All Projects → quil-lang → magicl

quil-lang / magicl

Licence: BSD-3-Clause license
Matrix Algebra proGrams In Common Lisp.

Programming Languages

common lisp
692 projects
fortran
972 projects

Projects that are alternatives of or similar to magicl

mfi
Modern Fortran Interfaces to BLAS and LAPACK
Stars: ✭ 31 (-83.33%)
Mutual labels:  linear-algebra
zalgebra
Linear algebra library for games and real-time graphics.
Stars: ✭ 129 (-30.65%)
Mutual labels:  linear-algebra
hicma
HiCMA: Hierarchical Computations on Manycore Architectures
Stars: ✭ 21 (-88.71%)
Mutual labels:  linear-algebra
Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (-21.51%)
Mutual labels:  linear-algebra
LAML
A stand-alone pure Java library for linear algebra and machine learning
Stars: ✭ 15 (-91.94%)
Mutual labels:  linear-algebra
start-machine-learning
A complete guide to start and improve in machine learning (ML), artificial intelligence (AI) in 2022 without ANY background in the field and stay up-to-date with the latest news and state-of-the-art techniques!
Stars: ✭ 3,066 (+1548.39%)
Mutual labels:  linear-algebra
lubeck
High level linear algebra library for Dlang
Stars: ✭ 57 (-69.35%)
Mutual labels:  linear-algebra
Learn-Machine-Learning-in-3-month
No description or website provided.
Stars: ✭ 35 (-81.18%)
Mutual labels:  linear-algebra
fflas-ffpack
FFLAS-FFPACK - Finite Field Linear Algebra Subroutines / Package
Stars: ✭ 44 (-76.34%)
Mutual labels:  linear-algebra
pbdML
No description or website provided.
Stars: ✭ 13 (-93.01%)
Mutual labels:  linear-algebra
vg
Vector-geometry toolbelt for 3D points and vectors
Stars: ✭ 106 (-43.01%)
Mutual labels:  linear-algebra
sympiler
Sympiler is a Code Generator for Transforming Sparse Matrix Codes
Stars: ✭ 32 (-82.8%)
Mutual labels:  linear-algebra
fml
Fused Matrix Library
Stars: ✭ 24 (-87.1%)
Mutual labels:  linear-algebra
numphp
PHP tools for matrix computation
Stars: ✭ 25 (-86.56%)
Mutual labels:  linear-algebra
float
Single precision (float) matrices for R.
Stars: ✭ 41 (-77.96%)
Mutual labels:  linear-algebra
Introduction-to-Python-Numerical-Analysis-for-Engineers-and-Scientist
Introduction to Python: Numerical Analysis for Engineers and Scientist. In 2017, Python became the world's most popular programming language. This course covers the basic syntax, linear algebra, plotting, and more to prepare students for solving numerical problems with Python.
Stars: ✭ 110 (-40.86%)
Mutual labels:  linear-algebra
pyGameMath
Math library for game programming in python.
Stars: ✭ 20 (-89.25%)
Mutual labels:  linear-algebra
linearmap-family
Purely-functional, coordinate-free linear algebra
Stars: ✭ 22 (-88.17%)
Mutual labels:  linear-algebra
saddle
SADDLE: Scala Data Library
Stars: ✭ 23 (-87.63%)
Mutual labels:  linear-algebra
Undergraduate-in-Statistics
Using Computer with your Statistics Major Course
Stars: ✭ 57 (-69.35%)
Mutual labels:  linear-algebra

MAGICL

Matrix Algebra proGrams In Common Lisp by Rigetti Computing. (née FLAIL: Finally, Linear Algebra In Lisp!)

(Note: The high-level interface is experimental and subject to change.)

Requirements

MAGICL has two main systems:

  • MAGICL/CORE: This is pure Lisp code with no foreign dependencies. This system establishes MAGICL's API (for the most part).

  • MAGICL: This is MAGICL with all extensions loaded.

The system MAGICL/CORE requires:

  • SBCL (> 1.3.19), CCL (>= 1.11) or ECL (>= 20.4.24) on AMD64
  • quicklisp

The system MAGICL, on the other hand, requires several foreign dependencies not shipped with MAGICL, like:

  • libffi
  • BLAS and LAPACK

Detailed instructions on how to install libffi and BLAS/LAPACK can be found here.

