A core scientific computing library for Crystal providing n-dimensional tensors, linear algebra, GPU acceleration, and automatic differentiation.
Num.cr is the core scientific computing library for the Crystal programming language. It provides an N-dimensional Tensor data structure, efficient numerical routines, GPU acceleration via OpenCL, and tools for linear algebra and machine learning. It solves the need for high-performance numerical computing within Crystal's type-safe, compiled environment.
Crystal developers and researchers who need to perform numerical computations, data analysis, or build machine learning models directly in the Crystal language.
Developers choose Num.cr because it brings NumPy-like functionality to Crystal, offering a familiar tensor API with the performance benefits of a compiled language, optional GPU acceleration, and a pure-Crystal automatic differentiation system for ML.
Scientific computing in pure Crystal
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides an N-dimensional Tensor with support for slicing, mutation, permutation, and broadcasting, enabling complex numerical computations without unnecessary allocations, as shown in the map and reduce examples.
Tensor operations can be backed by OpenCL for significant performance gains on supported hardware, with creation methods allowing CPU or GPU storage initialization.
Leverages established libraries like BLAS, LAPACK, and ClBlast for robust routines such as matrix inversion and eigenvalue computation, demonstrated in the linear algebra code snippets.
Num::Grad offers gradient computation entirely in Crystal, facilitating machine learning workflows without external dependencies, as illustrated in the backpropagation example.
Requires installation of multiple external libraries like BLAS, LAPACK, OpenCL, and ClBlast for advanced features, which the README admits are necessary for full functionality and can be challenging to configure.
Currently only supports OpenCL for GPU acceleration, missing out on CUDA which is widely used in machine learning, potentially limiting hardware compatibility and performance options.
As a Crystal-specific library, it lacks the extensive community, pre-trained models, and third-party integrations available in Python's scientific computing stack, which may hinder adoption for complex projects.
num.cr is an open-source alternative to the following products: