public override double _Det(ILinAlgMat mat) { using (new Matlab.NamedLock("LA")) { Matlab.PutMatrix("LA.A", mat.ToArray()); double det = Matlab.GetValue("det(LA.A)"); Matlab.Clear(); return(det); } }
static void Main(string[] args) { double x = 0; for (int i = 0; i < 100000; i++) { Matlab.PutValue("x", x); Matlab.Execute("x=x+1;"); x = Matlab.GetValue("x"); //matlab.Execute("clear x"); System.Console.WriteLine(x); } }
protected override bool CorrImpl(Vector vec1, Vector vec2, out double corr) { NamedLock.FuncO <double, bool> func = delegate(out double lcorr) { Matlab.Clear("HTLib2_Matlab_CorrImpl"); Matlab.PutVector("HTLib2_Matlab_CorrImpl.vec1", vec1.ToArray()); Matlab.PutVector("HTLib2_Matlab_CorrImpl.vec2", vec2.ToArray()); Matlab.Execute("HTLib2_Matlab_CorrImpl.corr = corr(HTLib2_Matlab_CorrImpl.vec1, HTLib2_Matlab_CorrImpl.vec2);"); lcorr = Matlab.GetValue("HTLib2_Matlab_CorrImpl.corr"); Matlab.Clear("HTLib2_Matlab_CorrImpl"); return(true); }; //return NamedLock.LockedCall("bool HTLib2.Matlab.NumericSolver.CorrImpl(Vector, Vector, out double)", func, out corr); return(NamedLock.LockedCall(Matlab.NamedLock.GetName("HTLib2_Matlab_CorrImpl"), func, out corr)); }
public override Tuple <ILinAlgMat, double[]> _EigSymm(ILinAlgMat A) { using (new Matlab.NamedLock("LA")) { Matlab.PutMatrix("LA.A", A.ToArray()); Matlab.Execute("LA.A = (LA.A + LA.A)/2;"); Matlab.Execute("[LA.V, LA.D] = eig(LA.A);"); Matlab.Execute("LA.D = diag(LA.D);"); CMatrix V = Matlab.GetMatrix("LA.V"); double[] D = Matlab.GetVector("LA.D"); if (HDebug.IsDebuggerAttached) { Matlab.Execute("LA.ERR = LA.A - (LA.V * diag(LA.D) * LA.V');"); Matlab.Execute("LA.ERR = max(max(abs(LA.ERR)));"); double err = Matlab.GetValue("LA.ERR"); HDebug.AssertTolerance(0.00000001, err); } Matlab.Clear(); return(new Tuple <ILinAlgMat, double[]>(V, D)); } }