[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] [bug #53904] Bug gsl_matrix_complex_set
From: |
Patrick Alken |
Subject: |
[Bug-gsl] [bug #53904] Bug gsl_matrix_complex_set |
Date: |
Mon, 14 May 2018 17:39:48 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?53904>
Summary: Bug gsl_matrix_complex_set
Project: GNU Scientific Library
Submitted by: psa
Submitted on: 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:
Discussion Lock: Any
_______________________________________________________
Details:
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;
}
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?53904>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-gsl] [bug #53904] Bug gsl_matrix_complex_set,
Patrick Alken <=