Probuje pomnozyc macierz i wektor wykorzystjac bibliteke CBLAS.
Kod:
#include "cblas.h"
#include<iostream>
using namespace std;
int main()
{
enum CBLAS_ORDER order;
enum CBLAS_TRANSPOSE transa;
double **a, *x, *y;
double alpha, beta;
int m, n, lda, incx, incy, i; //m - liczba wierszy ; n -liczba kolumn
order = CblasColMajor;
transa = CblasNoTrans;
a = new double *[m];
for (int i=0; i<m; i++) a[i] = new double [n];
x = new double [n];
y = new double [n];
m = 4;
n = 4;
lda = 1;
incx = 1;
incy = 1;
alpha =1;
beta = 0;
//element tablic
for (int i = 0; i<m; i++)
for (int j = 0; j<n; j++)
{ a[i][j] = 2; }
x[0] = 1;
x[1] = 2;
x[2] = 3;
x[3] = 4;
y[0] = 0;
y[1] = 0;
y[2] = 0;
y[3] = 0;
cblas_dgemv( order, transa, m, n, alpha, a, lda, x, incx, beta, y, incy );
for (int i = 0; i<n; i++)
cout << "y[" << i << "]=" << y[i];
return 0;
}
Jednazke wyskakuje blad:
cannot convert ‘double**’ to ‘const double*’ for argument ‘6’ to ‘void cblas_dgemv(CBLAS_ORDER, CBLAS_TRANSPOSE, int, int, double, const double*, int, const double*, int, double, double*, int)’
Moja tablica musi byc w posatci double*. jak powinnam poprawnie to uczynic?