Questions tagged [eigenvalue]
The eigenvalue is the factor by which the eigenvector is scaled when multiplied by the matrix.
eigenvalue
760
questions
54
votes
2
answers
167k
views
Python Numpy TypeError: ufunc 'isfinite' not supported for the input types
Here's my code:
def topK(dataMat,sensitivity):
meanVals = np.mean(dataMat, axis=0)
meanRemoved = dataMat - meanVals
covMat = np.cov(meanRemoved, rowvar=0)
eigVals,eigVects = np.linalg....
45
votes
2
answers
62k
views
whats the fastest way to find eigenvalues/vectors in python?
Currently im using numpy which does the job. But, as i'm dealing with matrices with several thousands of rows/columns and later this figure will go up to tens of thousands, i was wondering if there ...
38
votes
8
answers
32k
views
How expensive is it to compute the eigenvalues of a matrix?
How expensive is it to compute the eigenvalues of a matrix?
What is the complexity of the best algorithms?
How long might it take in practice if I have a 1000 x 1000 matrix? I assume it helps if ...
27
votes
1
answer
1k
views
Why eigenvector & eigenvalue in LDA become zero?
I'd like to implement fast PLDA (Probabilistic Linear Discriminant Analysis) in OpenCV. in this, LINK fast PLDA have been implemented in Matlab and Python. One of the parts of PLDA is LDA. I've ...
24
votes
3
answers
49k
views
Numpy transpose multiplication problem
I tried to find the eigenvalues of a matrix multiplied by its transpose but I couldn't do it using numpy.
testmatrix = numpy.array([[1,2],[3,4],[5,6],[7,8]])
prod = testmatrix * testmatrix.T
print ...
20
votes
1
answer
1k
views
Calculating eigen values of very large sparse matrices in python
I have a very large sparse matrix which represents a transition martix in a Markov Chain, i.e. the sum of each row of the matrix equals one and I'm interested in finding the first eigenvalue and its ...
18
votes
8
answers
9k
views
What is the fastest way to calculate first two principal components in R?
I am using princomp in R to perform PCA. My data matrix is huge (10K x 10K with each value up to 4 decimal points). It takes ~3.5 hours and ~6.5 GB of Physical memory on a Xeon 2.27 GHz processor.
...
18
votes
1
answer
3k
views
Matlab's eigs not converging unless number of eigenvalues computed is large
I am trying to compute the eigenvalues, λ (lambda), of a damped structure with the following equations of motion:
(λ²M + λC + K) x = 0,
where M, C, and K are sparse matrices. Using MATLAB's polyeig ...
15
votes
2
answers
36k
views
Does Matlab eig always returns sorted values?
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?
15
votes
1
answer
16k
views
What is the difference between 'eig' and 'eigs'?
I've searched a lot for this but I can't find any answer about how the two methods 'eig' and 'eigs' differ. What is the difference between the eigenvalues and eigenvectors received from them?
14
votes
2
answers
4k
views
Python eigenvalue computations run much slower than those of MATLAB on my computer. Why?
I would like to compute the eigenvalues of large-ish matrices (about 1000x1000) using Python 2.6.5. I have been unable to do so quickly. I have not found any other threads addressing this question.
...
12
votes
1
answer
5k
views
scipy eigh gives negative eigenvalues for positive semidefinite matrix
I am having some issues with scipy's eigh function returning negative eigenvalues for positive semidefinite matrices. Below is a MWE.
The hess_R function returns a positive semidefinite matrix (it is ...
11
votes
1
answer
17k
views
c++ find eigenvalues and eigenvectors of matrix
I'm writing an algorithm with a lot of steps (PCA), and two of them are finding eigenvalues and eigenvectors of a given matrix.
I do not wish to write the whole code for it because I know it is a ...
10
votes
5
answers
7k
views
how to implement eigenvalue calculation with MapReduce/Hadoop?
It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy ...
9
votes
4
answers
20k
views
Eigenvalues in MATLAB
In MATLAB, when I run the command [V,D] = eig(a) for a symmetric matrix, the largest eigenvalue (and its associated vector) is located in last column. However, when I run it with a non-symmetric ...
9
votes
6
answers
7k
views
Singular Value Decomposition (SVD) in PHP
I would like to implement Singular Value Decomposition (SVD) in PHP. I know that there are several external libraries which could do this for me. But I have two questions concerning PHP, though:
1) Do ...
9
votes
3
answers
27k
views
Python numpy compute first eigenvalue and eigenvector
I was wondering if there is a Python package, numpy or otherwise, that has a function that computes the first eigenvalue and eigenvector of a small matrix, say 2x2. I could use the linalg package in ...
9
votes
0
answers
725
views
Eigen/Eigenvalues: Too many sections with mingw-w64
I want to compile the following example based on Eigen's general eigenvalue solver (Eigen 3.3.3):
#include <iostream>
#include <Eigen/Eigenvalues>
int main()
{
Eigen::Matrix4f A;
...
8
votes
2
answers
18k
views
Mapping array back to an existing Eigen matrix
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, ...
8
votes
4
answers
15k
views
Simultaneously diagonalize matrices with numpy
I have a m × n × n numpy.ndarray of m simultaneously diagonalizable square matrices and would like to use numpy to obtain their simultaneous eigenvalues.
For example, if I had
from numpy import ...
8
votes
2
answers
2k
views
What's the best small C++ package to compute the largest eigenvalue of a matrix? [closed]
I need to compute the largest eigenvalue of a (sparse) matrix. I implemented the power iteration method, but it is too slow to converge, so I'd like to use a package for it. Does anyone have a ...
7
votes
2
answers
14k
views
Find eigenvector for a given eigenvalue R
I have a matrix 100x100 and I found it's biggest eigenvalue. Now I need to find eigenvector corresponding to this eigenvalue. How can I do this?
7
votes
2
answers
20k
views
How do I find out eigenvectors corresponding to a particular eigenvalue of a matrix?
How do I find out eigenvectors corresponding to a particular eigenvalue?
I have a stochastic matrix(P), one of the eigenvalues of which is 1. I need to find the eigenvector corresponding to the ...
7
votes
2
answers
18k
views
Plot a Correlation Circle in Python
I've been doing some Geometrical Data Analysis (GDA) such as Principal Component Analysis (PCA). I'm looking to plot a Correlation Circle... these look a bit like this:
Basically, it allows to ...
7
votes
1
answer
404
views
Eigenvectors are complex but only for large matrices
I'm trying to calculate the eigenvectors and eigenvalues of this matrix
import numpy as np
la = 0.02
mi = 0.08
n = 500
d1 = np.full(n, -(la+mi), np.double)
d1[0] = -la
d1[-1] = -mi
d2 = np.full(n-1, ...
7
votes
3
answers
4k
views
how to calculate 2^n modulo 1000000007 , n = 10^9
what is the fastest method to calculate this, i saw some people using matrices and when i searched on the internet, they talked about eigen values and eigen vectors (no idea about this stuff)...there ...
7
votes
1
answer
11k
views
How to make the eigenvalues and eigenvectors stay real instead of complex?
I try to diagonalize a n*100*100 3d matrix K by numpy.linalg.eig and get the eigenvalues w and eigenvectors v. The matrix is 100*100, but I wanna do it with broadcasting, and that's the number n I set ...
7
votes
1
answer
8k
views
Computation of symbolic eigenvalues with sympy
I'm trying to compute eigenvalues of a symbolic complex matrix Mof size 3x3. In some cases, eigenvals() works perfectly. For example, the following code:
import sympy as sp
kx = sp.symbols('kx')
x = ...
7
votes
3
answers
891
views
GSL eigenvalues order
I am using the functions gsl_eigen_nonsymm and/or gsl_eigen_symm from the GSL library to find the eigenvalues of an L x L matrix M[i][j] which is also a function of time t = 1,....,N so i have M[i][j][...
7
votes
1
answer
5k
views
Python OpenCV PCACompute Eigenvalue
When using Python 2.7.5 with OpenCV (OSX), I run PCA on a sequence of images (cols are pixels, rows are frames as per this answer.
How do I get the eigenvalues corresponding to the eigenvectors? ...
7
votes
1
answer
234
views
Matching similar eigenspectra in two matrices
I have two matrices for which part of the eigenspectrum of one matrix, very closely resembles the eigenspectrum of another matrix, but the only way I'm (currently) able to verify this is quite ...
6
votes
4
answers
12k
views
Sort eigenvalue matrix with eigenvector matrix
I have N eigenvalues in column vector form.
Thus there are N eigenvectors corresponding to these eigenvalues, forming an eigenvector matrix.
Now, the problem I am working on requires me to sort the ...
6
votes
2
answers
8k
views
complex eigen values in PCA calculation
Iam trying to calculate PCA of a matrix.
Sometimes the resulting eigen values/vectors are complex values so when trying to project a point to a lower dimension plan by multiplying the eigen vector ...
6
votes
2
answers
4k
views
Issue with computing eigenvalues using mathematica
Basically I'm trying to find the eigenvalues for matrix, and it takes about 12 hours. When it finishes, it says it couldn't find all the eigenvectors (actually barely any), and I'm skeptical about the ...
6
votes
7
answers
4k
views
Copying upper MatrixXd to lower MatrixXd (Eigen3) C++ library
I've got a lower triangular MatrixXd and I want to copy its lower values to the upper side as it'll become a symmetric matrix. How can I do it?
So far I've done:
MatrixXd m(n,n);
.....
//do ...
6
votes
3
answers
1k
views
Fast methods for approximating the highest 3 eigenvalues and eigenvectors of a large symmetric matrix
I am writing code to compute Classical Multidimensional Scaling (abbreviated to MDS) of a very large n by n matrix, n = 500,000 in my example.
In one step of MDS, I need to compute the highest ...
6
votes
1
answer
3k
views
LAPACK giving me incorrect eigenvalues
I am using DSYEV and DSYEVD from the LAPACK library to find eigenvalues and eigenvectors (Compilation syntax: gfortran -llapack ). However, I find wrong eigenvalues (-0.44,0.35,0.88) for a particular ...
6
votes
2
answers
368
views
Can't get a positive definite variance matrix when very small eigen values
To run a Canonical correspondence analysis (cca package ade4) I need a positive definite variance matrix. (Which in theory is always the case)
but:
matrix(c(2,59,4,7,10,0,7,0,0,0,475,18714,4070,97,...
6
votes
1
answer
4k
views
Incorrect EigenValues/Vectors with Numpy
I am trying to find the eigenvalues/vectors for the following matrix:
A = np.array([[1, 0, 0],
[0, 1, 0],
[1, 1, 0]])
using the code:
from numpy import linalg as LA
...
6
votes
1
answer
9k
views
Computing N smallest eigenvalues of Sparse Matrix in Python
I'd like to find the N smallest eigenvalues of a sparse matrix in Python. I've tried using the scipy.sparse.linalg.eigen.arpack package, but it is very slow at computing the smallest eigenvalues. I ...
6
votes
2
answers
829
views
How to use eig with the nobalance option as in MATLAB?
In MATLAB I can issue the command:
[X,L] = eig(A,'nobalance');
In order to compute the eigenvalues without the balance option.
What is the equivalent command in NumPy? When I run the NumPy version ...
6
votes
1
answer
3k
views
Suppress negligible complex numpy eigenvalues?
I am calculating the eigenvalues of a covariance matrix, which is real and symmetric positive semi-definite. Therefore, the eigenvalues and eigenvectors should all be real, however numpy.linalg.eig() ...
6
votes
1
answer
3k
views
How to find a better algorithm to compute eigenvalue and eigenvector of a very large matrix
I have used Jacobi method to find all eigenvalues and eigenvectors in c code. Though the complexity of Jacobi method is O(n^3) but the dimension of my matrix is huge (17814 X 17814). It takes a lot of ...
6
votes
1
answer
2k
views
Numpy eig/eigh gives negative values for a symmetric positive-semi definite matrix
The following code for the CIFAR dataset after GCN:
xtx = np.dot(dataset.train_data[i].transpose(), dataset.train_data[i])
e, q = np.linalg.eigh(xtx)
print(np.max(e), np.min(e))
Produces the ...
5
votes
4
answers
13k
views
Could we get different solutions for eigenVectors from a matrix?
My purpose is to find a eigenvectors of a matrix. In Matlab, there is a [V,D] = eig(M) to get the eigenvectors of matrix by using: [V,D] = eig(M). Alternatively I used the website WolframAlpha to ...
5
votes
1
answer
6k
views
Matlab VS Python - eig(A,B) VS sc.linalg.eig(A,B)
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 ...
5
votes
1
answer
11k
views
Eigendecomposition makes me wonder in numpy
I test the theorem that A = Q * Lambda * Q_inverse where Q the Matrix with the Eigenvectors and Lambda the Diagonal matrix having the Eigenvalues in the Diagonal.
My code is the following:
import ...
5
votes
3
answers
28k
views
Eigenvalues in octave with eig()
Consider the real, symmetric matrix
S = (2, 1; 1, 2)
From the characteristic equation |S - λ I|, we have the quadratic (2-λ)^2 - 1 = 0, whose solutions yield the eigenvalues 3 and 1. ...
5
votes
1
answer
7k
views
how to find Eigenvalues for non quadratic matrix
I want to make similar graphs to this given on the picture:
I am using Fisher Iris data and employ PCA to reduce dimensionality.
this is code:
load fisheriris
[pc,score,latent,tsquare,explained,mu] ...
5
votes
2
answers
5k
views
Sparse eigenvalues using eigen3/sparse
Is there an distinct and effective way of finding eigenvalues and eigenvectors of a real, symmetrical, very large, let's say 10000x10000, sparse matrix in Eigen3? There is an eigenvalue solver for ...