IncliArray
Loading...
Searching...
No Matches
NDArray.h File Reference

NDArray: a minimal NumPy-like N-dimensional float array. More...

#include <functional>
#include <string>
#include <tuple>
#include <unordered_set>
#include <vector>
Include dependency graph for NDArray.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  NDArray
 

Detailed Description

NDArray: a minimal NumPy-like N-dimensional float array.

This header declares the NDArray class, which provides:

  • Row‑major storage with explicit shape and strides
  • Safe element access via multi-index or flat index (when contiguous)
  • Non-owning views via slice (detached from autograd)
  • Reshape for owning, contiguous arrays
  • Broadcasting arithmetic (+, -, /, element-wise multiply)
  • Scalar arithmetic variants
  • 2D matrix multiplication
  • Lightweight reverse‑mode autograd for core ops

Design notes:

  • Memory ownership is explicit. Only base arrays (ownsData == true) allocate and manage their memory. Views never own.
  • Autograd records lightweight operation metadata on results (except slices and clones, which are detached).
  • Slices are detached views by default (no autograd participation). Use clone() to materialize an owning tensor when needed.