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
16
votes
3 answers

why does a*b*a take longer than (a'*(a*b)')' when using gpuArray in Matlab scripts?

The code below performs the operation the same operation on gpuArrays a and b in two different ways. The first part computes (a'*(a*b)')' , while the second part computes a*b*a. The results are then verified to be the same. %function…
avgn
  • 982
  • 6
  • 19
16
votes
1 answer

Calculate Normals from Heightmap

I am trying to convert an heightmap into a matrix of normals using central differencing which will later correspond to the steepness of a giving point. I found several links with correct results but without explaining the math behind. T L O R …
gdf31
  • 387
  • 1
  • 4
  • 11
16
votes
3 answers

LinAlgError: Last 2 dimensions of the array must be square

I need to solve a set of simultaneous equations of the form Ax = B for x. I've used the numpy.linalg.solve function, inputting A and B, but I get the error LinAlgError: Last 2 dimensions of the array must be square Here's my code: A =…
K Jackson
  • 161
  • 1
  • 1
  • 5
16
votes
5 answers

Determine if A+B=C exists in an array of n integers

This is a problem a friend of mine received as his homework (in algorithm and data structure class). He asked me about this. However, I can't solve it and have been thinking about it for some time during the last several days. There are n random…
Haozhun
  • 6,331
  • 3
  • 29
  • 50
16
votes
3 answers

Calculate a 2D homogeneous perspective transformation matrix from 4 points in MATLAB

I've got coordinates of 4 points in 2D that form a rectangle and their coordinates after a perspective transformation has been applied. The perspective transformation is calculated in homogeneous coordinates and defined by a 3x3 matrix M. If the…
daign
  • 899
  • 1
  • 10
  • 18
16
votes
2 answers

Solve Generalized Eigenvalue Problem in Numpy

I am looking to solve a problem of the type: Aw = xBw where x is a scalar (eigenvalue), w is an eigenvector, and A and B are symmetric, square numpy matrices of equal dimension. I should be able to find d x/w pairs if A and B are d x d. How would…
Andrew Latham
  • 5,982
  • 14
  • 47
  • 87
16
votes
1 answer

Moore-Penrose generalized inverse of a large sparse matrix

I have a square matrix with a few tens of thousands rows and columns with only a few 1 beside tons of 0, so I use the Matrix package to store that in R in an efficient way. The base::matrix object cannot handle that amount of cells, as I run out of…
daroczig
  • 28,004
  • 7
  • 90
  • 124
16
votes
3 answers

Why is Matlab's inv slow and inaccurate?

I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate. I am trying to find the reason of this…
16
votes
4 answers

Is there a way to efficiently invert an array of matrices with numpy?

Normally I would invert an array of 3x3 matrices in a for loop like in the example below. Unfortunately for loops are slow. Is there a faster, more efficient way to do this? import numpy as np A = np.random.rand(3,3,100) Ainv = np.zeros_like(A) for…
katrasnikj
  • 3,151
  • 3
  • 16
  • 27
15
votes
5 answers

Algorithm for solving systems of linear inequalities

I have k linear inequalities in n variables (0 < k < n). I don't particularly care what the solution set is, I only want to test whether or not it's empty - i.e. whether any assignment to my n variables satisfies the system. Anyone know a way to…
GMB
  • 486
  • 6
  • 13
15
votes
2 answers

matrices are not aligned Error: Python SciPy fmin_bfgs

Problem Synopsis: When attempting to use the scipy.optimize.fmin_bfgs minimization (optimization) function, the function throws a derphi0 = np.dot(gfk, pk) ValueError: matrices are not aligned error. According to my error checking this…
SaB
  • 747
  • 1
  • 9
  • 25
15
votes
3 answers

How can I measure trends in certain words, like Twitter?

I have newspaper articles' corpus by day. Each word in the corpus has a frequency count of being present that day. I have been toying with finding an algorithm that captures the break-away words, similar to the way Twitter measures Trends in…
datayoda
  • 1,067
  • 2
  • 12
  • 24
15
votes
3 answers

Sparse Matrix Libraries for Ruby

I'm looking for a Sparse Matrix library I can use from Ruby. I'm currently using the GNU Scientific Library bindings provided by the "gsl" gem, but my application would be better optimized if I used a dedicated sparse matrix library. I've…
15
votes
5 answers

Check for positive definiteness or positive semidefiniteness

I want to check if a matrix is positive definite or positive semidefinite using Python. How can I do that? Is there a dedicated function in SciPy for that or in other modules?
sramij
  • 4,775
  • 5
  • 33
  • 55
15
votes
3 answers

Broadcasted NumPy arithmetic - why is one method so much more performant?

This question is a follow up to my answer in Efficient way to compute the Vandermonde matrix. Here's the setup: x = np.arange(5000) # an integer array N = 4 Now, I'll compute the Vandermonde matrix in two different ways: m1 = (x **…
cs95
  • 379,657
  • 97
  • 704
  • 746