forum.alglib.net
http://forum.alglib.net/

needed help on how to use smatrixevd function
http://forum.alglib.net/viewtopic.php?f=2&t=118
Page 1 of 2

Author:  lovemebabe [ Thu Nov 11, 2010 2:36 pm ]
Post subject:  needed help on how to use smatrixevd function

Please someone post the program on how to pass arguments to smatrixevd function.
The alglib doesn't have any example on this function and neither it is available anywhere else on the net....
please.........

Author:  lovemebabe [ Thu Nov 11, 2010 2:48 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Here is what I am trying......
I am trying to find the eigenvalues of array samet....

real_2d_array samet[3][3]={{10,12,6},{12,15,7},{6,7,11}}, temp[2][2]; //
real_1d_array dd[2];
smatrixevd(samet,2,'U',1,dd,temp); //Please help here.......
for(int a =0; a<3;a++)
{
printf("%.6f ", dd[a]);
}

dd stores my eigen values(hope so)

Author:  Sergey.Bochkanov [ Thu Nov 11, 2010 2:56 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Try this:
Code:
real_2d_array samet = "[[10,12,6],[12,15,7],[6,7,11]]", temp;
real_1d_array dd;
smatrixevd(samet,3,2,true,dd,temp);
for(int a =0; a<3;a++)
{
    printf("%.6lf ", dd[a]);
}

Author:  lovemebabe [ Thu Nov 11, 2010 4:07 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Sergey.Bochkanov wrote:
Try this:
Code:
real_2d_array samet = "[[10,12,6],[12,15,7],[6,7,11]]", temp;
real_1d_array dd;
smatrixevd(samet,3,2,true,dd,temp);
for(int a =0; a<3;a++)
{
    printf("%.6lf ", dd[a]);
}

Dear Admin,
Thank you for the reply..
I compiled the code in Netbeans in windows 7, Cygwin environment, and the code builds successfully.
But the output is not there.
The command window shows the error as:
"terminate called after throwing an instance of 'alglib::ap_error'"

What could be the reason?

Author:  Sergey.Bochkanov [ Thu Nov 11, 2010 4:19 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Sorry, it must be

Code:
smatrixevd(samet,3,[b]1[/b],true,dd,temp);


not

Code:
smatrixevd(samet,3,[b]2[/b],true,dd,temp);


in case of other errors you can catch ap_error exception and inspect msg field.

Author:  lovemebabe [ Thu Nov 11, 2010 4:29 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Sergey.Bochkanov wrote:
Sorry, it must be

Code:
smatrixevd(samet,3,[b]1[/b],true,dd,temp);


not

Code:
smatrixevd(samet,3,[b]2[/b],true,dd,temp);


in case of other errors you can catch ap_error exception and inspect msg field.



Thank You Admin, Alglib is great....
Now, it works perfectly...

Author:  lovemebabe [ Thu Nov 11, 2010 7:26 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

Suppose I have an array as "double samet [3][3] = [[10,12,6],[12,15,7],[6,7,11]];"
And I want to eigenvalues of this array.
How do I typecast this to real_2d_array from double;

I need to do this as I am having a matrix from other program which is declared double[][];

Author:  Sergey.Bochkanov [ Thu Nov 11, 2010 8:24 pm ]
Post subject:  Re: needed help on how to use smatrixevd function

You can allocate array with setlength call and assign values to its elements manually.

Author:  purevil [ Fri Nov 12, 2010 4:52 am ]
Post subject:  Re: needed help on how to use smatrixevd function

Sergey.Bochkanov wrote:
Sorry, it must be

Code:
smatrixevd(samet,3,[b]1[/b],true,dd,temp);


not

Code:
smatrixevd(samet,3,[b]2[/b],true,dd,temp);


in case of other errors you can catch ap_error exception and inspect msg field.


I am trying to use this function too, and my purpose is to get eigenvectors of a matrix.
I tried the sample code, it can return eigenvalues alright, but the eigenvectors matrix (temp for sample code) is all zeros, can somebody help me with this please~

Author:  Sergey.Bochkanov [ Fri Nov 12, 2010 8:22 am ]
Post subject:  Re: needed help on how to use smatrixevd function

Can you post code which calls ALGLIB and gets zero matrix?

Page 1 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/