Questions tagged [eigenvector]
The eigenvectors of a square matrix are the non-zero vectors that, after being multiplied by the matrix, remain parallel to the original vector.
640
questions
1
vote
1
answer
49
views
Different results between Wolfram and Numpy when I multiply 3 matrices?
Firstly, I am sure that the Wolfram answer is the correct one because the two sandwich matrices is the eigen vecors matrices so the answer has to to be in the form of eigne bases.
so, the question is, ...
0
votes
1
answer
23
views
How do I get Sympy dsolve to produce all the eigenvectors for a ODE?
I am using dsolve on a basic ODE and I am getting f(x) = 0 as the only result. This is a valid result but there are infinitely many Eigenvector solutions to this equation. How do I encourage SYMPY to ...
0
votes
0
answers
38
views
Precision in SVD calculation through eigenvalues/eigenvectors
In octave I used eigendecomposition to calculate svd instead of svd fuction istelfand compare the results.
Errors are following using exiting SVD function
[U2,S2,V2] = svd(A2);
errU2U2t = max(max((U2*...
1
vote
1
answer
27
views
How are built eigenvectors with lapack in C
I am working on eigenvectors with lapacke in C code and I was wondering how are they built when the the eigenvalue has a imaginary part? I mean I have to malloc on the same dimension as if they were ...
0
votes
1
answer
84
views
how to calculate norm of eigenvector and are the eigenvector pairwise orthogonal? how to calculate by hand
eigenvalue
[1] 2.5897826 1.5156007 1.8060659 0.9620865
eigenvector
[1][2]
[1] 0.2364211 0.178445138
[2] -0.1055865 -0.3364896
There should be 7 eigen values and eigenvector but I remove it to ...
-1
votes
1
answer
49
views
Finding Matrix When Eigen Values & Eigen Vectors were known
I have been trying to find my matrix from eigenvalues and eigenvectors.
I calculated eigen values and eigen vectors from a matrix first.
Then, I want to verify the values of eigenvalues and ...
0
votes
0
answers
32
views
Why does `eigs_gen` from armadillo give different phases on lowest eigenvalue, when run multiple times
I am using the function eigs_gen from the C++ library Armadillo to find the ground state of a quantum physical Hamiltonian stored as a complex sparse matrix sp_cx_mat H;. It works, but the results ...
2
votes
1
answer
78
views
Eigenvector in Julia -- result less precise than Mathematica
I'm having a great time learning Julia.
With Wolfram Mathematica, I can get exact Eigenvectors for simple matrices. E.g.:
The same example in Julia returns the following:
Is there a way to get Julia'...
0
votes
0
answers
49
views
Compute eigenvector matrices
I have one problem in computing eigenvector matrices.I compute one in python and one online but they have different solution.
Here i use online named matrixcalc, and it's solution:
and here I use ...
0
votes
1
answer
61
views
Numpy eigensystem solver returns improper matrix
I've been trying to use the output of numpy.linalg.eigh as a
rotation matrix, but the matrix formed from the eigenvectors it
returns is improper; that is, it's not a pure rotation, but a
combination ...
0
votes
0
answers
76
views
Simultaneous diagonalization of a set of commuting hermitian 8*8 matrices
I have four commuting hermitian 8*8 matrices A, B, C, D. The eigenvalues are +1 and -1, each with multiplicity 4. I want to diagonalize these matrices simultaneously. Due to the 4-fold degeneracy of ...
0
votes
1
answer
40
views
Extracting eigenvectors from eigendecomposition
I'm following the sequence of steps:
Given A is m by n then we perform SVD on A = USVT
Then, find U’ = (1/2)(U+UT) to obtain a symmetric matrix
Then, perform eigenvalue decomposition on U’, m by m.
...
-1
votes
1
answer
39
views
Using CPU memory to store GPU output
I was wondering whether it could be possible to tell cupy to store the output of some calculation (carried on the GPU) directly on the CPU memory. I am currently trying to use cupy.scipy.sparse.eigsh ...
0
votes
1
answer
37
views
How to project chosen Eigen Faces onto test data using skikit-learn?
Background:
I want to do face recognition in Python. Earlier, in Matlab, I've implemented face recognition using roughly this code:
[EigVec, projec, eigenVal] = myPCA(TrainingDataFaces);
prinComps = [...
1
vote
0
answers
65
views
Different matrix multiplication result in MATLAB and Python leads different eigenvectors
I am trying to convert my MATLAB code to Python. I have to multiply two matrices and calculate the eigenvector and eigenvalues of the multiplication result. Here are the two matrices
P = [0....
2
votes
0
answers
34
views
Compute generalized eigenvalue problem with CLapack in C
I'm going to show you an example how to compute generalized eigenvalue problem in C with CLapack.
Here I have two matrices.
#define row 5
#define column 5
float A[row * column] = { 9.5605, 6.8163, -...
0
votes
0
answers
32
views
how to set numbering for obtained eigenvectors?
I used the code below to get the eigenvectors of the matrices in the shown text files.
import numpy as np
from numpy import *
from matplotlib.pyplot import *
import re
import scipy.linalg as la
data=...
1
vote
0
answers
46
views
Calculating full set of eigenvectors with arbitrary error tolerance
I'm trying to numerically compute the full set of eigenvectors of a large dense matrix, with the freedom to specify the error tolerance and maximum number of iterations. (The default error tolerance ...
0
votes
1
answer
51
views
Reconstructing a matrix with complex elements after diagonalization
I have a random matrix Htest with complex elements, which I diagonalize using scipy.linalg.eig. Having the decomposed matrices, I tried to reconstruct the original matrix. Here is my script
import ...
0
votes
2
answers
59
views
Numpy outputting incorrect eigenvectors
I need to output eigenvalues and eigenvectors of a matrix. This seems like a trivial task using a function like numpy.linalg.eig. It turned out that it outputs correct eigenvalues but there is ...
0
votes
1
answer
15
views
PCA Eigenface is wrong and staticy and I dont know what Im doing wrong
I am trying to generate eigenfaces using principle component analysis and have gone through the following steps to do so. Am I missing something or doing something wrong?
data matrix: (N, width * ...
0
votes
0
answers
76
views
How to calculate left eigenvectors in C++?
I regularly use C++ and the Eigen Tux module to calculate the eigenvalues and right eigenvectors of a matrix. I would now like to look to calculate the left eigenvectors as defined in this screenshot:
...
0
votes
1
answer
33
views
Why does eig give an inverted PC1 value compared to eigh, but PC2 is the same?
I am comparing eig and eigh and I would like clarification of why the results are partly inverted!
f1 and f2 are my 2 features.
pc1 and pc2 are the principal components using eig.
pc1h and pc2h are ...
0
votes
0
answers
17
views
Applying eigenvectors to another dataframe
I want to apply the eigenvectors which I have acquired from one data to another, my question is, before projecting the eigenvectors to get the principal components of second data frame, should I ...
1
vote
1
answer
39
views
Why does my Numpy code return incorrect eigenvector values?
The problem I am having is the same as this question.
However, I believe the answer to the above question does not apply to my case.
matrix = np.array([[10,3,1],[3,2,1],[1,1,1]])
eigenvalues, ...
1
vote
0
answers
65
views
How can I optimize my code to run for size greater than number of threads
I am new to CUDA programming. I am performing a simple power iteration method to get the dominant eigen vector, but whenever I increase my matrix size to a value greater than the number of threads per ...
0
votes
0
answers
53
views
Numpy seems to be producing different results when a matrix is raised to nth power using different methods
For a 2x2 matrix A, let T be the matrix containing it's eigenvectors.
Let D be a diagonal matrix containing the eigenvalues of A on it's diagonal.
Therefore, AT = TD
Assuming T is invertible, A = TDT-...
0
votes
0
answers
27
views
cosine similarity and norm for find similar vectors
When we check similarity of two vectors, cosine similarity gives something different with l2 norms of those two vectors?
How can we resolved the difference?
1
vote
0
answers
59
views
Difference PCA by sklearn (SVD) and scratch PCA (Eigenvector Decomposition)
While implementing PCA from scratch, I discovered that PCA by sklearn uses Singular Value Decomposition (SVD) while all tutorials implement PCA using Eigenvalue Decomposition. They lead to different ...
0
votes
0
answers
73
views
"R: Calculating robust normals for a LiDAR point cloud and tracking valid indices"
I am working with LiDAR point cloud data in R and trying to calculate the robust normals for the points using a local plane-based approach. My goal is to compute the normals for each point in the ...
0
votes
0
answers
39
views
Implementing the winding number of a 1D Hamiltonian
The winding number of a 1D Hamiltonian is given by
\begin{equation}
w = \frac{i}{\pi} \int_{-\pi}^{\pi} \langle \psi_{k} | \partial_{k} |\psi_{k} \rangle dk
\end{equation}
where $\psi_{k}$ is the ...
0
votes
0
answers
167
views
Can I diagonalize a 80000*80000 matrix using lapack in fortran 95? How much ram it will need?
I am trying to diagonalise a sparse matrix(N*N) where N is 80000. I want to have the eigen values and eigen vectors of this matrix. I will be using a fortran which includes Lapack_dsyev for this. How ...
1
vote
1
answer
120
views
Power method in Matlab giving inconsistent results
I'm trying to make a simple implementation of the power method for determining dominant eigenvectors of a matrix in Matlab. If you repeatedly multiply any vector by a matrix, normalize that, multiply ...
1
vote
0
answers
195
views
Why the scaling matrix in LDA is not Normalized
I was carrying out LDA (linear Discriminant Analysis) and noticed that the Scaling matrix produced by R is not normalized. Here is an example:
(res <- MASS::lda(Species~., iris))
Call:
lda(Species ~...
0
votes
0
answers
77
views
Arbitrary signs from numpy.linalg.eig eigenvectors causing incorrect output for custom SVD implementation
For a class (read: can't just use np.linalg.svd) I'm trying to write a function that generates the singular value decomposition (SVD) of an arbitrarily-shaped matrix; it should factor some input ...
0
votes
2
answers
83
views
matlab eig for imaginary matrices in python
Say I have the following matrix Pi in Matlab where I need to perform the following code
Pi = [0.2 0.2 0.15; 0.1 0.15 0.48; 0.9 0.96 0.9]
Pia = .5*(Pi-Pi')*1i;
[W,D] = eig(Pia,'vector');
eigenvalues D ...
1
vote
1
answer
365
views
Difference between NetworkX and iGraph calculation of eigenvector centrality
I am trying to calculate the eigenvector centrality for nodes in a graph
Both packages iGraph and NetworkX have methods to calculate eigenvector centrality, but they are returning different values for ...
1
vote
0
answers
209
views
Eigen Library + Intel MKL + Visual Studio 2022 not working
I am trying to enable Intel MKL (2023.0.0) on Eigen C++ (3.4.0) library using Visual Studio++, so far I am able to run Eigen library in Visual Studio 2022 with no issues.
But as stated on this other ...
1
vote
1
answer
74
views
How can I get more significant figures for the eigenvalues and eigenvectors problem?
I'm trying to calculate the eigenvalues and eigenvector of a matrix in Python. I used numpy and, as an example, did this with a matrix M:
w,v=eig(M)
idx = w.argsort()[::1]
eigVal= w[idx]
eigVec = v[...
0
votes
0
answers
56
views
How different are Scipy's linalg.eig and Matlab's eigs?
I am trying to translate a code from Matlab into Python and I notice a difference in the components of the eigenvectors computed with scipy.linalg.eig() from Matlab's eigs(). The difference is around ...
1
vote
1
answer
213
views
Optimising Monte-Carlo algorithm | Reduce operation on GPU & Eigenvalues problem | Many-body problem
This issue reminds some typical many-body problem, but with some extra calculations.
I am working on the generalized Metropolis Monte-Carlo algorithm for the modeling of large number of arbitrary ...
4
votes
0
answers
263
views
Why is Scipy.linalg.eigh much slower when using np.complex64?
I have a large Hermitian matrix of which I need to calculate the eigenvalues and eigenvectors. For this I use scipy.linalg.eigh. Above a certain size of the matrix, scipy is much faster if np....
0
votes
1
answer
80
views
Function for language C that replicates the results of eig in MATLAB
I want to find the function of calculating eigenvalue and eigenvectors in language C which has same results as MATLAB's eig function.
I'm currently using GNU Scientific Library eigenvalue solver. ...
0
votes
0
answers
54
views
Octave row reduces incorrectly a given matrix
I was trying to calulate the eigenvectors and eigenvalues of a matrix "by hand"(without using the function eig())
First I calculate the eigenvalaues with the function poly() and roots().
...
2
votes
1
answer
284
views
Function to Convert Square Matrix to Upper Hessenberg with Similarity Transformations
I am attempting to translate a MATLAB function to Python from Timothy Sauer,
Numerical Analysis Second Edition, page 546, Program 12.8. The original function
receives a square matrix and returns a ...
0
votes
1
answer
99
views
Solving generalized eigenvalue system with a semidefinite positive B in python
I am trying to use Normalized Cut algorithm (Shi and Malik, 2000) to cut a matrix into two matrices. In this regard, I need to find the second smallest eigenvector in a generalized eigenvalue system (...
0
votes
1
answer
59
views
tensorflow.linalg.eig throwing error UnboundLocalError: local variable 'out_dtype' referenced before assignment
I have below code
import tensorflow as tf
X_tf = tf.Variable([[25, 2, 9], [5, 26, -5], [3, 7, -1]])
lambdas_X_tf, V_X_tf = tf.linalg.eig(X_tf)
when I execute it I get below error
File "C:\Users\...
-1
votes
1
answer
189
views
numpy's "linalg.eig()" and "linalg.eigh()" for the same hermitian matrix
This question was due to a misunderstanding. See the answer below.
numpy.linalg methods eig() and eigh() appear to return different eigenvectors for the same hermitian matrix. Here the code:
import ...
1
vote
0
answers
51
views
TruncatedSVD n_oversamples seems to have no bearing
I'm looking for way to improve the quality of my eigenvectors produced by sklearn TruncatedSVD. The documentation at scikit-learn.org suggests that the n_oversamples parameter is a good place to start....
0
votes
1
answer
101
views
Python: Normalizing eigenfunctions over the range of the for loop
I am trying to plot the probability density of a wavefunction, however with my current code:
import numpy as np
from numpy import linalg as LA
for x in range(0,steps+1):
...
w,v=LA.eig(H)
...