LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Input Matrix to the SymEigenValueVector Function

Fatal runtime error when a 2D Array is input to the function: eg:
"Array argument too small (44bytes). Argument must contain atleast 6720 bytes."
0 Kudos
Message 1 of 7
(3,739 Views)
Actuall, the input array must be 2D and it must be square (nxn same number of rows as columns). I tried it with a 2D 5x5 array entering 5 for size and it worked fine.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 7
(3,739 Views)
Thank you. However, does it matter whether the 2D array is created as a double pointer (** Input_Matrix) or as pointer to rows of the array (* Input_Matrix)?

I have a 2D nXn array: *Input_Matrix with n as the size, and I still get the error.
0 Kudos
Message 3 of 7
(3,739 Views)
2D arrays in C are NOT double**. A 1D array of double* is NOT a 2D array. 1D or multi-dimension numeric arrays are just double* to a allocated buffer of size (dim1*dim2*dim3...). That is why you are getting the problem. you need a single memory block with a double*, not an array of double* blocks.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 7
(3,739 Views)
Thank you!
However, I tried the following array on SymEigenValueVector and the Eigen Vectors that the pgm prints out, seem to be wrong.

If the input matrix should be a single memory block with a double *, how is the matrix read from this memory block (row-wise, or column-wise)?

int main()
{
int i, j;
double * array;
double * EValues;
double * EVectors;

EValues = (double *) malloc(2*sizeof(double));
EVectors = (double *) malloc(4*sizeof(double));
array = (double *) malloc(4*sizeof(double));
array[0] = 2;
array[1] = -1;

array[2] = 0;
array[3] = 1;

SymEigenValueVector (array, 2, 1, EValues,
EVectors);

Cls ();

for (i=0; i<2;i++) {
printf("evalues = %f\n",EValues[i]);
}
printf("===================
=====\n");
for (i=0; i<4;i++) {
printf("EVectors = %f\n",EVectors[i]);
}

return 0;
}


evalues = 2.000000
evalues = 1.000000
========================
EVectors = 1.000000
EVectors = 0.000000
EVectors = 0.000000
EVectors = 1.000000

Thank you!
0 Kudos
Message 5 of 7
(3,739 Views)
It's in memory row-wise. So the array you are sending in is:

2 -1
0 1

Remember, this function says it is looking for a 2D array input. If you are mallocing and trying to mimic a 2D array, a good thing to do is declare a 2D array (double [][]), fill it, and look at it in memory with the Memory Display (Window->Memory Display) in double format. Then you will know exactly what a 2D array looks like in the memory buffer.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 6 of 7
(3,739 Views)
Thank you. If that is the case, should'nt my E.Vectors be
EVectors = 1.000000
EVectors = 0.000000
EVectors = 1.000000
EVectors = 1.000000

instead of 1,0,0,1 (as printed by the pgm) for the given input?
0 Kudos
Message 7 of 7
(3,739 Views)