bugGNU Scientific Library - Bugs: bug #53904, Bug gsl_matrix_complex_set

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #53904: Bug gsl_matrix_complex_set

Submitter:  Patrick Alken <psa>
Submitted:  Mon 14 May 2018 09:39:47 PM UTC
   
 
Category:  None Severity:  3 - Normal
Operating System:  Status:  None
Assigned to:  None Open/Closed:  Open
Release: 

Mon 14 May 2018 09:39:47 PM UTC, original submission:  

from daniel =dot= comparat =at= u-psud =dot= fr

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;
}

Patrick Alken <psa>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psa (Submitted the item)
  •  

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code