eigenvector

Why some eigen vector signs from C++ Armadillo are different from Python and R

我的梦境 提交于 2019-12-02 20:08:32
问题 I was wondering why the sign of the elements in the eigen vectors from Armadillo is the opposite from other languages like Python (i.e. numpy) and R. For example: C++ using namespace arma; vec eigval; mat eigvec; // C++11 initialization mat A = { 1, -1, 0, -1, 2, -1, 0, -1, 1}; eig_sym(eigval, eigvec, A); eigvec.print("Eigen Vectors"); Output Eigen Vectors -5.7735e-01 -7.071068e-01 0.4082483 -5.7735e-01 9.714451e-e17 -0.8164966 -5.7735e-01 7.017068e-01 0.4082483 Python import numpy as np w,v

eigenfaces are not showing correctly and are very dark

牧云@^-^@ 提交于 2019-12-02 19:04:20
问题 I need to show 1st 10 eigenfaces using PCA for a image feature vector matrix. I am using following matlab code to create 1st eigenface but I am getting very dark and not so correct eigenfaces. eFea is a matrix of 240x4096 where each row represents an image of 64x64 newData = eFea'; data = newData; [M,N] = size(data); mn = mean(data,2); data = double(data) - repmat(mn,1,N); % construct the matrix Y Y = data' / sqrt(N-1); % SVD [u,S,PC] = svd(Y,0); imshow(reshape(PC(1,:),64,64)) any hints

eigenvectors from numpy.eig not orthogonal

那年仲夏 提交于 2019-12-02 10:19:49
my problem is the following: using scipy.linalg.eig to get eigenvectors and eigenvalues i see that all my eigenvalues have multiplicity 1 yet when i run the code below it doesn't confirm that the eigenvectors are orthogonal as they should be in this case. any reason why this would be? or how to fix it? import scipy as SP import numpy as NP from scipy import linalg from numpy import linspace,asscalar,argsort import cmath import time matA=SP.array([[-0.0001, 0., 0., 0.00001, 0., 0., 0.00002, 0.],[0., -0.0002, 0., 0., 0., 0., 0., 0.],[0., 0., -0.00015, 0., 0., -9.*10**-6, 0., -0.00005],[0.00001,

Eigen Values and Eigen Vectors Matlab

半城伤御伤魂 提交于 2019-12-02 10:03:38
I have a matrix A A = [ 124.6,95.3,42.7 ; 95.3,55.33,2.74 ; 42.7,2.74,33.33 ] The eigenvalues and vectors: [V,D] = eig(A) How do I show the eigenvalues are mutually perpendicular? I've tried that if the dot product of the eigenvalues are zero, this demonstrates they are mutually perpendicular, but how would you compute this in MATLAB? I tried the following code transpose(diag(D)) * diag(D) %gives 4.1523e+04 Also, how can I verify the definition of eigenvalues and vector holds: A e_i - L_i e_i = 0 The above equation: for i equal 1 to 3. For a real, symmetric matrix all eigenvales are positive

Sign difference in eigenvectors taken form Matlab and Python

流过昼夜 提交于 2019-12-01 21:53:05
Could you please explain why there is a sign difference in some of the eigenvectors (2-4)? Does this difference affect further calculation in further calculations, e.g dimensionality reduction? Matlab: N = 5000; dataA = rand(N,5); covA = cov(dataA); %covA = dataA*dataA'/(length(dataA)-1); covA = covA + eps.*eye(size(covA)); [~,pA] = chol(covA); assert(pA==0,'A is not possitive definite') dataB = rand(N,5); covB = cov(dataB); %covB = dataB*dataB'/(length(dataB)-1); covB = covB + eps.*eye(size(covB)); [~,pB] = chol(covB); assert(pB==0,'B is not possitive definite') [V,D] = eig(covA, covB); V =

