Skip to content

`libtensr` is a lightweight multi-dimensional tensor library written in C, designed for numerical and linear algebra operations in small-scale projects such as MiniRT. It provides a simple API for creating, managing, and accessing N-dimensional arrays (tensors) with stride-based memory layout.

Notifications You must be signed in to change notification settings

SeanAndrie/libtensr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

libtensr (WIP)

libtensr is a lightweight multi-dimensional tensor library written in C, designed for numerical and linear algebra operations. It provides a simple API for creating, managing, and accessing N-dimensional arrays (tensors) with stride-based memory layout — similar in concept to NumPy arrays, but implemented in pure C.

The library depends on the libft-adapt library, which provides foundational utility functions, and should be placed in the root directory alongside it to ensure proper compilation and linkage.

Current Features

Core Tensor Management

  • Creation of tensors with arbitrary rank and shape
  • Automatic computation of strides (row-major layout only)
  • Element access via indexed lookup
  • Iteration over N-dimensional indices through contextual helpers

Elementwise Operations

  • Generic elementwise operation framework
  • User-defined binary functions supported through callbacks

Shape Handling

  • Infer broadcast-compatible shapes
  • Support broadcasting rules during elementwise operations

Planned Features

Initialization & Data Handling

  • Generate 1-D ranges
  • Clone tensors
  • Import from raw C arrays
  • Export to raw C arrays

Shape Manipulation

  • Reshape tensors without copying
  • Permute dimensions (general transpose)
  • Flatten tensors into 1-D views
  • Squeeze dimensions of size 1
  • Unsqueze/expand dimensions

Mathematical Operations

  • Basic elementwise arithmetic (add, sub, mul, div)
  • Vector dot product
  • Matrix multiplication
  • Norm and normalization functions

About

`libtensr` is a lightweight multi-dimensional tensor library written in C, designed for numerical and linear algebra operations in small-scale projects such as MiniRT. It provides a simple API for creating, managing, and accessing N-dimensional arrays (tensors) with stride-based memory layout.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published