OpenRadioss
2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
cblas_example1.c
Go to the documentation of this file.
1
/* cblas_example.c */
2
3
#include <stdio.h>
4
#include <stdlib.h>
5
#include "
cblas.h
"
6
7
int
main
( )
8
{
9
CBLAS_LAYOUT
Layout;
10
CBLAS_TRANSPOSE
transa;
11
12
double
*a, *
x
, *
y
;
13
double
alpha
, beta;
14
CBLAS_INT
m,
n
, lda, incx, incy, i;
15
16
Layout =
CblasColMajor
;
17
transa =
CblasNoTrans
;
18
19
m = 4;
/* Size of Column ( the number of rows ) */
20
n
= 4;
/* Size of Row ( the number of columns ) */
21
lda = 4;
/* Leading dimension of 5 * 4 matrix is 5 */
22
incx = 1;
23
incy = 1;
24
alpha
= 1;
25
beta = 0;
26
27
a = (
double
*)malloc(
sizeof
(
double
)*m*
n
);
28
x
= (
double
*)malloc(
sizeof
(
double
)*
n
);
29
y
= (
double
*)malloc(
sizeof
(
double
)*
n
);
30
/* The elements of the first column */
31
a[0] = 1;
32
a[1] = 2;
33
a[2] = 3;
34
a[3] = 4;
35
/* The elements of the second column */
36
a[m] = 1;
37
a[m+1] = 1;
38
a[m+2] = 1;
39
a[m+3] = 1;
40
/* The elements of the third column */
41
a[m*2] = 3;
42
a[m*2+1] = 4;
43
a[m*2+2] = 5;
44
a[m*2+3] = 6;
45
/* The elements of the fourth column */
46
a[m*3] = 5;
47
a[m*3+1] = 6;
48
a[m*3+2] = 7;
49
a[m*3+3] = 8;
50
/* The elements of x and y */
51
x
[0] = 1;
52
x
[1] = 2;
53
x
[2] = 1;
54
x
[3] = 1;
55
y
[0] = 0;
56
y
[1] = 0;
57
y
[2] = 0;
58
y
[3] = 0;
59
60
cblas_dgemv
( Layout, transa, m,
n
,
alpha
, a, lda,
x
, incx, beta,
61
y
, incy );
62
/* Print y */
63
for
( i = 0; i <
n
; i++ )
64
printf(
" y%d = %f\n"
, i,
y
[i]);
65
free(a);
66
free(
x
);
67
free(
y
);
68
return
0;
69
}
cblas.h
cblas_dgemv
void cblas_dgemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE TransA, const CBLAS_INT M, const CBLAS_INT N, const double alpha, const double *A, const CBLAS_INT lda, const double *X, const CBLAS_INT incX, const double beta, double *Y, const CBLAS_INT incY)
Definition
cblas_dgemv.c:11
CBLAS_TRANSPOSE
CBLAS_TRANSPOSE
Definition
cblas.h:28
CblasNoTrans
@ CblasNoTrans
Definition
cblas.h:28
CBLAS_LAYOUT
CBLAS_LAYOUT
Definition
cblas.h:27
CblasColMajor
@ CblasColMajor
Definition
cblas.h:27
CBLAS_INT
#define CBLAS_INT
Definition
cblas.h:23
main
int main()
Definition
cblas_example1.c:7
alpha
#define alpha
Definition
eval.h:35
y
y
Definition
schur_example.m:54
x
x
Definition
schur_example.m:53
n
n
Definition
schur_example.m:9
engine
extlib
lapack-3.10.1
CBLAS
examples
cblas_example1.c
Generated by
1.15.0