Has anyone installed the GNU Scientific Library for use in a C project in Atmel Studio? I need to invert a 6x6 matrix. Any hints would be welcomed.

## installing GNU Scientific Library

What's to "install" exactly? Surely you just pull the source and build it?

There is a lot of talk about installing it in Ubuntu. I found a site where I can download the library, and then instructions to add it to a Visual Studio project in the usual way. I will try that.

Most such libraries are designed for "infinite resource" PCs so does this give any guarantees about resource requirements?

Jack Crenshaw wrote a column at Embedded Systems Design on applied numerical analysis, and IIRC, one or more books on that.

embedded.com

Reusing code and inverting matrices

July 30, 2008

(page 3)

Back to the Matrix class...

via

embedded.com

Jack Crenshaw's column features algorithms and plug-and-play routines, along with explanations of how they work.

http://www.embedded.com/electronics-blogs/26/Programmer-s-Toolbox

http://www.embedded.com/user/JackCrens

...

Jack Crenshaw is a systems engineer and the author of Math Toolkit for Real-Time Programming.

...

https://www.crcpress.com/Math-Toolkit-for-Real-Time-Programming/Crenshaw/p/book/9781929629091

My first thought was,"On an AVR?" But then, some of them ARE bigger and faster than computers we used to do this stuff on.

But what do you need a library for? Inverting a matrix is easy. http://bfy.tw/BaWl

I got the GSL-2-3 files from the GNU website and unzipped them. I am out of my depth trying to build it. I don't suppose anyone here has the Atmel Studio library built for this and the include files they could just give me. It is not that I am lazy, just frustrated and ignorant on how to proceed.

I know how to invert a matrix, but there are subtlies if it is sparse or banded and so forth. GSL would have all of that.

**TORBY SAID:**

My first thought was, "On an AVR?" But then, some of them ARE bigger and faster than computers we used to do this stuff on.

It's true, an ATmega256 has more memory than the mainframe I did my PhD thesis on, and that required inverting a 40x40 matrix.

**TORBY SAID:**

But what do you need a library for? Inverting a matrix is easy.

Try row reducing a 6x6 to the unity matrix and tell me how easy it is. Doing a Google search is easy.

**MarkThomas wrote:**

I know how to invert a matrix, but there are subtlies if it is sparse or banded and so forth.

/* General-purpose matrix inversion routine

The n x n matrix a is inverted in place.This subroutine has a long history, dating back to the IBM

scientific subroutine package routine of the same name.

the subroutine uses the gauss-jordan method of pivotal

condensation, with complete pivoting. this means that for each

column of a, a search is executed for the largest element below

or to the right of the current diagonal element. this largest

element is moved to the position of the pivotal element.

the history of the interchanges is retained in the working

vectors irow and icol, which are used to restore the inverse

matrix to the correct order. the user must supply storage

for irow and icol. usage isdouble a[n][n];

size_t irow[n], icol[n];

...

det = minv(a, irow, icol, n)

*/double mInv(double a[], size_t irow[], size_t icol[], const size_t n){

from

embedded.com

SimpleMat.cpp

October 21, 2008

http://www.embedded.com/design/embedded/source-code/4200225/SimpleMat-cpp

embedded.com

Reusing code and inverting matrices

July 30, 2008

(page 6 of 7)

...

mInv, the matrix inversion algorithm I'm providing inSimpleMat.cpp, is an oldie but goodie....

I should mention that Gauss-Jordan is not the only way to invert a matrix. More modern methods involve factoring the matrix into two parts. The LU decomposition, for example, involves factoring the matrix into two triangular matrices. ... However, if you have to solve many such linear equations, involving the

samematrixA, LU decomposition is much faster.Several other decomposition algorithms exist. Each has its advantages. However, if you want the matrix inverse explicitly, and your matrix is relatively small (say less than 20x20), you'll find

mInvhard to beat.

gchapman, that is actually a pretty good inversion algorithm, and I will probably use something like it and hope my matricies are not sparse or otherwise weird.

Years ago I fond a (Legal) distribution of the book "numerical Recipes in C" online & made a copy, but haven't done much with it since.

It's filled with math concepts and C algorithms to calculate them (Also matrices) and might be relevant to this post.

Hi Paul,

That would be a nice book to have. It is sort of pricey on Amazon. What sort of algorithms does it have for inverting a matrix bigger than 4x4? I will probably end up using a Gauss-Jordon I can find code for on line.

It would be a copywrite violation for you to email me the pages of interest, or the whole book for that matter.

mark

Paul,

I found the Gauss-Jordan code from Numerical Recipes. Thanks for the tip.

mark