Hello Sergey,
Here is a sample of the code I use. Nothing special really. I debugged it over and over and as long as it is called from a .net program there is no problem. When this is called from a COM interface I get an access violation although the call is made from an try catch block. This shouldn't be possible.
Actually I don't think that there is a bug in your or my code but that this code triggers a problem in the .net framework in combination with COM interop.
I guess there is some memory management problem. e.g. During debugging the com interface, I changed the code from:
vector.Add(alglib.spline1dcalc(splineInts[col], newIndices[row])); //Vector = List<double>
to:
double x = alglib.spline1dcalc(splineInts[col], newIndices[row]); vector.Add(x);
which is a useless change, but I could run the calculation without a problem. Restarting the application with this code resulted in an access violation again.
Do you have an idea what could be the cause of the problem? Do you use recursion in the spline calculations? Can the stack size be a problem? Maybe it is the Vector.Add function that crashes the memory manager when called 700 times?
My code: //build splines for all slaves based on rows alglib.spline1dinterpolant[] splineInts = new alglib.spline1dinterpolant[nSlaves]; for (int i = 0; i < nSlaves; i++) { double[] sval = absMatrix.ValuesBySlaveIndex(i); //get an array with y-values alglib.spline1dbuildakima(absIndices , sval , out splineInts[i]); //absIndices=x-values, sval=y-values }
//interpolate slave splines based on newRows PreMatrix newMatrix = new PreMatrix(); //Matrix with slave positions in a column for (int row = 0; row < newIndices.Count; row++) //NewIndices = array with new x-values { PreVector vector = new PreVector(); for (int col = 0; col < nSlaves; col++) { vector.Add(alglib.spline1dcalc(splineInts[col], newIndices[row])); } newMatrix.Add(vector); }
|