/stdm

Primary LanguageCGNU Lesser General Public License v3.0LGPL-3.0

MassifLib++ (stdm)

A high-performance C library for scientific computing that brings the power of Fortran-style multi-dimensional arrays, NumPy-like operations, and Julia-inspired syntax to C.

Key Features

  • Fortran-style Arrays: Multi-dimensional arrays with column-major memory layout and intuitive A[i,j] indexing
  • NumPy-like Operations: Element-wise operations, slicing, broadcasting, and linear algebra functions
  • Memory Safe: Proper allocation/deallocation routines and bounds checking
  • Efficient Views: Slicing creates views rather than copies for maximum performance
  • Broad Support: Element-wise math, reductions, matrix operations, and more

Quick Start

#include "stdm.h"

int main() {
    // Create a 2x3 array of ones
    int shape[] = {2, 3};
    massif_array A = massif_ones(2, shape);
    
    // Fortran-style indexing
    MASSIF_SET(A, 5.0, 0, 1);  // A[0,1] = 5.0
    double val = MASSIF_GET(A, 0, 1);  // val = 5.0
    
    // Element-wise operations
    massif_array B = massif_full(2, shape, 2.0);
    massif_array C = massif_allocate(2, shape);
    massif_add(&A, &B, &C);  // C = A + B
    
    // Linear algebra
    massif_array result = massif_matmul(&A, &B);
    
    // Clean up
    massif_deallocate(&A);
    massif_deallocate(&B);
    massif_deallocate(&C);
    massif_deallocate(&result);
    
    return 0;
}

## Building

```c
gcc -std=c99 -O3 -lm your_program.c stdm.c -o your_program