el 02-28-2014 05:45 PM
Hello,
I am writing an application in LabWindows CVI to display and analize data that we obtain in an optical experiment. The data is a matrix where the subsequent rows represent spectra collected a different times. There are about 200 columns and 100 rows in each matrix. I want to use singular value decomposition using the SVDEx function. I get an error every time i try to execute the code in debugguing mode:
FATAL RUN-TIME ERROR: The program has caused a 'General Protection' fault at 0x0342BC16.
I believe that I am passing the incorrect arrays to SVDEx. I was wondering if there is any example code available, so I can learn how tro do do this.
Here is a fragment of the code where I call the function SVDEx:
//declare the arrays to hold S U V
double *U,*S,*V;
int isizeS=Y_DATA_POINTS;
int i;
int AnalisisError=0;
if (X_DATA_POINTS<Y_DATA_POINTS) {isizeS=X_DATA_POINTS;}
//Allocate arrays
U=malloc(Y_DATA_POINTS*X_DATA_POINTS*sizeof(double));
S=malloc(2*isizeS*sizeof(double));
V=malloc(Y_DATA_POINTS*X_DATA_POINTS*sizeof(double));
AnalisisError = SVDEx (adAbsMap, Y_DATA_POINTS, X_DATA_POINTS, FULL_SIZE, U, S+isizeS, V);
FATAL RUN-TIME ERROR: "Visualize_12.c", line 2451, col 17, thread id 0x00000E18: The program has caused a 'General Protection' fault at 0x0342BC16.
Any help will be very much appreciated.
J. Hodak
el 03-03-2014 06:35 PM
Hi J. Hodak,
I wasn't able to find any example programs. Have you seen the help document for this function?
http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvisvdex/
What's happening in your code at "Visualize_12.c", line 2451, col 17?
el 03-04-2014 09:37 AM
Hi,
Thanks for trying to find an answer. I just realized now where the probem was. My mistake was when i allocated the arrays for holding the matrices. Because i was assking SVDEx to carry out FUL SIZE decomposition I must declare the arrays U and V to be , Y_DATA_POINTS*, Y_DATA_POINTS doubles and X_DATA_POINTS*, X_DATA_POINTS doubles respectively. My code was wrong, I was declaring the sizes to be smaller than necessary and "Visualize_12.c", line 2451, was the call to SVDEx, and col 17 was pointing t that mistake. It took me a while to realize this because the error message did not exlicitly specify that the size or the array passed was too small. Now it is working well. But I believe that it will help to have an example to get started with this.
Thanks again,
Fundadero.