bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bugs in functions gsl_blas_dgemv and gsl_blas_dgemm


From: Ignat Shishkin
Subject: bugs in functions gsl_blas_dgemv and gsl_blas_dgemm
Date: Thu, 18 May 2023 01:10:29 +0300

Hello!
I have a problem with this function. I noticed that it can change
vector<gsl_vector *>. Write down an example.

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>

#include <gsl/gsl_matrix.h>
#include <gsl/gsl_linalg.h>

void printv(gsl_vector *v)
{
    int N = v->size; //size_of_matrix
    for (int i = 0; i < N; i++)
    {
        printf ("%6.3f ", gsl_vector_get (v, i));
    }
    printf("\n");
}
int main()
{
int N = 8;
vector <gsl_vector *>test;
    gsl_vector *test_ = gsl_vector_alloc (N);
    gsl_vector *test_t = gsl_vector_alloc (N);
    gsl_vector_set_all(test_, 1.0);
    for(int i = 0; i < 7; i++ )
    {
        test_ = sumv(test_,test_);
        test.push_back(test_);
    }

    for(int i = 0; i < 7; i++ )
    {
        printv(test[i]);
    }

    gsl_matrix *q = gsl_matrix_alloc (N, N);
    gsl_matrix_set_identity(q);



    //gsl_vector_memcpy(test_t, test[1]);
    test_t = test[1];
    gsl_blas_dgemv (CblasNoTrans, 1.0, q, test_t , 0.0,  test_);
    //gsl_vector_memcpy(test[3], test_);


printf("\n");
     for(int i = 0; i < 7; i++ )
    {
        printv(test[i]);
    }

return 0;
}

And we get
 2.000  2.000  2.000  2.000  2.000  2.000  2.000  2.000
 4.000  4.000  4.000  4.000  4.000  4.000  4.000  4.000
 8.000  8.000  8.000  8.000  8.000  8.000  8.000  8.000
16.000 16.000 16.000 16.000 16.000 16.000 16.000 16.000
32.000 32.000 32.000 32.000 32.000 32.000 32.000 32.000
64.000 64.000 64.000 64.000 64.000 64.000 64.000 64.000
128.000 128.000 128.000 128.000 128.000 128.000 128.000 128.000

2.000  2.000  2.000  2.000  2.000  2.000  2.000  2.000
 4.000  4.000  4.000  4.000  4.000  4.000  4.000  4.000
 8.000  8.000  8.000  8.000  8.000  8.000  8.000  8.000
16.000 16.000 16.000 16.000 16.000 16.000 16.000 16.000
32.000 32.000 32.000 32.000 32.000 32.000 32.000 32.000
64.000 64.000 64.000 64.000 64.000 64.000 64.000 64.000
 4.000  4.000  4.000  4.000  4.000  4.000  4.000  4.000

How did the last element of the vector test change? How is it possible?
Have I made a mistake here?

-- 
Kind Regards
Ignat Shishkin

+7 (958) 193 72 54


reply via email to

[Prev in Thread] Current Thread [Next in Thread]