|
NumCpp(C++版本Numpy)安装与使用
玩python进行矩阵运算的,没有不知道numpy的,可惜没有c++版本的numpy放出来
安装:
git clone https://github.com/dpilger26/NumCpp
mkdir build
cd build
cmake ..
make
sudo make install 或者 sudo cmake --build . --target install
fatal error: boost/math/special_functions/chebyshev.hpp: 没有那个文件或目录
#include "boost/math/special_functions/chebyshev.hpp"
问题在:boost版本太低了
查看一下:
jiang@jiang-Ubuntu:~$ dpkg -S /usr/include/boost/version.hpp
libboost1.65-dev:amd64: /usr/include/boost/version.hpp
在CMakeLists.txt中查看一下版本:
find_package(Boost) 输出:Found Boost: /usr/include (found version "1.65.1")
官方要求:
Boost Versions:
1.68+
手动编译安装Boost1.69新版本(先卸载旧版本):
http://www.ai111.vip/thread-1251-1-1.html
- #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;
- }
复制代码
- cmake_minimum_required (VERSION 3.14)
- project("main" CXX)
- #aux_source_directory(. ALL_SRCS)
- set(ALL_SRCS "dm02.cpp")
- add_executable(${PROJECT_NAME} ${ALL_SRCS})
- message(WARNING "我说:lib目录里的文件编译成动态库再由main函数调用")
- # Building NumCpp version 2.5.0
- find_package(NumCpp 2.5.0 REQUIRED)
- target_link_libraries(${PROJECT_NAME}
- NumCpp::NumCpp
- )
- #find_package(FFTW3f)
- #target_link_libraries(main -lboost_system -lboost_thread -lfftw3f -lpthread)
- # 官方链接:https://dpilger26.github.io/NumCpp/doxygen/html/md__c_1__github__num_cpp_docs_markdown__building.html
复制代码
|
|