-
Notifications
You must be signed in to change notification settings - Fork 14
/
dgemv.cpp
57 lines (37 loc) · 978 Bytes
/
dgemv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <math.h>
#include <algorithm>
#include "dgemv.h"
void vector_dgemv(double *A, double *vecin,double *vecout,int rowa, int cola, char AT)
{
int M,N,K;
double alpha=1;
double beta=0;
int incX=1;
int incY=1;
dgemv_(&AT, &rowa, &cola, &alpha, A, &rowa, vecin, &incX, &beta, vecout, &incY);
}
void dgemv(double **A, double *vecin,double *vecout,int rowa, int cola, char AT)
{
int M,N,K;
double *a;
double alpha=1;
double beta=0;
int incX=1;
int incY=1;
a = dgemv_ctof(A, rowa, cola);
dgemv_(&AT, &rowa, &cola, &alpha, a, &rowa, vecin, &incX, &beta, vecout, &incY);
delete a;
}
double* dgemv_ctof(double **in, int rows, int cols)
{
double *out;
int i, j;
out = new double[rows*cols];
for (i=0; i<rows; i++) for (j=0; j<cols; j++) out[i+j*rows] = in[i][j];
return(out);
}
void dgemv_ftoc(double *in, double **out, int rows, int cols)
{
int i, j;
for (i=0; i<rows; i++) for (j=0; j<cols; j++) out[i][j] = in[i+j*rows];
}