here's my small, less efficient, and likely incorrect implementation of numpy in C++, built without external dependencies, and from scratch.
hopefully, I learn some C++ through this.
brew install fmt
# Install pybind11 (macOS)
brew install pybind11
# Or using pip
pip install pybind11mkdir -p build
cd build
cmake ..
make
cd ..- basic array construction (1d and 2d)
- zeros(shape)
- ones(shape)
- eye(n)
- arange(start, stop, step)
- linspace(start, stop, num)
- full(shape, value)
- integer indexing
- bounds checking
- row slicing (e.g., arr(0) for first row)
- range slicing (start:stop:step)
- view-based slicing (no data copying)
- advanced indexing (arr({1, 7, 3}) to select reorder these rows)
- addition (+)
- subtraction (-)
- multiplication (*)
- division (/)
- scalar operations
- unary operations (-arr, abs(arr))
- sum()
- min(), max()
- mean()
- std()
- axis-based reductions (e.g., sum(axis=0))
- shape compatibility checking
- broadcasted arithmetic operations
- efficient memory handling for broadcasts
- reshape()
- transpose()
- flatten()
- ravel()
- shared pointer implementation
- view-based operations
- copy-on-write optimization
- boolean masking
- matrix multiplication (matmul/dot)
- simd optimizations
- parallel operations