A C++ header-only library inspired by NumPy.
(Compatible with C++17 and above)
NumXX is an implementation of NumPy in C++. It hopes to bring about the easy number and array manipulation found in NumPy ... but in C++.
This library was made completely in vanilla C++, so using it should be simple. There are two ways:
- Simply clone this repository:
git clone https://github.com/abdallahsoliman00/NumXX.git- Add the folder NumXX to your include path.
- To use, add the following line to the top of your C++ file:
#include "NumXX.hpp"- Add the following to your CMakeLists.txt project file:
# Fetch NumXX from GitHub
include(FetchContent)
FetchContent_Declare(
NumXX
GIT_REPOSITORY https://github.com/abdallahsoliman00/NumXX.git
GIT_TAG main
)
FetchContent_MakeAvailable(NumXX)
# Link library
target_link_libraries(${PROJECT_NAME}
PRIVATE
NumXX
)
- You can now use the library by adding the following:
#include <NumXX.hpp>This project is complete with *mostly all the core features.
These include:
- Easy array creation for any number of dimensions
- Element-wise operations
- Array slicing
- Basic matrix and vector operations (see here)
- Functional operations. i.e. trig functions, logarithms and exponentials, etc...
- Core NumPy-equivalent functions like
sum(),mean(),diff(),max(),min() - File handling operations to read and write to files.
For a fully working implementation, see NumCpp or xtensor.
*Note: It is mostly complete as not all core features are implemented to their fullest extent.
This library aims to mimic NumPy functionality, so for example, if you want to run this in NumPy:
import numpy as np
x = np.array([1,2,3,4])
np.sum(x)Try this in NumXX:
#include "NumXX.hpp"
namespace nx = numxx;
int main() {
auto x = nx::NArray({1,2,3,4});
nx::sum(x);
}If it doesn't exist, it hasn't been implemented yet, and if you're feeling generous perhaps you can implement it yourself and open a pull request.
To see a small taster snippet of code, see this examples file.
This is only a README to help you get started quickly. For a more comprehensive documentation, please see the link below:
https://abdallahsoliman00.github.io/NumXX-Docs/
This repository is open to contributions. If anyone wishes to contribute, please feel free to open a pull request.
This library was a one-man project. The reliability of this library is therefore not guaranteed. Please use with caution.
Inspired by NumPy.