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
31
votes
5 answers

Is Google's Android OpenGL tutorial teaching incorrect linear algebra?

After helping another user with a question regarding the Responding to Touch Events Android tutorial, I downloaded the source code, and was quite baffled by what I saw. The tutorial seems to not be able to decide whether it wants to use row vectors…
Tim
  • 35,413
  • 11
  • 95
  • 121
30
votes
2 answers

How to try-except an illegal matrix operation due to singularity in NumPy

In NumPy, I'm trying to use linalg to compute matrix inverses at each step of a Newton-Raphson scheme (the problem size is small intentionally so that we can invert analytically computed Hessian matrices). However, after I get far along towards…
ely
  • 74,674
  • 34
  • 147
  • 228
30
votes
2 answers

Fitting a line in 3D

Are there any algorithms that will return the equation of a straight line from a set of 3D data points? I can find plenty of sources which will give the equation of a line from 2D data sets, but none in 3D. Thanks.
Mike
  • 899
  • 2
  • 12
  • 16
30
votes
1 answer

Haskell Linear Algebra Matrix Library for Arbitrary Element Types

I'm looking for a Haskell linear algebra library that has the following features: Matrix multiplication Matrix addition Matrix transposition Rank calculation Matrix inversion is a plus and has the following properties: arbitrary element (scalar)…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
28
votes
3 answers

BLAS: gemm vs. gemv

Why does BLAS have a gemm function for matrix-matrix multiplication and a separate gemv function for matrix-vector multiplication? Isn't matrix-vector multiplication just a special case of matrix-matrix multiplication where one matrix only has one…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
28
votes
2 answers

Haskell linear algebra?

I am starting to test Haskell for linear algebra. Does anyone have any recommendations for the best package for this purpose? Any other good resources for doing basic matrix manipulation with Haskell? The haskell wiki lists several resources for…
Shane
  • 98,550
  • 35
  • 224
  • 217
28
votes
4 answers

How to compute scipy sparse matrix determinant without turning it to dense?

I am trying to figure out the fastest method to find the determinant of sparse symmetric and real matrices in python. using scipy sparse module but really surprised that there is no determinant function. I am aware I could use LU factorization to…
swagatam
  • 283
  • 3
  • 4
28
votes
4 answers

Is there any fast method of matrix exponentiation?

Is there any faster method of matrix exponentiation to calculate Mn (where M is a matrix and n is an integer) than the simple divide and conquer algorithm?
Akashdeep Saluja
  • 2,959
  • 8
  • 30
  • 60
27
votes
1 answer

Identity matrix in Julia

I'm trying to construct the identity matrix in Julia 1.1. After looking at the documentation I found that I could compute a 4x4 Identity matrix as follows: julia> Id4 =1* Matrix(I, 4, 4) 4×4 Array{Int64,2}: 1 0 0 0 0 1 0 0 0 0 1 0 0 …
ecjb
  • 5,169
  • 12
  • 43
  • 79
27
votes
5 answers

Convolution along one axis only

I have two 2-D arrays with the same first axis dimensions. In python, I would like to convolve the two matrices along the second axis only. I would like to get C below without computing the convolution along the first axis as well. import numpy as…
Paul
  • 1,720
  • 2
  • 15
  • 20
27
votes
3 answers

Why is numpy.linalg.pinv() preferred over numpy.linalg.inv() for creating inverse of a matrix in linear regression

If we want to search for the optimal parameters theta for a linear regression model by using the normal equation with: theta = inv(X^T * X) * X^T * y one step is to calculate inv(X^T*X). Therefore numpy provides np.linalg.inv() and…
2Obe
  • 3,570
  • 6
  • 30
  • 54
27
votes
2 answers

Travelling salesman with a directional constraint

I am trying to order an array of 3D coordinates by their order along a path. A sample: points = np.array([[ 0.81127451, 0.22794118, 0.52009804], [ 0.62986425, 0.4546003 , 0.12971342], [ 0.50666667, …
Matt Hall
  • 7,614
  • 1
  • 23
  • 36
27
votes
2 answers

Can't understand the cost function for Linear Regression

I really can't understand the following equation, especially 1/(2m). What's the purpose of this equation? And where does 1/(2m) came from? J(theta_0, theta_1) = 1/(2m) * sum_(i=1)^m [ h_theta(x^i) - y^i ]^2 Please explain. How it casts???
Faheem
  • 287
  • 1
  • 3
  • 5
27
votes
2 answers

Why does my translation matrix needs to be transposed?

I'm working on a small graphics engine using OpenGL and I'm having some issues with my translation matrix. I'm using OpenGL 3.3, GLSL and C++. The situation is this: I have defined a small cube which I want to render on screen. The cube uses it's…
Krienie
  • 611
  • 1
  • 6
  • 14
26
votes
2 answers

scipy.linalg.eig return complex eigenvalues for covariance matrix?

The eigenvalues of a covariance matrix should be real and non-negative because covariance matrices are symmetric and semi positive definite. However, take a look at the following experiment with scipy: >>> a=np.random.random(5) >>>…
user11869
  • 1,083
  • 2
  • 14
  • 29