# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Repository Overview
VectorMatrix is a Rust library for linear algebra operations with small, stack-allocated vectors and matrices using const generics. It has zero dependencies and supports `no_std` environments.
## Build and Development Commands
```bash
# Build
cargo build # Debug build
cargo build --release # Release build
cargo build --no-default-features # Build without std
cargo build --target wasm32-unknown-unknown # Build for WebAssembly
# Testing
cargo test # Run all tests
cargo test -- --nocapture # Run tests with output
cargo test <test_name> # Run specific test
# Linting and Formatting
cargo clippy --no-deps # Run linter (CI uses this)
cargo fmt # Format code
cargo fmt --check # Check formatting (CI uses this)
# Documentation
cargo doc # Generate docs
cargo doc --open # Generate and open docs
```
## Architecture
### Type Structure
- `Vector<T, N>`: N-dimensional vector with const generic size
- `Matrix<T, R, C>`: R×C matrix with const generic dimensions
- `NormalizedVector<T, N>`: Type-safe unit vector
### Key Design Decisions
1. **Column-major storage**: Matrices store data in column-major order internally
2. **Const generics**: Dimensions are compile-time constants for stack allocation
3. **No dependencies**: Pure Rust implementation with optional `std` feature
4. **Specialized implementations**: Optimized algorithms for 2×2, 3×3, and 4×4 matrices
### Trait System
- `Constants`: Provides ZERO and ONE values for numeric types (in `src/types.rs`)
- `Float`: Abstracts floating-point operations (sqrt, sin, cos, approx_eq)
- Both traits use sealed trait pattern for controlled extensibility
### Module Structure
- `src/lib.rs`: Main library exports and trait definitions
- `src/vector.rs`: Vector implementation
- `src/matrix.rs`: Generic matrix implementation
- `src/matrix/m2x2.rs`, `m3x3.rs`, `m4x4.rs`: Specialized matrix implementations
- `src/types.rs`: Trait implementations for standard numeric types