Ok guys, I am using the following library: http://www.codeproject.com/KB/recipes/AdvancedMatrixLibrary.aspx
And I wish to calculate the eigenvectors of certain matrices I have. I do not know how to formulate the code.
So far I have attempted:
Matrix MatrixName = new Matrix(n, n);
Matrix vector = new Matrix(n, 0);
Matrix values = new Matrix(n, 0);
Matrix.Eigen(MatrixName[n, n], values, vector);
However it says that the best overloaded method match has some invalid arguments. I know the library works but I just do not know how to formulate my c# code.
Any help would be fantastic!
Looking at the Library, the signature of the Eigen method looks like this:
public static void Eigen(Matrix Mat, out Matrix d,out Matrix v)
There are a few errors:
Notice the out
keyword next to the d and v parameters. You need to add the out keyword to the call to Eigen.
The code expects a Matrix as the first argument, while you are sending an element. Thus, MatrixName[n, n]
needs to change to MatrixName
.
You don't need to instantiate the vector and values Matrices, since the Eigen method does this for you and will return the values in the two arguments you send thanks to the out keyword. One thing to note as well is that you will receive the output as follows:
values will be a [n+1,1] Matrix
vector will be a [n+1,n+1] Matrix
Not as Matrix(n, 0) as you expect from your initial code.
The code will look like this:
Matrix MatrixName = new Matrix(n, n);
Matrix vector;
Matrix values;
Matrix.Eigen(MatrixName, out values, out vector);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With