cblas_example1.c
Go to the documentation of this file.
00001 /* cblas_example.c */
00002 
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include "cblas.h"
00006 
00007 int main ( )
00008 {
00009    enum CBLAS_ORDER order;
00010    enum CBLAS_TRANSPOSE transa;
00011 
00012    double *a, *x, *y;
00013    double alpha, beta;
00014    int m, n, lda, incx, incy, i;
00015 
00016    order = CblasColMajor;
00017    transa = CblasNoTrans;
00018 
00019    m = 4; /* Size of Column ( the number of rows ) */
00020    n = 4; /* Size of Row ( the number of columns ) */
00021    lda = 4; /* Leading dimension of 5 * 4 matrix is 5 */
00022    incx = 1;
00023    incy = 1;
00024    alpha = 1;
00025    beta = 0;
00026 
00027    a = (double *)malloc(sizeof(double)*m*n);
00028    x = (double *)malloc(sizeof(double)*n);
00029    y = (double *)malloc(sizeof(double)*n);
00030    /* The elements of the first column */
00031    a[0] = 1;
00032    a[1] = 2;
00033    a[2] = 3;
00034    a[3] = 4;
00035    /* The elements of the second column */
00036    a[m] = 1;
00037    a[m+1] = 1;
00038    a[m+2] = 1;
00039    a[m+3] = 1;
00040    /* The elements of the third column */
00041    a[m*2] = 3;
00042    a[m*2+1] = 4;  
00043    a[m*2+2] = 5;
00044    a[m*2+3] = 6;
00045    /* The elements of the fourth column */
00046    a[m*3] = 5;
00047    a[m*3+1] = 6;
00048    a[m*3+2] = 7;
00049    a[m*3+3] = 8;
00050    /* The elemetns of x and y */ 
00051    x[0] = 1;
00052    x[1] = 2;
00053    x[2] = 1;
00054    x[3] = 1;
00055    y[0] = 0;
00056    y[1] = 0;
00057    y[2] = 0;
00058    y[3] = 0;
00059    
00060    cblas_dgemv( order, transa, m, n, alpha, a, lda, x, incx, beta,
00061                 y, incy );
00062    /* Print y */
00063    for( i = 0; i < n; i++ ) 
00064       printf(" y%d = %f\n", i, y[i]);
00065    free(a);
00066    free(x);
00067    free(y);
00068    return 1;
00069 }


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:15