eigenvector

Calculating EigenVectors in C# using Advanced Matrix Library in C#. NET

半世苍凉 提交于 2019-12-30 07:06:07
问题 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

Mapping array back to an existing Eigen matrix

允我心安 提交于 2019-12-28 16:06:29
问题 I want to map an array of double to an existing MatrixXd structure. So far I've managed to map the Eigen matrix to a simple array, but I can't find the way to do it back. void foo(MatrixXd matrix, int n){ double arrayd = new double[n*n]; // map the input matrix to an array Map<MatrixXd>(arrayd, n, n) = matrix; //do something with the array ....... // map array back to the existing matrix } 回答1: I'm not sure what you want, but I'll try to explain. You're mixing double and float in your code (a

Does Matlab eig always returns sorted values?

試著忘記壹切 提交于 2019-12-28 02:56:05
问题 I use a function at Matlab: [V,D] = eig(C); I see that V and D are always sorted ascending order. Does it always like that or should I sort them after I get V and D values? 回答1: V is NOT sorted in any order, except to correspond to the order of the associated eigenvalues. But perhaps you did not mean that. The eigenvalues TEND to be in descending order, but this is not assured at all. They tend to be in order because the largest tend to trickle out of the algorithm on top. Eig has no sort at

Converting Eigen::MatrixXf to 2D std::vector

怎甘沉沦 提交于 2019-12-25 15:57:52
问题 Is there a more elegant solution than to copy the values point to point?! Something like this works for a 1D vector... vector<float> vec(mat.data(), mat.data() + mat.rows() * mat.cols()); I tried various other alternatives that were suggested by the GCC compiler for vector< vector > but nothing worked out... 回答1: Eigen::MatrixXf uses efficient linear memory, while a vector of vector would represent a very different datatype. For multidimentional vector, you would therefore have to read the

Inaccurate zheev eigen values and vectors

☆樱花仙子☆ 提交于 2019-12-25 01:58:52
问题 I use the LAPACK zheev routine in a Fortran scientific code to compute both eigenvalues and vectors of a matrix not too big (likely to never exceed size 1000). Since this step happens at the beginning of the computation I have to achieve a great accuracy to avoid important error propagation. The problem is that the accuracy of the computation is only about 1e-9 in my test case (with a 12x12 matrix only) and that is not enough at all. I compared with numpy.linalg.eigh which give ridiculously

Ordering of eigenvectors when calculating eigenvectors using LAPACK's ssteqr

邮差的信 提交于 2019-12-24 00:58:51
问题 I am using LAPACK's ssteqr function to calculate eigenvalues/eigenvectors. The documentation for ssteqr says that the eigenvalues are sorted "in ascending order" . Is it reasonable to assume that the list of eigenvectors is also sorted in ascending order? 回答1: Yes, it is reasonable to assume that the eigenvectors are ordered so that the i -th eigenvector corresponds to the i -th eigenvalue. Nevertheless, if I were you, I would check for each eigenvalue the result of the multiplication of the

Numpy seems to produce incorrect eigenvectors

倖福魔咒の 提交于 2019-12-23 04:14:09
问题 I want to use Numpy to calculate eigenvalues and eigenvectors. Here is my code: import numpy as np from numpy import linalg as LA lapl = np.array( [[ 2, -1, -1, 0, 0, 0], [-1, 3, 0, -1, 0, -1], [-1, 0, 2, -1, 0, 0], [ 0, -1, -1, 3, -1, 0], [ 0, 0, 0, -1, 2, -1], [ 0, -1, 0, 0, -1, 2]]) w, v = LA.eigh(lapl) print ('Eigenvalues:', np.round(w,0)) print ('Eigenvectors:', np.round(v,2)) Here is the result: Eigenvalues: [ 0. 1. 2. 3. 3. 5.] Eigenvectors: [[ 0.41 0.5 0.41 -0.46 0.34 0.29] [ 0.41 0.

Get non normalized eigenvectors in scipy

雨燕双飞 提交于 2019-12-22 11:20:57
问题 Scipy and Numpy returns eigenvectors normalized. I am trying to use the vectors for a physical application and I need them to not be normalized. For example a = np.matrix('-3, 2; -1, 0') W,V = spl.eig(a) scipy returns eigenvalues (W) of [-2,-1] and the modal matrix (V) (eigenvalues as columns) [[ 0.89442719 0.70710678][ 0.4472136 0.70710678]] I need the original modal matrix [[2 1][1 1]] 回答1: According to various related threads (1) (2) (3), there is no such thing as a "non normalized"

How to drop a perpendicular line from each point in a scatterplot to an (Eigen)vector?

蓝咒 提交于 2019-12-22 05:05:04
问题 I'm creating a visualization to illustrate how Principal Components Analysis works, by plotting Eigenvalues for some actual data (for the purposes of the illustration, I'm subsetting to 2 dimensions). I'm want a combination of these two plots from this fantastic PCA tutorial, only for my real data. I can plot the vectors and all ok: Person1 <- c(-3,1,1,-3,0,-1,-1,0,-1,-1,3,4,5,-2,1,2,-2,-1,1,-2,1,-3,4,-6,1,-3,-4,3,3,-5,0,3,0,-3,1,-2,-1,0,-3,3,-4,-4,-7,-5,-2,-2,-1,1,1,2,0,0,2,-2,4,2,1,2,2,7,0

spectral clustering

回眸只為那壹抹淺笑 提交于 2019-12-21 11:23:13
问题 First off I must say that I'm new to matlab (and to this site...) , so please excuse my ignorance. I'm trying to write a function in matlab that will use Spectral Clustering to split a set of points into two clusters. my code is as follows function Groups = TrySpectralClustering(data) dist_mat = squareform(pdist(data)); W= zeros(length(data),length(data)); for i=1:length(data), for j=(i+1):length(data), W(i,j)=10^(-dist_mat(i,j)); W(j,i)=W(i,j); end end D = zeros(length(data),length(data));