日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Ubuntu16.04安装openBLAS

發布時間:2023/12/13 综合教程 32 生活家
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu16.04安装openBLAS 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考博客:https://www.cnblogs.com/chay/p/10272949.html

cblas_daxpy(_:_:_:_:_:_:):https://developer.apple.com/documentation/accelerate/1513298-cblas_daxpy

Ubuntu16.04安裝openBLAS

基本步驟:

 git clone git://github.com/xianyi/OpenBLAS
  cd OpenBLAS
  sudo apt-get install gfortran
  sudo make FC=gfortran
  sudo make install

最后安裝在/opt 下,執行:

ln -s /opt/OpenBLAS/lib/libopenblas.so.0   /usr/lib/libopenblas.so.0

創建一個測試程序:

#include <stdio.h>
#include <stdlib.h>
#include "cblas.h"

int main(){

        int n;                          /*! array size */
        double da;                      /*! double constant */
        double *dx;                     /*! input double array */
        int incx;                        /*! input stride */
        double *dy;                      /*! output double array */
        int incy;                       /*! output stride */

        int i;

        n = 10;
        da = 10;
        dx = (double*)malloc(sizeof(double)*n);
        incx = 1;
        dy = (double*)malloc(sizeof(double)*n);
        incy = 1;

        for(i=0;i<n;i++){
                dx[i] = 9-i;
                dy[i] = i;
                printf("%f ",dy[i]);    //輸出原來的dy
        }
        printf("
");

        cblas_daxpy(n, da, dx,incx, dy, incy);  //運行daxpy程序
    //    cblas_dcopy(n, dx,incx, dy, incy);      //運行dcopy程序

        for(i=0;i<n;i++){
            printf("%f ",dy[i]);   //輸出計算后的dy
        }
        printf("
");

        return 0;   
}  

運行以下命令,生成a.out可執行文件:

gcc test.c  -I /opt/OpenBLAS/include/ -L/opt/OpenBLAS/lib -lopenblas

執行結果:(此處相當于:da*dx[i]+dy[i])

0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 
90.000000 81.000000 72.000000 63.000000 54.000000 45.000000 36.000000 27.000000 18.000000 9.000000

總結

以上是生活随笔為你收集整理的Ubuntu16.04安装openBLAS的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。