Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Computing the determinant of a C array

I have written a program that generates a few N x N matrices for which I would like to compute their determinant. Related to this I have two questions

  • What library is the best for doing so? I would like the fastest possible library since I have millions of such matrices.

  • Are there any specifics I should take care of when casting the result to an integer? All matrices that I will generate have integer determinants and I would like to make sure that no rounding error skews the correct value of the determinant.

Edit. If possible provide an example of computing the determinant for the recommended library.

like image 913
Jernej Avatar asked Jan 17 '23 04:01

Jernej


2 Answers

As for Matrix Libraries, it looks like that question is answered here:

Recommendations for a small c-based vector and matrix library

As for casting to an integer: if the determinant is not an integer, then you shouldn't be casting it to an integer, you should be using round, floor, or ceil to convert it in an acceptable way. These will probably give you integral values, but you will still need to cast them; however, you will now be able to do so without fear of losing any information.

like image 90
Dancrumb Avatar answered Jan 18 '23 19:01

Dancrumb


You can work wonders with matrices by blas and lapack. They are actually written in fortran and using them from "c" is kind of a tweak. but all in all they can crunch numbers in horrendous speed.

http://www.netlib.org/lapack/lug/node11.html

like image 38
Aftnix Avatar answered Jan 18 '23 18:01

Aftnix