cblas_example1.c

来自「基本的C语言线性代数函数库,在linux下可直接编译;在windows下要显示地」· C语言 代码 · 共 70 行

C
70
字号
/* cblas_example.c */#include <stdio.h>#include <stdlib.h>#include "cblas.h"int main ( ){   enum CBLAS_ORDER order;   enum CBLAS_TRANSPOSE transa;   double *a, *x, *y;   double alpha, beta;   int m, n, lda, incx, incy, i;   order = CblasColMajor;   transa = CblasNoTrans;   m = 4; /* Size of Column ( the number of rows ) */   n = 4; /* Size of Row ( the number of columns ) */   lda = 4; /* Leading dimension of 5 * 4 matrix is 5 */   incx = 1;   incy = 1;   alpha = 1;   beta = 0;   a = (double *)malloc(sizeof(double)*m*n);   x = (double *)malloc(sizeof(double)*n);   y = (double *)malloc(sizeof(double)*n);   /* The elements of the first column */   a[0] = 1;   a[1] = 2;   a[2] = 3;   a[3] = 4;   /* The elements of the second column */   a[m] = 1;   a[m+1] = 1;   a[m+2] = 1;   a[m+3] = 1;   /* The elements of the third column */   a[m*2] = 3;   a[m*2+1] = 4;     a[m*2+2] = 5;   a[m*2+3] = 6;   /* The elements of the fourth column */   a[m*3] = 5;   a[m*3+1] = 6;   a[m*3+2] = 7;   a[m*3+3] = 8;   /* The elemetns of x and y */    x[0] = 1;   x[1] = 2;   x[2] = 1;   x[3] = 1;   y[0] = 0;   y[1] = 0;   y[2] = 0;   y[3] = 0;      cblas_dgemv( order, transa, m, n, alpha, a, lda, x, incx, beta,                y, incy );   /* Print y */   for( i = 0; i < n; i++ )       printf(" y%d = %f\n", i, y[i]);   free(a);   free(x);   free(y);   return 1;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?