[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Bug-gsl] gsl_blas_dgemv return a 0 vector when using a vector twice

**From**: |
Alejandro Cruz Marcelo |

**Subject**: |
Re: [Bug-gsl] gsl_blas_dgemv return a 0 vector when using a vector twice |

**Date**: |
Wed, 03 Sep 2008 11:37:51 -0500 |

**User-agent**: |
Thunderbird 2.0.0.16 (Windows/20080708) |

Hello Brian
Sorry for my late response.
When using the funciton gsl_blas_dgemv to perform the operation
x = Ax

`it returns x equal to 0. I guess we are not supposed to use the same
``vector but that warning is not in the manual.
`However, the operation
x = Ax + x
it is performed properly.
Here is some code to illustrate this.
Thank you,
Alejandro
// Start code
#include <stdio.h>
#include <math.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
int main()
{
gsl_vector * x = gsl_vector_calloc(2);
gsl_matrix * A = gsl_matrix_calloc(2,2);
gsl_matrix_set_identity(A);
gsl_vector_set(x,0,2);
gsl_vector_set(x,1,2);
gsl_blas_dgemv(CblasNoTrans,
1.0, A, x,
0.0, x);
printf( "The operation performed is x = (1.0)*A*x + (0.0)*x \n ");
printf("Output should be the vector [2,2]^t ");
printf("but instead we get: ");
printf("%f \n ", gsl_vector_get(x,0));

`printf("%f ", gsl_vector_get(x,1));
`` system("PAUSE");
``
`gsl_vector_set(x,0,2);
gsl_vector_set(x,1,2);
gsl_blas_dgemv(CblasNoTrans,
1.0, A, x,
1.0, x);
printf( "But if the operation performed is x = (1.0)*A*x + (1.0)*x \n ");
printf("Output should be the vector [4,4]^t ");
printf("and that is what we get: ");
printf("%f \n ", gsl_vector_get(x,0));

`printf("%f ", gsl_vector_get(x,1));
``
`` system("PAUSE");
`` return 0;
`}
// The end
Brian Gough wrote:

At Fri, 29 Aug 2008 09:44:30 -0500,
Alejandro Cruz-Marcelo wrote:

`
`gsl_blas_dgemv(CblasNoTrans,
1.0, A, y,

` 1.0, y)
``then y becomes a vector of 0's and no error is produced, even though the
``operation A*y + y makes perfect sense. I believe that in the
``documentation there is no warning about using the same vector twice in
``the function.
``
`

Please can you send an example program that demonstrates the problem,
thanks.

`
`

**Re: [Bug-gsl] gsl_blas_dgemv return a 0 vector when using a vector twice**,
*Alejandro Cruz Marcelo* **<=**