This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gsl_linalg_LU_det error




I think the problem was that you 
mistakenly used gsl_linalg_LU_det(&m.matrix,s2) instead of
gsl_linalg_LU_det ( &m.matrix, s1 ). I changed
your code to the following and got the right answer:

(It's in plain C.)

---------begin dettest.c--------------
#include <stdio.h>
#include <stdlib.h>
#include <gsl/gsl_linalg.h>
int main (void)
{
  double a_data[] = { 3.0, 4.0, 5.0, 66.0, 23.0, 1.0, 2.0, 7.0, 9.0 };
  gsl_matrix_view m = gsl_matrix_view_array(a_data, 3,3);
  int s1,s2;
  double dd;
  gsl_permutation * p = gsl_permutation_alloc (3);
  gsl_linalg_LU_decomp (&m.matrix, p, &s1);
  dd=gsl_linalg_LU_det (&m.matrix,s1);
  printf ( "%f\n",dd);
  gsl_permutation_free (p);
  return 0;
}
-----------end dettest.c------------

-Jason


On Mon, May 27, 2002 at 01:29:34PM +0200, Kollányi Tibor wrote:
> Hello, here is my simple program, but the value of determinant is not 
> correct. What is the problem?
> #include <iostream.h>
> #include <stdlib.h>
> #include <gsl/gsl_linalg.h>
> int main (void)
> {
>   double a_data[] = { 3.0, 4.0, 5.0, 66.0, 23.0, 1.0, 2.0, 7.0, 9.0 };
>   gsl_matrix_view m = gsl_matrix_view_array(a_data, 3,3);
>   int s1,s2;
>   double dd;
>   gsl_permutation * p = gsl_permutation_alloc (3);
>   gsl_linalg_LU_decomp (&m.matrix, p, &s1);
>   dd=gsl_linalg_LU_det (&m.matrix,s2);
>   cout << "det(A)= " << dd;
>   gsl_permutation_free (p);
>   return 0;
> }
> Please help me!
> 
> -- 
> Kollányi Tibor
> assistant
> University of Miskolc
> Miskolc-Egyetemváros
> H-3515
> HUNGARY
> tel.:+36 46 / 565 111 / 1915
>             30 / 455 7717


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]