Sign difference in eigenvectors taken form Matlab and Python

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 21:50:54
问题 Could you please explain why there is a sign difference in some of the eigenvectors (2-4)? Does this difference affect further calculation in further calculations, e.g dimensionality reduction? Matlab: N = 5000; dataA = rand(N,5); covA = cov(dataA); %covA = dataA*dataA'/(length(dataA)-1); covA = covA + eps.*eye(size(covA)); [~,pA] = chol(covA); assert(pA==0,'A is not possitive definite') dataB = rand(N,5); covB = cov(dataB); %covB = dataB*dataB'/(length(dataB)-1); covB = covB + eps.*eye(size

Conflicting eigen vector outputs between Matlab and Numpy

北城余情 提交于 2019-12-01 16:06:44
I am calculating eigenvectors in Matlab and Numpy, but getting different results. I was under the impression there was only one set of eigenvectors for a given matrix, however both of these outputs seem valid. Here is my matlab code: m = [ 1.4675 + 0.0000i 0.1669 + 1.2654i; 0.1669 - 1.2654i 1.3085 + 0.0000i] [eig_vec,eig_val] = eig(m) eig_val contains: eig_val = 0.1092 0 0 2.6668 eig_vec contains: eig_vec = 0.0896 + 0.6789i 0.0953 + 0.7225i -0.7288 + 0.0000i 0.6848 + 0.0000i Here is my python code: m = np.array([[1.46753694+0.j, 0.16692111+1.26535838j], [0.16692111-1.26535838j, 1.30851770+0.j]

Conflicting eigen vector outputs between Matlab and Numpy

拟墨画扇 提交于 2019-12-01 15:48:51
问题 I am calculating eigenvectors in Matlab and Numpy, but getting different results. I was under the impression there was only one set of eigenvectors for a given matrix, however both of these outputs seem valid. Here is my matlab code: m = [ 1.4675 + 0.0000i 0.1669 + 1.2654i; 0.1669 - 1.2654i 1.3085 + 0.0000i] [eig_vec,eig_val] = eig(m) eig_val contains: eig_val = 0.1092 0 0 2.6668 eig_vec contains: eig_vec = 0.0896 + 0.6789i 0.0953 + 0.7225i -0.7288 + 0.0000i 0.6848 + 0.0000i Here is my python

C++ linear algebra library armadillo : how to use eig_pair to get the same result as eig function in Matlab?

随声附和 提交于 2019-12-01 12:09:13
I try to use eig_pair to get Eigen decomposition for pair of general dense square matrices A and B of the same size, such that A*eigvec = B*eigvec*diagmat(eigval), but the result doesn't match the Matlab function eig. for example: A= [1,2;3,4] B=[2,4;5,8] in Matlab: [u,v] = eig(A,B) result: u = -1.0000 -0.0000 0.5000 -1.0000 v = 1.0000 0 0 0.5000 in armadillo: eig_pair(v,u,A,B) result: u: 9.9301e-016 -1.0000e+000 1.0000e+000 5.0000e-001 v: 0.5000 1.0000 My question is: how to get the values of u and v that match the results in Matlab? Looking forwards to your reply!!! Eigenvectors are not

C++ linear algebra library armadillo : how to use eig_pair to get the same result as eig function in Matlab?

隐身守侯 提交于 2019-12-01 11:57:27
问题 I try to use eig_pair to get Eigen decomposition for pair of general dense square matrices A and B of the same size, such that A*eigvec = B*eigvec*diagmat(eigval), but the result doesn't match the Matlab function eig. for example: A= [1,2;3,4] B=[2,4;5,8] in Matlab: [u,v] = eig(A,B) result: u = -1.0000 -0.0000 0.5000 -1.0000 v = 1.0000 0 0 0.5000 in armadillo: eig_pair(v,u,A,B) result: u: 9.9301e-016 -1.0000e+000 1.0000e+000 5.0000e-001 v: 0.5000 1.0000 My question is: how to get the values