eigenvalue

Matlab VS Python - eig(A,B) VS sc.linalg.eig(A,B)

大憨熊 提交于 2019-12-17 14:54:41
问题 I have the following matrices sigma and sigmad: sigma: 1.9958 0.7250 0.7250 1.3167 sigmad: 4.8889 1.1944 1.1944 4.2361 If I try to solve the generalized eigenvalue problem in python I obtain: d,V = sc.linalg.eig(matrix(sigmad),matrix(sigma)) V: -1 -0.5614 -0.4352 1 If I try to solve the g. e. problem in matlab I obtain: [V,d]=eig(sigmad,sigma) V: -0.5897 -0.5278 -0.2564 0.9400 But the d's do coincide. 回答1: Any (nonzero) scalar multiple of an eigenvector will also be an eigenvector; only the

eigenvalue decomposition of structure tensor in matlab

杀马特。学长 韩版系。学妹 提交于 2019-12-13 18:07:38
问题 I have a synthetic image. I want to do eigenvalue decomposition of local structure tensor (LST) of it for some edge detection purposes. I used the eigenvalues l1 , l2 and eigenvectors e1 , e2 of LST to generate an adaptive ellipse for each pixel of image. Unfortunately I get unequal eigenvalues l1 , l2 and so unequal semi-axes length of ellipse for homogeneous regions of my figure: However I get good response for a simple test image: I don't know what is wrong in my code: function [H,e1,e2,l1

Eigenvalue calculation using TQLI algorithm fails with segmentation fault

丶灬走出姿态 提交于 2019-12-13 03:50:35
问题 I am trying to calculate eigenvalues using the TQLI algorithm that I got from the website of the CACS of the University of Southern California. My test script looks like this: #include <stdio.h> int main() { int i; i = rand(); printf("My random number: %d\n", i); float d[4] = { {1, 2, 3, 4} }; float e[4] = { {0, 0, 0, 0} }; float z[4][4] = { {1.0, 0.0, 0.0, 0.0} , {0.0, 1.0, 0.0, 0.0} , {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 0.0, 1.0} }; double *zptr; zptr = &z[0][0]; printf("Element [2][1] of

one of Eigenvalues of covariance matrix is negative in R

只谈情不闲聊 提交于 2019-12-13 00:11:57
问题 I have a data set x . And I use cov(x) to calculate the covariance of x . I want to calculate the inverse square root of cov(x) . But I get negative eigenvalue of cov(x) . Here is my code S11=cov(x) S=eigen(S11,symmetric=TRUE) R=solve(S$vectors %*% diag(sqrt(S$values)) %*% t(S$vectors)) This is the eigenvalue of S . c(0.897249923338732, 0.814314811717616, 0.437109871173458, 0.334921280373883, 0.291910583884559, 0.257388456770167, 0.166787180227719, 0.148268784967556, 0.121401731579852, 0

Find a matrix that gives same result when multiplied by a constant or another matrix

大城市里の小女人 提交于 2019-12-12 16:15:35
问题 I have got a problem like A*x=lambda*x , where A is of order d*d , x is of order d*c and lambda is a constant. A and lambda are known and the matrix x is unknown. Is there any way to solve this problem in matlab?? (Like eigen values but x is a d*c matrix instead of being a vector). 回答1: If I've understood you correctly, there will not necessarily be any solutions for x . If A*x=lambda*x , then any column y of x satisfies A*y=lambda*y , so the columns of x are simply eigenvectors of A

Largest eigenvalues (and corresponding eigenvectors) in C++

走远了吗. 提交于 2019-12-12 14:37:00
问题 What is the easiest and fastest way (with some library, of course) to compute k largest eigenvalues and eigenvectors for a large dense matrix in C++? I'm looking for an equivalent of MATLAB's eigs function; I've looked through Armadillo and Eigen but couldn't find one, and computing all eigenvalues takes forever in my case (I need top 10 eigenvectors for an approx. 30000x30000 dense non-symmetric real matrix). Desperate, I've even tried to implement power iterations by myself with Armadillo's

Finding eigenvectors and eigenvalues of a sparse matrix with ARPACK ( called form PYTHON, MATLAB or as a FORTRAN subroutine)

主宰稳场 提交于 2019-12-12 10:17:26
问题 Few days ago I asked a question how to find the eigenvalues of a large sparse matrix. I got no answers, so I decided to describe a potential solution. One question remains: Can I use the python implementation of ARPACK to compute the eigenvalues of a asymmetric sparse matrix. At the beginning I would like to say that it is not at all necessary to call the subroutines of ARPACK directly using FOTRAN driver program. That is quite difficult and I never got it going. But one can do the following:

Preventing scipy eigenvectors differing from computer to computer

杀马特。学长 韩版系。学妹 提交于 2019-12-12 09:48:41
问题 Following up on this question about how to find the Markov steady state, I'm now running into the problem that it works perfectly on my lab computer, but it doesn't work on any other computer. Specifically, it always finds the correct number of near-one eigenvalues, and thus which nodes are attractor nodes, but it doesn't consistently find all of them and they aren't grouped properly. For example, using the 64x64 transition matrix below, the computers in which it doesn't work it always

Eigenvalue decomposition of correlation matrix [closed]

别来无恙 提交于 2019-12-12 02:53:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a correlation matrix: cor.table <- matrix( sample( c(0.9,-0.9) , 2500 , prob = c( 0.8 , 0.2 ) , repl = TRUE ) , 50 , 50 ) diag(cor.table) <- 1 I try to do eigenvalue decomposition: library(psych) fit<-principal(cor.table, nfactors=50,rotate="none") or stopifnot( eigen( cor.table )$values > 0 ) In both

Eigenvalues for matrices in a for loop

允我心安 提交于 2019-12-11 17:54:14
问题 I need to calculate eigenvalues of a series of matrices and then save them in a separate file. My data has 5 columns and 10,000 rows. I use the following functions: R<-NULL A <- setwd("c:/location of the file on this computer") for(i in 0:1){ X<-read.table(file="Example.prn", skip=i*5, nrow=5) M <- as.matrix(X) E=eigen(M, only.values = TRUE) R<-rbind(R,E)} print(E) } As an example I have used a data set with 10 rows and 5 columns. This gives me the following results: $`values` [1] 1.350000e