linear-algebra

C library for linear algebra [closed]

淺唱寂寞╮ 提交于 2019-12-30 04:12:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . Please, give me some tips for a HIGH PERFORMANCE C library for linear algebra (matrix algebra, eigenvalues, eigenvectors etc.). Can be both open-source or closed-source. 回答1: CLAPACK (f2c'ed version of LAPACK) GSL - GNU Scientific Library EDIT Thanks to comments from osgx:

Efficient 4x4 matrix inverse (affine transform)

安稳与你 提交于 2019-12-29 10:16:58
问题 I was hoping someone can point out an efficient formula for 4x4 affine matrix transform. Currently my code uses cofactor expansion and it allocates a temporary array for each cofactor. It's easy to read, but it's slower than it should be. Note, this isn't homework and I know how to work it out manually using 4x4 co-factor expansion, it's just a pain and not really an interesting problem for me. Also I've googled and came up with a few sites that give you the formula already (http://www

Equivalent of `polyfit` for a 2D polynomial in Python

好久不见. 提交于 2019-12-28 13:21:31
问题 I'd like to find a least-squares solution for the a coefficients in z = (a0 + a1*x + a2*y + a3*x**2 + a4*x**2*y + a5*x**2*y**2 + a6*y**2 + a7*x*y**2 + a8*x*y) given arrays x , y , and z of length 20. Basically I'm looking for the equivalent of numpy.polyfit but for a 2D polynomial. This question is similar, but the solution is provided via MATLAB. 回答1: Here is an example showing how you can use numpy.linalg.lstsq for this task: import numpy as np x = np.linspace(0, 1, 20) y = np.linspace(0, 1

Efficient dot products of large memory-mapped arrays

北战南征 提交于 2019-12-28 03:45:23
问题 I'm working with some rather large, dense numpy float arrays that currently reside on disk in PyTables CArray s. I need to be able to perform efficient dot products using these arrays, for example C = A.dot(B) , where A is a huge (~1E4 x 3E5 float32) memory-mapped array, and B and C are smaller numpy arrays that are resident in core memory. What I'm doing at the moment is copying the data into memory-mapped numpy arrays using np.memmap , then calling np.dot directly on the memory-mapped

Does Matlab eig always returns sorted values?

試著忘記壹切 提交于 2019-12-28 02:56:05
问题 I use a function at Matlab: [V,D] = eig(C); I see that V and D are always sorted ascending order. Does it always like that or should I sort them after I get V and D values? 回答1: V is NOT sorted in any order, except to correspond to the order of the associated eigenvalues. But perhaps you did not mean that. The eigenvalues TEND to be in descending order, but this is not assured at all. They tend to be in order because the largest tend to trickle out of the algorithm on top. Eig has no sort at

numpy arbitrary precision linear algebra

你。 提交于 2019-12-28 02:10:30
问题 I have a numpy 2d array [medium/large sized - say 500x500]. I want to find the eigenvalues of the element-wise exponent of it. The problem is that some of the values are quite negative (-800,-1000, etc), and their exponents underflow (meaning they are so close to zero, so that numpy treats them as zero). Is there anyway to use arbitrary precision in numpy? The way I dream it: import numpy as np np.set_precision('arbitrary') # <--- Missing part a = np.array([[-800.21,-600.00],[-600.00,-1000.48

Represent a sparse matrix in C using the CSparse Library

巧了我就是萌 提交于 2019-12-25 18:37:35
问题 I can't understand how can easily represent a sparse matrix in C using the CSparese Library. That's what I want | 6.0 0.0 2.0 | A = | 3.0 8.0 0.0 | | 6.0 0.0 1.0 | with | 40.0 | b = | 50.0 | | 30.0 | The cs Struct of the csparse is this typedef struct cs_sparse /* matrix in compressed-column or triplet form */ { csi nzmax ; /* maximum number of entries */ csi m ; /* number of rows */ csi n ; /* number of columns */ csi *p ; /* column pointers (size n+1) or col indices (size nzmax) */ csi *i ;

How to fit a plane to a 3D point cloud?

谁都会走 提交于 2019-12-25 11:56:45
问题 I want to fit a plane to a 3D point cloud. I use a RANSAC approach, where I sample several points from the point cloud, calculate the plane, and store the plane with the smallest error. The error is the distance between the points and the plane. I want to do this in C++, using Eigen. So far, I sample points from the point cloud and center the data. Now, I need to fit the plane to the samples points. I know I need to solve Mx = 0 , but how do I do this? So far I have M (my samples), I want to

Solving the 3 DOF Rotation in a simplified camera model

。_饼干妹妹 提交于 2019-12-25 04:52:24
问题 I'm trying to obtain a 3x3 rotation matrix and a focal length parameter in a constrained projection camera model: formula to relate pixel coordinates to real world coordinates: The 3x4 matrix that describe both intrinsic and extrinsic parameters so in my constrained camera model, u0 and v0 are set to 1, Tx, Tv, Tz are set to 0, so the DOF of this is reduced 4 DOF (3 DOF from rotation matrix + 1 DOF for the focal length (au, av)). My problem is, although I know the rotation matrix is

Solving a System of Linear Equations with Constraints in C# (Mono)

最后都变了- 提交于 2019-12-25 02:23:17
问题 I have a system of linear equations with dimensions 3xN that I am currently solving using the Accord.NET method: double[,] A = ... // matrix A double[] b = ... // vector b // Then all that is necessary is to call: double[] x = A.Solve(b, leastSquares: true); This works fine but I need to also impose constraints (primarily, x > 0). Is there a way to implement this (ideally within Accord or some other simple library)? The elements of both A and B can have positive, negative and zero values and