eigenvalue

The roots of the characteristic polynomial and the eigenvalues are not the same

时光毁灭记忆、已成空白 提交于 2019-12-24 07:53:48
问题 This is matrix B B = [1 2 0 ; 2 4 6 ; 0 6 5] The result of eig(B) is: {-2.2240, 1.5109, 10.7131} and the characteristic polynomial of B by this link is syms x polyB = charpoly(B,x) x^3 - 10*x^2 - 11*x + 36 but the answer of solve(polyB) is 133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) + ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3) + 10/3 (3^(1/2)*(133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3))*i)/2 - 133/(18*(3^(1/2)*5492^(1/2)*(i/3) + 1009

How to find principal eigen direction?

此生再无相见时 提交于 2019-12-24 07:38:52
问题 I am trying to generate points within ellipsoid and then trying to fit with smooth ellipsoid surfaces. The goal is to fit with unknown data where i have to find value of a,b and c in 3 principal axes. Rinv should be equivalent to pc. But what i am getting pc in different order. So i have to find correct order to rotate my data to matlab coordinate. a=3; b=5; c=1; index=1; for i=1:500000 x=10*rand-5; y=10*rand-5; z=10*rand-5; if ((x^2/a^2) + (y^2/b^2) + (z^2/c^2) -1) <0 C(index,:)=[x,y,z];

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

How do I get specified Eigenvectors from the generalized Schur factorization of a matrix pair using LAPACK?

假装没事ソ 提交于 2019-12-23 18:12:06
问题 I am grad student trying to rewrite my MATLAB prototype code into C++ code using Eigen and LAPACK. Generalised eigenvalue solver (A*x=lamba*B*x) takes some part in this program. Because Eigen's generalised eigen solver could result in wrong eigenvalue (in my experience), I decided to go with LAPACK (using Accelerate framework in OS X) The code below is the C++ translation of tgevc example http://www.nag.com/numeric/fl/manual/pdf/F08/f08ykf.pdf that I wrote. Everything looks fine unless I

Computation of symbolic eigenvalues with sympy

被刻印的时光 ゝ 提交于 2019-12-23 09:37:43
问题 I'm trying to compute eigenvalues of a symbolic complex matrix M of size 3x3 . In some cases, eigenvals() works perfectly. For example, the following code: import sympy as sp kx = sp.symbols('kx') x = 0. M = sp.Matrix([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]) M[0, 0] = 1. M[0, 1] = 2./3. M[0, 2] = 2./3. M[1, 0] = sp.exp(1j*kx) * 1./6. + x M[1, 1] = sp.exp(1j*kx) * 2./3. M[1, 2] = sp.exp(1j*kx) * -1./3. M[2, 0] = sp.exp(-1j*kx) * 1./6. M[2, 1] = sp.exp(-1j*kx) * -1./3. M[2, 2] = sp.exp(-1j

Python Numpy TypeError: ufunc 'isfinite' not supported for the input types

﹥>﹥吖頭↗ 提交于 2019-12-22 05:33:20
问题 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.eig(np.mat(covMat)) I get the error in the title on the last line above. I suspect has something to do with the datatype, so, here's an image of the variable and datatype from the Variable Explorer in Spyder: I've tried changing np.linalg.eig(np.mat(covMat)) to np.linalg.eig(np.array(np.mat(covMat))) and to np

scipy eigh gives negative eigenvalues for positive semidefinite matrix

假如想象 提交于 2019-12-22 05:12:02
问题 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 the sum of a rank one matrix and a diagonal matrix, both with nonnegative entries). import numpy as np from scipy import linalg as LA def hess_R(x): d = len(x) H = np.ones(d*d).reshape(d,d) / (1 - np.sum(x))**2 H = H + np.diag(1 / (x**2)) return H.astype(np.float64) x = np.array([ 9.98510710e-02

Plot a Correlation Circle in Python

百般思念 提交于 2019-12-20 01:43:33
问题 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 measure to which extend the Eigenvalue / Eigenvector of a variable is correlated to the principal components (dimensions) of a dataset. Anyone knows if there is a python package that plots such data visualization? 回答1: I agree it's a pity not to have it in some mainstream package such as sklearn. Here

how to calculate 2^n modulo 1000000007 , n = 10^9

早过忘川 提交于 2019-12-17 20:22:53
问题 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 was a question which reduced to a recursive equation f(n) = (2*f(n-1)) + 2 , and f(1) = 1, n could be upto 10^9.... i already tried using DP, storing upto 1000000 values and using the common fast exponentiation method, it all timed out im generally weak in these modulo questions, which require

Are eigenvectors returned by R function eigen() wrong?

别说谁变了你拦得住时间么 提交于 2019-12-17 17:12:17
问题 #eigen values and vectors a <- matrix(c(2, -1, -1, 2), 2) eigen(a) I am trying to find eigenvalues and eigenvectors in R. Function eigen works for eigenvalues but there are errors in eigenvectors values. Is there any way to fix that? 回答1: Some paper work tells you the eigenvector for eigenvalue 3 is (-s, s) for any non-zero real value s ; the eigenvector for eigenvalue 1 is (t, t) for any non-zero real value t . Scaling eigenvectors to unit-length gives s = ± sqrt(0.5) = ±0.7071068 t = ± sqrt