-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathblas2bC.c
44 lines (34 loc) · 2.03 KB
/
blas2bC.c
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
/* -*- Mode:C; Coding:us-ascii-unix; fill-column:132 -*- */
/* ****************************************************************************************************************************** */
/**
@file blas2bC.c
@author Mitch Richling <https://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 illustrate how to make use of #gemv and #ger blas routines (as implemented in the cblas).
This is almost precisely the same as example program blas2.c; however, this one uses the column major order of Fortran.
*/
/* ------------------------------------------------------------------------------------------------------------------------------ */
#include <stdio.h> /* I/O lib ISOC */
#include <stdlib.h> /* Standard Lib ISOC */
#include "blaio.h" /* Basic Linear Algebra I/O */
int main(int argc, char **argv) {
double a[4*5] = { 1, 6, 11, 16,
2, 7, 12, 17,
3, 8, 13, 18,
4, 9, 14, 19,
5, 10, 15, 20 };
double x[5] = {2,3,4,5,6};
double y[4];
printMatrix(CblasColMajor, 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(CblasColMajor, CblasNoTrans, 4, 5, 1, a, 4, x, 1, 0, y, 1);
printVector(4, y, 8, 3, NULL, NULL, NULL, " y<-1.0*a*xT+0.0*y= ");
/* row_order lenY lenX alpha X incX Y, incY A LDA */
cblas_dger(CblasColMajor, 4, 5, 1, y, 1, x, 1, a, 4);
printMatrix(CblasColMajor, 4, 5, a, 8, 3, NULL, NULL, NULL, NULL, NULL, "a <- 1.0*x.yT+a = ");
return 0;
} /* end func main*/