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
281
votes
11 answers

What are the most widely used C++ vector/matrix math/linear algebra libraries, and their cost and benefit tradeoffs?

It seems that many projects slowly come upon a need to do matrix math, and fall into the trap of first building some vector classes and slowly adding in functionality until they get caught building a half-assed custom linear algebra library, and…
Catskul
  • 17,916
  • 15
  • 84
  • 113
232
votes
12 answers

"Cloning" row or column vectors

Sometimes it is useful to "clone" a row or column vector to a matrix. By cloning I mean converting a row vector such as [1, 2, 3] Into a matrix [[1, 2, 3], [1, 2, 3], [1, 2, 3]] or a column vector such as [[1], [2], [3]] into [[1, 1, 1] [2,…
Boris Gorelik
  • 29,945
  • 39
  • 128
  • 170
116
votes
10 answers

Math - mapping numbers

How do I map numbers, linearly, between a and b to go between c and d. That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case. My brain is fried.
Sam
  • 6,167
  • 6
  • 26
  • 24
91
votes
2 answers

cocktail party algorithm SVD implementation ... in one line of code?

In a slide within the introductory lecture on machine learning by Stanford's Andrew Ng at Coursera, he gives the following one line Octave solution to the cocktail party problem given the audio sources are recorded by two spatially separated…
gregS
  • 2,580
  • 5
  • 28
  • 33
77
votes
2 answers

Rotating a Vector in 3D Space

I am making an android project in opengl es that uses accelerometer to calculate change in specific axes and my aim is to rotate my spacecraft-like object's movement vector. The problem is that i can't understand the math behind rotation matrices.…
deniz
  • 2,427
  • 4
  • 27
  • 38
62
votes
7 answers

Python Inverse of a Matrix

How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it.
Claudiu
  • 224,032
  • 165
  • 485
  • 680
61
votes
4 answers

Understanding tensordot

After I learned how to use einsum, I am now trying to understand how np.tensordot works. However, I am a little bit lost especially regarding the various possibilities for the parameter axes. To understand it, as I have never practiced tensor…
floflo29
  • 2,261
  • 2
  • 22
  • 45
53
votes
7 answers

C# linear algebra library

Is there stable linear algebra (more specifically, vectors, matrices, multidimensional arrays and basic operations on them) library for C#? Search yielded a few open source libraries which are either not updated for couple of years or are in an…
ima
  • 8,105
  • 3
  • 20
  • 19
49
votes
7 answers

Linear index upper triangular matrix

If I have the upper triangular portion of a matrix, offset above the diagonal, stored as a linear array, how can the (i,j) indices of a matrix element be extracted from the linear index of the array? For example, the linear array [a0, a1, a2, a3,…
Robert T. McGibbon
  • 5,075
  • 3
  • 37
  • 45
48
votes
11 answers

Solving a linear equation

I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++. Here's an example of the equations: -44.3940 = a * 50.0 + b * 37.0 + tx -45.3049 = a * 43.0 + b * 39.0 + tx -44.9594 = a * 52.0 + b * 41.0 +…
Adam Ernst
  • 52,440
  • 18
  • 59
  • 71
47
votes
2 answers

Can I get the matrix determinant using Numpy?

I read in the manual of Numpy that there is function det(M) that can calculate the determinant. However, I can't find the det() method in Numpy. By the way, I use Python 2.5. There should be no compatibility problems with Numpy.
george
47
votes
6 answers

Transforming a row vector into a column vector in Numpy

Let's say I have a row vector of the shape (1, 256). I want to transform it into a column vector of the shape (256, 1) instead. How would you do it in Numpy?
44
votes
2 answers

whats the fastest way to find eigenvalues/vectors in python?

Currently im using numpy which does the job. But, as i'm dealing with matrices with several thousands of rows/columns and later this figure will go up to tens of thousands, i was wondering if there was a package in existence that can perform this…
yurib
  • 8,043
  • 3
  • 30
  • 55
40
votes
3 answers

Algorithm for intersection of 2 lines?

I have 2 lines. Both lines containing their 2 points of X and Y. This means they both have length. I see 2 formulas, one using determinants and one using normal algebra. Which would be the most efficient to calculate and what does the formula looks…
Shawn Mclean
  • 56,733
  • 95
  • 279
  • 406
39
votes
3 answers

Numpy Adding two vectors with different sizes

If I have two numpy arrays of different sizes, how can I superimpose them. a = numpy([0, 10, 20, 30]) b = numpy([20, 30, 40, 50, 60, 70]) What is the cleanest way to add these two vectors to produce a new vector (20, 40, 60, 80, 60, 70)? This is my…
tnt
  • 3,411
  • 5
  • 24
  • 23
1
2 3
99 100