Search

NumCpp, Numpy for C++

Suitable for Python programmers who want to use C++ but keep the way they do their projects


NumCpp, Numpy for C++


NumCpp is an implementation for C++ of the Numpy library of Python which is for work with multidimensional arrays widely used in Machine Learning .


Installation

In order to use NumCpp on your system it is necessary to clone and compile. Dependencies: CMake, Make and g++:

git clone https://github.com/dpilger26/NumCpp
cd NumCpp
mkdir build && cd build
cmake ..
sudo cmake --build . --target install


Testing and compiling a project

When you are developing with the library you can compile with these procedures. Example of a dummy project: my-project:

mkdir my-project
my-project cd

Create a main.cpp file:

vim main.cpp

#include <NumCpp.hpp>

int main(){
  auto a = nc::random::randInt<int>({10, 10}, 0, 100);
  std::cout << a;
  return EXIT_SUCCESS;
}

Create CMakeLists.txt

vim CMakeLists.txt

cmake_minimum_required(VERSION 3.14)
 
project("HelloWorld" CXX)
 
add_executable(${PROJECT_NAME} main.cpp)
 
find_package(NumCpp 2.6.2 REQUIRED)
target_link_libraries(${PROJECT_NAME}
    NumCpp::NumCpp
)

Compile:

mkdir build && cd build
cmake ..
cmake --build . --config Release
./HelloWorld

For more information access:


cpp cppdaily python


Share



Comments