Hi there, newbie here.
I did a search but could not find good answer to my question.
I have a simple LabView vi that takes in a 2D Array (user defines it, it is a "control" input) called A, an array b, and an initialized (all zeros) array x that is the same size as b.
Then I am trying to pass this to a C function in a library I'm writing, which will solve Ax=b.
I do not know in advance the size of the matrix A, but it is assumed to be square (therefore it is the same size as arrays b and x).
My problem is passing this matrix A into my function. I can pass b and x successfully, but my execution chokes up on A.
Here's my C function prototype:
_declspec(dllexport) unsigned char GaussJordan(double **A, double b[], double x[], unsigned long dim);
However, when I do to "configure" in the dll vi, it keeps generating the prototype:
unsigned char GaussJordan(double *A, double *b, double *x, unsigned long dim);
even when I tell it that A should be a 2D array.
When I stop my debugger right inside my C function call, I see that A[0] is 0, and then A[0][0] "cannot be evaluated".
When I change my function prototype to:
_declspec(dllexport) unsigned char GaussJordan(double A[3][3], double b[], double x[], unsigned long dim);
for instance, then with my debugger I can see inside my GaussJordan an A matrix that makes sense (i.e. is exactly what I passed in). However, this is then a problem because inside GaussJordan I have a function call to:
solveeqn(double **A, double b[], double[x], unsigned long size)
Which dies because A[3][3] is not of type double *[3].
Since I am using solveeqn on matrices of variable size elsewhere on the code, I cannot lock it to the size that labview desires. Not to mention that having to write a different vi to C interface on the day I decide to solve 4x4 matrices instead of 3x3 matrices is too much work.
So, the question is: how do I pass a variable-sized (assumed square) 2D array from LabView into a C function, if the size of this array is unknown in advance/unknown at compile time??
Any help will be greatly appreciated!
Thanks,
-Elisa.