安装NumCPP库

安装NumCPP库

NumCpp库是一个只包含头文件的类似于Numpy的C++库,API都很相似,参考:https://github.com/dpilger26/NumCpp
开发手册:https://dpilger26.github.io/NumCpp/doxygen/html/index.html


编译安装boost库

安装依赖

sudo apt-get install mpi-default-dev  #安装mpi库  
sudo apt-get install libicu-dev     #支持正则表达式的UNICODE字符集   
sudo apt-get install python-dev     #需要python的话  
sudo apt-get install libbz2-dev     #如果编译出现错误:bzlib.h: No such file or directory

boost库源文件下载 https://sourceforge.net/projects/boost/
解压安装

./bootstrap.sh
sudo ./b2
sudo ./b2 install

查看boost库版本

dpkg -S /usr/include/boost/version.hpp

编译安装NumCpp库

下载:https://github.com/dpilger26/NumCpp/releases

编译安装

cd NumCpp
mkdir build
cd build
cmake ..
cmake --build . --target install

最后自动安装在/usr/local/include/NumCpp/usr/local/include/NumCpp.hpp

测试代码

#include "NumCpp.hpp"
 
#include <cstdlib>
#include <iostream>
 
int main()
{
    auto a = nc::random::randInt<int>({10, 10}, 0, 100);
    std::cout << a;
 
    return EXIT_SUCCESS;
}

编译测试代码

make test.cpp -o test

完成!

posted @ 2021-08-19 12:56  nanmi  阅读(1586)  评论(1编辑  收藏  举报