安装NumCPP库

时间:2021-08-19
本文章向大家介绍安装NumCPP库,主要包括安装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

完成!

原文地址:https://www.cnblogs.com/nanmi/p/15161211.html