Currently this library is SBCL-, CCL- and ECL-only. The non-portable code is in with-array-pointers.lisp and magicl.lisp.

Installation

First ensure you have the necessary requirements installed, as described in the previous section.

To install MAGICL, clone this repository into your Quicklisp's local-projects folder. You can quickly check where this is by running sbcl and evaluating ql:*local-project-directories*. Once installed, confirm that MAGICL is working properly by running the tests, as described in the next section.

Lisp-Only vs Accelerated MAGICL

Extensions

MAGICL/CORE only uses pure ANSI Common Lisp code. If you wish to accelerate it or extend the functionality, you may load MAGICL extensions. These extensions typically install new backends to MAGICL functions. The available extensions are:

  • MAGICL/EXT-BLAS: for BLAS functions
  • MAGICL/EXT-LAPACK: for LAPACK functions
  • MAGICL/EXT-EXPOKIT: for expokit (matrix exp()) functions

For backwards compatibility, MAGICL loads every extension under the kitchen sink. This may change in future versions of MAGICL! If you depend on an extension, depend on it explicitly!

If you use extensions, you'll need the requisite C/Fortran libraries. Expokit will automatically build for you, as its source is included in the distribution of MAGICL.

Backends

Accelerated functionality is installed with a notion called "backends". A backend is a name of a group of functionality, typically denoted by a symbol or keyword. The :lisp backend is the default one, and several backends can be active all at once. Each extension above adds a new backend. The current backends are:

  • :lisp: Pure Lisp code
  • :blas: BLAS-backed code
  • :lapack: LAPACK-backed code
  • :expokit: expokit-backed code

In most cases, one does not need to concern themselves with backends; MAGICL functionality should "just work" and dispatch to the appropriate backend. However, the programmer always has control, even dynamically in the program, of which backends should be used at a given time with the magicl.backends:with-backends macro. For instance,

(magicl.backends:with-backends (:blas :lisp)
  ;; ... code ...
  )

says that the code should be executed, always preferring :blas-accelerated functions, and using :lisp-implemented functions as a fall-back.

(magicl.backends:with-backends (:lisp)
  ;; ... code ...
  )

says to only use :lisp-implemented functions, even if other backends are loaded.

The active backends can be found with the function magicl.backends:active-backends, which lists the backends to use in priority order.

One can be even finer-grained than with-backends. Given a function f which has many backend implementations, one can get a specific implementation by using the function:

(magicl.backends:backend-implementation 'f :backend-name)

For instance

(magicl.backends:backend-implementation 'magicl:csd :lapack)

will give the implementation of the cosine-sine decomposition function in LAPACK. This can be called in exactly the same way magicl:csd can be called.

In backend-implementation, if both the function name and the backend name are (quoted) constants, this will be looked up at compile-time, which is useful for writing efficient code that does not dispatch. But note that by doing this, with-backends will not be respected.

Testing MAGICL

You can run the MAGICL tests from your Lisp REPL with:

(asdf:test-system :magicl)

You currently need all of the extensions working for the tests to run.

High-level Interface

See the high-level doc for an extensive discussion and comparison of MAGICL functions with those of MATLAB and NumPy.

Developer's Guide: How to Add New Functions

See the developer how-to to understand how to add new functionality to MAGICL.

Fortran Bindings

See the Fortran Functions on how to re-generate the Fortran bindings from the original BLAS, LAPACK, and Expokit reference code.

See the same document for how to query for available Fortran functions in the currently loaded dynamic libraries.

History and Credits

MAGICL development started at Rigetti Computing by Robert Smith and Joe Lin in 2017.

CL-BLAPACK is a library developed by Ryan Rifkin and Evan Monroig. Rigetti Computing created a fork of this library and renamed it MAGICL, and made significant changes that departed from the original design, including:

  • Fixing several bugs in the Fortran parsing to make it work with the latest reference BLAS and LAPACK, leading to significant refactoring.

  • Adding support for matrix exponentiation with Expokit.

  • Adding support for loading various BLAS and LAPACK implementations.

  • Removing the use of the FNV library in favor of native Lisp arrays.

  • Adding a high-level interface to various functions.

  • Adding function availability reporting.

The most important common design decision between CL-BLAPACK and MAGICL is allowing direct access to the Fortran library functions by way of automatically generated Lisp bindings from the reference sources.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].