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
13
votes
4 answers

Solving matrices of the form Ax = B ==> error: Matrix is close to singular or badly scaled

I'm having trouble solving a system of the form Ax=B The solution to the system should be x = inv(A)*B However, this doesn't work. I get the following error message when I try the above line of code: Warning: Matrix is close to singular or badly…
Tushar Garg
  • 769
  • 3
  • 8
  • 16
13
votes
2 answers

Scipy-like functionality in Java / Scala?

I'm trying to port some Python code to Scala. It makes heavy use of Numpy and Scipy. While I've found a number of dense matrix / linear algebra libraries that will do as an adequate (but not superb) replacement for NumPy, I've not really found…
nomad
  • 1,809
  • 2
  • 18
  • 33
13
votes
3 answers

Architecture for providing different linear algebra back-ends

I am prototyping a new system in Python; the functionality is mostly numerical. An important requirement is the ability to use different linear algebra back-ends: from individual user implementations to generic libraries, such as Numpy. The linear…
Escualo
  • 40,844
  • 23
  • 87
  • 135
13
votes
2 answers

Is there a built-in/easy LDU decomposition method in Numpy?

I see cholesky decomposition in numpy.linalg.cholesky, but could not find a LDU decompositon. Can anyone suggest a function to use?
user1559897
  • 1,454
  • 2
  • 14
  • 27
13
votes
6 answers

Is there around a straightforward way to invert a triangular (upper or lower) matrix?

I'm trying to implement some basic linear algebra operations and one of these operations is the inversion of a triangular (upper and/or lower) matrix. Is there an easy and stable algorithm to do that? Thank you.
tunnuz
  • 23,338
  • 31
  • 90
  • 128
13
votes
1 answer

How to solve a least squares (underdetermined system) quickly?

I have a program in R that is computing a large amount of least squares solutions (>10,000: typically 100,000+) and, after profiling, these are the current bottlenecks for the program. I have a matrix A with column vectors that correspond to…
Mark
  • 131
  • 4
13
votes
3 answers

Fastest algorithm for computing the determinant of a matrix?

For a research paper, I have been assigned to research the fastest algorithm for computing the determinant of a matrix. I already know about LU decomposition and Bareiss algorithm which both run in O(n^3), but after doing some digging, it seems…
13
votes
3 answers

Is there an algorithm to multiply square matrices in-place?

The naive algorithm for multiplying 4x4 matrices looks like this: void matrix_mul(double out[4][4], double lhs[4][4], double rhs[4][4]) { for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { out[i][j] = 0.0; …
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
13
votes
3 answers

3D Correspondences from fundamental matrix

In MATLAB I have calculated the Fundamental matrix (of two images) using the normalized Eight point algorithm. From that I need to triangulate the corresponding image points in 3D space. From what I understand, to do this I would need the rotation…
worbel
  • 6,509
  • 13
  • 53
  • 63
13
votes
2 answers

Numpy Cholesky decomposition LinAlgError

In my attempt to perform cholesky decomposition on a variance-covariance matrix for a 2D array of periodic boundary condition, under certain parameter combinations, I always get LinAlgError: Matrix is not positive definite - Cholesky decomposition…
neither-nor
  • 1,245
  • 2
  • 17
  • 30
13
votes
2 answers

Compute Jordan normal form of matrix in Python / NumPy

In MATLAB you can compute the Jordan normal form of a matrix by using the the function jordan. It there an equivalent function available in NumPy and SciPy?
sighol
  • 2,678
  • 6
  • 28
  • 34
13
votes
6 answers

Invert 4x4 matrix - Numerical most stable solution needed

I want to invert a 4x4 matrix. My numbers are stored in fixed-point format (1.15.16 to be exact). With floating-point arithmetic I usually just build the adjoint matrix and divide by the determinant (e.g. brute force the solution). That worked for…
13
votes
1 answer

Sorting a List of 3d coplanar points to be clockwise or counterclockwise

I have a list of 3D points. I know they are all coplanar. I have the center that I want to sort them around and the normal to the plane on which the points and the center lie. How can I test if one point is right (or left) of another point? I…
AAB
  • 674
  • 3
  • 14
  • 27
12
votes
3 answers

square to trapezoid

I know that transforming a square into a trapezoid is a linear transformation, and can be done using the projective matrix, but I'm having a little trouble figuring out how to construct the matrix. Using the projective matrix to translate, scale,…
Andrew Prock
  • 6,900
  • 6
  • 40
  • 60
12
votes
1 answer

NumPy: why does np.linalg.eig and np.linalg.svd give different V values of SVD?

I am learning SVD by following this MIT course. the Matrix is constructed as C = np.matrix([[5,5],[-1,7]]) C matrix([[ 5, 5], [-1, 7]]) the lecturer gives the V as this is close to w, v = np.linalg.eig(C.T*C) matrix([[-0.9486833 ,…
user11528241