Can I get the matrix determinant using Numpy?
You can use numpy.linalg.det to compute the determinant of an array: In [1]: import numpy In [2]: M = [[1, 2], [3, 4]] In [3]: print numpy.linalg.det(M) Out[3]: -2.0000000000000004
You can use numpy.linalg.det to compute the determinant of an array: In [1]: import numpy In [2]: M = [[1, 2], [3, 4]] In [3]: print numpy.linalg.det(M) Out[3]: -2.0000000000000004
Cramer’s Rule and Gaussian Elimination are two good, general-purpose algorithms (also see Simultaneous Linear Equations). If you’re looking for code, check out GiNaC, Maxima, and SymbolicC++ (depending on your licensing requirements, of course). EDIT: I know you’re working in C land, but I also have to put in a good word for SymPy (a computer … Read more
The equations going from linear index to (i,j) index are i = n – 2 – floor(sqrt(-8*k + 4*n*(n-1)-7)/2.0 – 0.5) j = k + i + 1 – n*(n-1)/2 + (n-i)*((n-i)-1)/2 The inverse operation, from (i,j) index to linear index is k = (n*(n-1)/2) – (n-i)*((n-i)-1)/2 + j – i – 1 Verify in … Read more
Math.NET. We’re using it in production.
The idea with tensordot is pretty simple – We input the arrays and the respective axes along which the sum-reductions are intended. The axes that take part in sum-reduction are removed in the output and all of the remaining axes from the input arrays are spread-out as different axes in the output keeping the order … Read more
You should have a look at numpy if you do matrix manipulation. This is a module mainly written in C, which will be much faster than programming in pure python. Here is an example of how to invert a matrix, and do other matrix manipulation. from numpy import matrix from numpy import linalg A = … Read more
If you want to rotate a vector you should construct what is known as a rotation matrix. Rotation in 2D Say you want to rotate a vector or a point by θ, then trigonometry states that the new coordinates are x’ = x cos θ − y sin θ y’ = x sin θ + … Read more
I was trying to figure this out as well, 2 years later. But I got my answers; hopefully it’ll help someone. You need 2 audio recordings. You can get audio examples from http://research.ics.aalto.fi/ica/cocktail/cocktail_en.cgi. reference for implementation is http://www.cs.nyu.edu/~roweis/kica.html ok, here’s code – [x1, Fs1] = audioread(‘mix1.wav’); [x2, Fs2] = audioread(‘mix2.wav’); xx = [x1, x2]’; yy … Read more
If your number X falls between A and B, and you would like Y to fall between C and D, you can apply the following linear transform: Y = (X-A)/(B-A) * (D-C) + C That should give you what you want, although your question is a little ambiguous, since you could also map the interval … Read more
Use numpy.tile: >>> tile(array([1,2,3]), (3, 1)) array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) or for repeating columns: >>> tile(array([[1,2,3]]).transpose(), (1, 3)) array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])