-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_from_web.c
More file actions
65 lines (48 loc) · 2.15 KB
/
example_from_web.c
File metadata and controls
65 lines (48 loc) · 2.15 KB
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
58
59
60
61
62
63
64
/* -*- Mode:C; Coding:us-ascii-unix; fill-column:132 -*- */
/* ****************************************************************************************************************************** */
/**
@file blas2C.c
@author Mitch Richling <http://www.mitchr.me/>
@Copyright Copyright 1997 by Mitch Richling. All rights reserved.
@brief Demonstrate several cblas (level 1) functions. @EOL
@Keywords blas cblas C fortran numerical linear algebra vector matrix gemv ger
@Std C89
This is a simple program intended to illistrate how to make use of #gemv and #ger blas routines (as implimented in the cblas).
*/
/* ------------------------------------------------------------------------------------------------------------------------------ */
#include <math.h> /* Math stuff ISOC */
#include <stdio.h> /* I/O lib ISOC */
#include <stdlib.h> /* Standard Lib ISOC */
#include <cblas.h> /* Basic Linear Algebra I/O */
int main(int argc, char **argv) {
double a[4*5] = { 1, 2, 3, 4, 5,
6, 7, 8, 9,10,
11,12,13,14,15,
16,17,18,19,20
};
double x[5] = {2,3,4,5,6};
double y[4];
// printMatrix(CblasRowMajor, 4, 5, a, 8, 3, NULL, NULL, NULL, NULL, NULL, " a = ");
// printVector(5, x, 8, 3, NULL, NULL, NULL, " x = ");
/* row_order transform lenY lenX alpha a lda X incX beta Y, incY */
cblas_dgemv(CblasRowMajor, CblasNoTrans, 4, 5, 1, a, 5, x, 1, 0, y, 1);
// printVector(4, y, 8, 3, NULL, NULL, NULL, " y<-1.0*a*xT+0.0*y= ");
int i;
for(i = 0; i < 4; i++)
{
printf("%8.2f\n",y[i] );
}
printf("\n");
/* row_order lenY lenX alpha X incX Y, incY A LDA */
cblas_dger(CblasRowMajor, 4, 5, 1, y, 1, x, 1, a, 5);
// printMatrix(CblasRowMajor, 4, 5, a, 8, 3, NULL, NULL, NULL, NULL, NULL, "a <- 1.0*x.yT+a = ");
for(i = 0; i < 4*5; i++)
{
printf("%8.2f", a[i] );
if ((i+1)%5 == 0)
{
printf("\n");
}
}
return 0;
} /* end func main */