Metadata-Version: 2.4
Name: zanpy
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Topic :: Scientific/Engineering :: Mathematics
Summary: A high-performance N-dimensional array library built in Rust for macOS.
Keywords: matrix,rust,simd,ndarray,math
Author-email: Santiago Zanoni <santiagozanoni08@gmail.com>
License: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/Mersautschip/zanpy


# 🚀 Zanpy

**Zanpy** is a high-performance N-dimensional array library built in **Rust** with a seamless **Python** interface. It leverages SIMD (Single Instruction, Multiple Data) and cache-efficient memory layouts to provide blazing-fast linear algebra operations.

---

## ✨ Features

* **Native Rust Engine:** Memory-safe, high-speed core implementation.
* **SIMD Acceleration:** Matrix multiplication optimized with `wide` SIMD types (f64x2) and $i, k, j$ loop reordering.
* **N-Dimensional Support:** Sophisticated broadcasting for arrays up to 8 dimensions.
* **Numpy-Compatible:** Familiar Python syntax for `reshape`, `transpose`, `arange`, and `identity`.
* **Linear Algebra:** Built-in LU decomposition for matrix inversion and dot product support.

---

## 📦 Installation

To install the latest release via `pip`:

```bash
pip install zanpy
````

*Note: For local development, see the [Development](https://www.google.com/search?q=%23development) section.*

-----

## 🛠 Usage

### Basic Array Creation

```python
import zanpy

# Create a 2x2 identity matrix
identity = zanpy.PyNdArray.identity(2)

# Create an array from a range and reshape it
a = zanpy.PyNdArray.arange(0, 4, 1).reshape([2, 2])
```

### Arithmetic & Broadcasting

```python
b = zanpy.PyNdArray.ones([2, 2])

# Element-wise addition using the + operator
c = a + b

# Matrix Multiplication using the @ operator
d = a @ identity
```

### Reductions & Math

```python
print(f"Matrix Sum: {a.sum()}")
print(f"Matrix Mean: {a.mean()}")
print(f"Matrix Max: {a.max()}")

# Invert a square matrix
a_inv = a.inv()
```

-----

## 🏗 Architecture

Zanpy is architected for speed by separating the math logic from the Python glue:

1.  **`zanpy-core`**: The standalone Rust crate. It manages the `NdArray` struct, calculating memory offsets via strides and executing raw SIMD math.
2.  **`zanpy-py`**: The bridge crate. Uses **PyO3** and **Maturin** to expose Rust functionality as a Python module.

### Why it's fast

The `mat_mul` implementation avoids the "cache-miss" penalty of naive triple-nested loops by using an $i, k, j$ traversal. This ensures that the CPU accesses memory in a linear, predictable fashion, maximizing cache hits.

-----

## 🛠 Development

### Prerequisites

  * **Rust** (1.70+ recommended)
  * **Python** (3.9+)
  * **Maturin** (`pip install maturin`)

### Building from Source

```bash
# Clone the repository
git clone [https://github.com/yourusername/zanpy.git](https://github.com/yourusername/zanpy.git)
cd zanpy

# Compile and install in your current virtual environment
cd crates/zanpy-py
maturin develop --release
```

### Testing

```bash
# Run Rust unit tests
cargo test

# Run Python integration tests
pytest tests/
```

-----

## 📜 License

Distributed under the MIT License. See `LICENSE` for more information.


