eigenvalue

Matlab Codgen eig() function - strange behaviour

烂漫一生 提交于 2019-12-06 11:44:32
First, don't be fooled by the long post, there is not a lot of code just an observation of results so there are few example matrices. This is a bit related to this question: Matlab Codegen Eig Function - Is this a Bug? I know that mex/C/C++ translated eig() function may not return the same eigenvectors when using the same function in MATLAB and that's fine, but i am puzzled with results I'm getting. First this simple example: Output % c = diagonal matrix of eigenvalues % b = matrix whose columns are the corresponding right eigenvectors function [ b, c ] = eig_test(a) [b, c] = eig(a); end

Incorrect eigenvalues SciPy sparse linalg.eigs, eigsh for non-diagonal M matrix

北战南征 提交于 2019-12-06 07:18:06
问题 Why do eigh and eigsh from scipy.sparse.linalg as used below give incorrect results when solving the generalized eigenvalue problem A * x = lambda * M * x , if M is non-diagonal? import mkl import numpy as np from scipy import linalg as LA from scipy.sparse import linalg as LAsp from scipy.sparse import csr_matrix A = np.diag(np.arange(1.0,7.0)) M = np.array([[ 25.1, 0. , 0. , 17.3, 0. , 0. ], [ 0. , 33.6, 16.8, 8.4, 4.2, 2.1], [ 0. , 16.8, 3.6, 0. , 11. , 0. ], [ 17.3, 8.4, 0. , 4.2, 0. , 9

Eigenvector (Spectral) Decomposition

三世轮回 提交于 2019-12-06 07:14:35
I am trying to find a program in C code that will allow me to compute a eigenvalue (spectral) decomposition for a square matrix. I am specifically trying to find code where the highest eigenvalue (and therefore its associated eigenvalue) are located int the first column. The reason I need the output to be in this order is because I am trying to compute eigenvector centrality and therefore I only really need to calculate the eigenvector associated with the highest eigenvalue. Thanks in advance! In any case I would recommend to use a dedicated linear algebra package like Lapack (Fortran but can

Sorting eigenvectors by their eigenvalues (associated sorting)

主宰稳场 提交于 2019-12-06 06:16:05
问题 I have an unsorted vector of eigenvalues and a related matrix of eigenvectors. I'd like to sort the columns of the matrix with respect to the sorted set of eigenvalues. (e.g., if eigenvalue[3] moves to eigenvalue[2], I want column 3 of the eigenvector matrix to move over to column 2.) I know I can sort the eigenvalues in O(N log N) via std::sort . Without rolling my own sorting algorithm, how do I make sure the matrix's columns (the associated eigenvectors) follow along with their eigenvalues

low RAM consuming c++ eigen solver

馋奶兔 提交于 2019-12-06 05:44:17
问题 I'm newbie in C++ programming , but I have a task to compute eigenvalues and eigenvectors (standard eigenproblem Ax=lx ) for symmetric matrices (and hermitian)) for very large matrix of size: binomial(L,L/2) where L is about 18-22. Now I'm testing it on machine which has about 7.7 GB ram available, but at final I'll have access to PC with 64GB RAM. I've started with Lapack++ . At the beginning my project assume to solve this problem only for symmetrical real matrices. This library was great.

The fastest way to calculate eigenvalues of large matrices

折月煮酒 提交于 2019-12-06 01:17:24
Until now I used numpy.linalg.eigvals to calculate the eigenvalues of quadratic matrices with at least 1000 rows/columns and, for most cases, about a fifth of its entries non-zero (I don't know if that should be considered a sparse matrix). I found another topic indicating that scipy can possibly do a better job. However, since I have to calculate the eigenvalues for hundreds of thousands of large matrices of increasing size (possibly up to 20000 rows/columns and yes, I need ALL of their eigenvalues), this will always take awfully long. If I can speed things up, even just the tiniest bit, it

Preventing scipy eigenvectors differing from computer to computer

眉间皱痕 提交于 2019-12-05 22:09:54
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 produces one of three different wrong collections of attractors at random. On the smaller matrix M1 below,

Sparse eigenvalues using eigen3/sparse

女生的网名这么多〃 提交于 2019-12-05 08:45:34
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 dense matrices but that doesn't make use of the property of the matrix e.g. it's symmetry. Furthermore I don't want to store the matrix in dense. Or (alternative) is there a better (+better documented) library to do that? Armadillo will do this using eigs_sym Note that computing all the eigenvalues is a very expensive operation whatever you do, usually what is done is to find only the k largest, or

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

亡梦爱人 提交于 2019-12-05 08:22:58
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.linalg.eig(np.array(covMat)) , nothing works. Any ideas? (an example would be great!) Your array has a

How do I find out eigenvectors corresponding to a particular eigenvalue of a matrix?

筅森魡賤 提交于 2019-12-04 23:49:45
问题 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 eigenvalue 1. The scipy function scipy.linalg.eig returns the array of eigenvalues and eigenvectors. D, V = scipy.linalg.eig(P) Here D(array of values) and V(array of vectors) are both vectors. One way is to do a search in D and extract the corresponding eigenvector in V. Is there an easier way? 回答1: