Questions tagged [linear-algebra]

Linear Algebra is a core body of mathematics studying vector spaces and linear mappings between these spaces. Key topics include: matrices, vectors, simultaneous systems of linear equations, diagonal form, eigenvalues, eigenvectors, projections, points, lines, planes, hyperplanes, rotations and reflections.

Linear Algebra is a core body of mathematics studying vector spaces and linear mappings between these spaces. It has extensive applications in computer graphics, economics, engineering, and control systems, among other fields.

Key topics include: matrices, vectors, simultaneous systems of linear equations, diagonal form, eigenvalues, eigenvectors, projections, points, lines, planes, hyperplanes, rotations, reflections, shears, scaling.

Popular packages for solving linear algebra problems include , , , and .

4466 questions
15
votes
2 answers

Python - NumPy - tuples as elements of an array

I'm a CS major in university working on a programming project for my Calc III course involving singular-value decomposition. The idea is basically to convert an image of m x n dimensions into an m x n matrix wherein each element is a tuple…
Thomas
  • 151
  • 1
  • 1
  • 3
15
votes
1 answer

Tensor multiplication with numpy tensordot

I have a tensor U composed of n matrices of dimension (d,k) and a matrix V of dimension (k,n). I would like to multiply them so that the result returns a matrix of dimension (d,n) in which column j is the result of the matrix multiplication between…
Matteo
  • 7,924
  • 24
  • 84
  • 129
15
votes
1 answer

scipy.stats.multivariate_normal raising `LinAlgError: singular matrix` even though my covariance matrix is invertible

I am having trouble trying to use scipy.stats.multivariate_normal, hopefully one of you might be able to help. I have a 2x2 matrix which is possible to find the inverse of using numpy.linalg.inv(), however when I attempt to use it as the covariance…
Jonnyishman
  • 365
  • 3
  • 4
  • 12
15
votes
7 answers

Left inverse in numpy or scipy?

I am trying to obtain the left inverse of a non-square matrix in python using either numpy or scipy. How can I translate the following Matlab code to Python? >> A = [0,1; 0,1; 1,0] A = 0 1 0 1 1 0 >> y = [2;2;1] y = …
D R
  • 21,936
  • 38
  • 112
  • 149
15
votes
3 answers

SVD computing different result in Matlab and OpenCV

I wonder why there is sign difference in result for SVD computing in Matlab and OpenCV. I input the same matrix 3.65E+06 -2.09E+06 0 YY = -2.09E+06 2.45E+06 0 0 0 0 [U,S,V] = svd(YY);//Matlab …
Bryanyan
  • 677
  • 3
  • 13
  • 30
14
votes
4 answers

Combining a linear algebra library with Boost::Units

I'm doing a good amount of scientific programming and made very good experiences with both Boost.Units, which provides compile-time dimensional analysis for quantities (i.e. tags quantities with units and thereby catches many errors with classical…
thiton
  • 35,651
  • 4
  • 70
  • 100
14
votes
3 answers

C library for linear algebra

Please, give me some tips for a HIGH PERFORMANCE C library for linear algebra (matrix algebra, eigenvalues, eigenvectors etc.). Can be both open-source or closed-source.
Cartesius00
  • 23,584
  • 43
  • 124
  • 195
14
votes
2 answers

Numpy: Multiplying a matrix with a 3d tensor -- Suggestion

I have a matrix P with shape MxN and a 3d tensor T with shape KxNxR. I want to multiply P with every NxR matrix in T, resulting in a KxMxR 3d tensor. P.dot(T).transpose(1,0,2) gives the desired result. Is there a nicer solution (i.e. getting rid of…
osdf
  • 818
  • 10
  • 20
14
votes
3 answers

julia, linear algebra, is there a function finding all vectors orthogonal to the given one?

For a given vector I would like to find the orthogonal basis around it, i.e. the given vector normalized and randomly chosen basis of orthogonal sub-space. Is there a convenient function for this in Julia?
xealits
  • 4,224
  • 4
  • 27
  • 36
14
votes
2 answers

Scikit-Learn PCA

I am using input data from here (see Section 3.1). I am trying to reproduce their covariance matrix, eigenvalues, and eigenvectors using scikit-learn. However, I am unable to reproduce the results as presented in the data source. I've also seen this…
slaw
  • 6,591
  • 16
  • 56
  • 109
14
votes
4 answers

System of linear equations in C++?

I need to solve a system of linear equations in my program. Is there a simple linear algebra library for C++, preferably comprised of no more than a few headers? I've been looking for nearly an hour, and all the ones I found require messing around…
Archagon
  • 2,470
  • 2
  • 25
  • 38
14
votes
2 answers

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?
kamaci
  • 72,915
  • 69
  • 228
  • 366
14
votes
1 answer

Calculate eigenvalues/eigenvectors of hundreds of small matrices using CUDA

I have a question on the eigen-decomposition of hundreds of small matrices using CUDA. I need to calculate the eigenvalues and eigenvectors of hundreds (e.g. 500) of small (64-by-64) real symmetric matrices concurrently. I tried to implement it by…
Yifei Huang
  • 141
  • 1
  • 3
14
votes
7 answers

ublas vs. matrix template library (MTL4)

I'm writing a software for hyperbolic partial differential equations in c++. Almost all notations are vector and matrix ones. On top of that, I need the linear algebra solver. And yes, the vector's and matrix's sizes can vary considerably (from say…
dodol
  • 1,073
  • 2
  • 16
  • 33