A simple yet powerful multi-dimensional array implementation in C++11, inspired by Python's NumPy. This library provides an intuitive interface for working with multi-dimensional arrays, supporting slicing, indexing, and initialization through initializer lists.
Features
- Multi-dimensional arrays: Supports arrays with arbitrary dimensions, enabling complex data structures.
- Initializer list support: Easily initialize arrays with nested lists.
- Indexing and slicing: Access and manipulate data through familiar Python-like syntax.
- C++11 support: Fully compatible with C++11 and upper, using modern type traits and std::initializer_list.
Installation
To use Ndarray-11, simply download or clone the repository and include the header file in your project.
Then, include the header file in your code:
A simple multi-dimensional array implementation in C++11.
Usage
- For more examples, see the examples directory.
- Documentation is generated using Doxygen, and can be found here.
Basic Initialization
Create a 3D array with pre-defined dimensions:
{
{0, 0, 0},
{0, 0, 0}
},
{
{1, 1, 1},
{1, 1, 1}
}
};
An interface to create Ndarray.
Definition ndarray-11.hpp:375
Accessing Elements
Access elements with an intuitive function call syntax, similar to Python's NumPy:
Slicing
Perform slicing operations with a Python-like syntax using the Range
class:
auto sliced_array = array["0:1, ::1"];
Printing Arrays
Print the array using the <<
operator:
std::cout << array << std::endl;
Example
int main() {
{
{0, 0, 0},
{0, 0, 0}
},
{
{1, 1, 1},
{1, 1, 1}
}
};
array(0, 1, 2) = 777;
std::cout << array << std::endl;
return 0;
}
Limitations
Cooming not so soon
Check out the Milestones
Contributions
Contributions are welcome! If you find bugs or have suggestions for improvements, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements