help-gsl
[Top][All Lists]

## Re: [Help-gsl] Determinant of a matrix:

 From: Doug McKee Subject: Re: [Help-gsl] Determinant of a matrix: Date: Sun, 27 Feb 2005 20:35:20 -0800

I'm probably a little late (just joined the list today), but I ran into this exact problem about a week ago. I never figured out why my call to gsl_linalg_LU_det didn't work, but I did come up with a work-around. If I copy the function definition from the gsl source and rename the function my_gsl_linalg_LU_det in my own file, it works great. All it does is multiply the elements of the diagonal. I'd still love to know why the library call fails though. Just makes me nervous that other functions are failing and I'm not noticing.
```
HTH,
Doug

```
```Thanks a lot for the reply.

I am sorry, I did copy the matrix A into tmp_ptr. So, the code is like:
(exactly as you suggested in the reply):

double get_det(gsl_matrix * A) {
int sign=0; double det=0.0; int row_sq = A->size1;
gsl_permutation * p = gsl_permutation_calloc(row_sq);
gsl_matrix * tmp_ptr = gsl_matrix_calloc(row_sq, row_sq);
int * signum = &sign;
gsl_matrix_memcpy(tmp_ptr, A);
gsl_linalg_LU_decomp(tmp_ptr, p, signum);
det = gsl_linalg_LU_det(tmp_ptr, *signum);
gsl_permutation_free(p);
gsl_matrix_free(tmp_ptr);
return det;
}

It doesnt work, even for simple 2X2 or 3X3 matrices.

```
```-Nomesh
```
```

```