[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] Bug gsl_matrix_complex_set
From: |
Daniel Comparat |
Subject: |
[Bug-gsl] Bug gsl_matrix_complex_set |
Date: |
Sat, 31 Mar 2018 12:26:41 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
Dear sir or Madam
I found a bug when using *gsl_matrix_complex_set.*
You will find the code below, the output of the data array is wrong if I use
/gsl_matrix_complex_set(m, 1, 1, gsl_complex_rect(1., 0.))/
in the code. So there is a bug. However if using
/gsl_complex x = gsl_complex_rect(1., 0.);/
/ gsl_matrix_complex_set(m, 1, 1, x);/
it is O.K.
Here is a code (I was testing using a real matrix the complex eigenvalue)
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <stdio.h> /* printf */
#include <stdlib.h> /* system, NULL, EXIT_FAILURE */
#include <gsl/gsl_math.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_cblas.h>
using namespace std;
int main()
{
double S_VN =0. ;
int size = 4;
cout << " size = " << size << endl;
double data[16] = { -1.0, 1.0, -1.0, 1.0,
-8.0, 4.0, -2.0, 1.0,
27.0, 9.0, 3.0, 1.0,
64.0, 16.0, 4.0, 1.0
};
for (int i=0; i<16; i++)
cout << " i = " << i << " data[i] " << data[i] << endl;
gsl_eigen_herm_workspace *w = gsl_eigen_herm_alloc(size); // This
function allocates a workspace for computing eigenvalues
gsl_matrix_complex *m = gsl_matrix_complex_alloc(size, size);
gsl_vector *eval = gsl_vector_alloc (size); // Valeurs propres
gsl_complex x = gsl_complex_rect(1., 0.);
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
{
cout << " i = " << i << " j = " << j << " j+4*i = " <<
j+4*i << " data[i][j] " << data[j+4*i] << " data [9] " << data[9] << endl;
gsl_matrix_complex_set(m, 1, 1, x); // matrice pour rho_gg
= rho_11
}
gsl_eigen_herm(m, eval, w); // This function computes the
eigenvalues of the complex hermitian matrix
gsl_eigen_herm_free(w); // This function frees the memory
associated with the workspace w.
return 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gsl] Bug gsl_matrix_complex_set,
Daniel Comparat <=