All Projects → owlbarn → eigen

owlbarn / eigen

Licence: MIT license
Owl's OCaml Interface to Eigen3 C++ Library

Programming Languages

C++
36643 projects - #6 most used programming language
ocaml
1615 projects
Cuda
1817 projects

Projects that are alternatives of or similar to eigen

Tensor
A library and extension that provides objects for scientific computing in PHP.
Stars: ✭ 146 (+386.67%)
Mutual labels:  matrix, linear-algebra, tensor
Numeric
N-dimensional matrix class for Rust
Stars: ✭ 51 (+70%)
Mutual labels:  matrix, linear-algebra, tensor
eigen-js
⚡ Eigen-js is a port of the Eigen C++ linear algebra library
Stars: ✭ 78 (+160%)
Mutual labels:  matrix, linear-algebra, eigen
Eigen Git Mirror
THIS MIRROR IS DEPRECATED -- New url: https://gitlab.com/libeigen/eigen
Stars: ✭ 1,659 (+5430%)
Mutual labels:  matrix, linear-algebra, sparse-matrix
monolish
monolish: MONOlithic LInear equation Solvers for Highly-parallel architecture
Stars: ✭ 166 (+453.33%)
Mutual labels:  matrix, linear-algebra, sparse-matrix
Notecalc3
NoteCalc is a handy calculator trying to bring the advantages of Soulver to the web.
Stars: ✭ 879 (+2830%)
Mutual labels:  matrix, linear-algebra
Spmp
sparse matrix pre-processing library
Stars: ✭ 62 (+106.67%)
Mutual labels:  matrix, linear-algebra
Lacaml
OCaml bindings for BLAS/LAPACK (high-performance linear algebra Fortran libraries)
Stars: ✭ 101 (+236.67%)
Mutual labels:  matrix, linear-algebra
Node Sylvester
🐱 Sylvester is a vector, matrix, and geometry library for JavaScript, that runs in the browser and on the server.
Stars: ✭ 144 (+380%)
Mutual labels:  matrix, linear-algebra
Fmatvec
A fast vector/matrix library
Stars: ✭ 5 (-83.33%)
Mutual labels:  matrix, linear-algebra
Numphp
Mathematical PHP library for scientific computing
Stars: ✭ 120 (+300%)
Mutual labels:  matrix, linear-algebra
Mathnet Numerics
Math.NET Numerics
Stars: ✭ 2,688 (+8860%)
Mutual labels:  matrix, linear-algebra
Owl
Owl - OCaml Scientific and Engineering Computing @ http://ocaml.xyz
Stars: ✭ 919 (+2963.33%)
Mutual labels:  matrix, linear-algebra
Cloud Volume
Read and write Neuroglancer datasets programmatically.
Stars: ✭ 63 (+110%)
Mutual labels:  matrix, tensor
Mumps.jl
A Julia Interface to MUMPS
Stars: ✭ 6 (-80%)
Mutual labels:  matrix, linear-algebra
Phpsci Carray
PHP library for scientific computing powered by C
Stars: ✭ 176 (+486.67%)
Mutual labels:  matrix, linear-algebra
Nalgebra
Linear algebra library for Rust.
Stars: ✭ 2,433 (+8010%)
Mutual labels:  matrix, linear-algebra
Peroxide
Rust numeric library with R, MATLAB & Python syntax
Stars: ✭ 191 (+536.67%)
Mutual labels:  matrix, linear-algebra
Lrslibrary
Low-Rank and Sparse Tools for Background Modeling and Subtraction in Videos
Stars: ✭ 625 (+1983.33%)
Mutual labels:  matrix, tensor
Cgmath
A linear algebra and mathematics library for computer graphics.
Stars: ✭ 773 (+2476.67%)
Mutual labels:  matrix, linear-algebra

Eigen - A Thin OCaml Interface to Eigen3 C++ Library

Simply put, Eigen is a very thin OCaml interface to Eigen3 C++ template library. This library is used by another OCaml numerical library -- Owl to provide basic support for both dense and sparse matrix operations.

Even though Eigen3 itself provides a rich set of matrix operations. This OCaml library only interfaces to the most necessary functions needed by Owl library. Therefore, you should only use Owl (which is much more powerful) to perform numerical operations.

To install the library from the source code, execute the following bash command.

make && make install

If you have questions or suggestions, please contact me via Email, LinkedIn, or Twitter.

Optional configuration

You can customise the optimization flags used to compile the C++ libeigen by setting EIGENCPP_OPTFLAGS, the default value is

EIGENCPP_OPTFLAGS = -Ofast -march=native -funroll-loops -ffast-math

Similarly you can customise the optimization flags used to compile the eigen library by setting EIGEN_FLAGS, the default value is

EIGEN_FLAGS = -O3 -Ofast -march=native -funroll-loops -ffast-math

These can be useful if the set of flags is not supported by your system or if you want to use more experimental features

Module Structure

This section is not meant for a tutorial but to help you understand how Eigen's OCaml modules are organised. In case you want to contribute in extending either Eigen or Owl, this would be helpful.

Eigen.Dense.S    (* module of float32 dense matrix *)
Eigen.Dense.D    (* module of float64 dense matrix *)
Eigen.Dense.C    (* module of complex32 dense matrix *)
Eigen.Dense.Z    (* module of complex64 dense matrix *)

The following code snippet creates a complex32 dense identity matrix then prints it out on the standard output.

let x = Eigen.Dense.C.eye 5 in Eigen.Dense.C.print x;;

Polymorphic Functions

The matrix created by each specific module has its own types. For example, Eigen.Sparse.C.create 3 3;; returns Eigen_types.SPMAT_C.c_spmat_c Ctypes.structure Ctypes_static.ptr. Hence a matrix needs to be passed to the functions in the corresponding module to process it.

However, if you want to implement polymorphic function atop of Eigen (e.g., in Owl), Eigen_types module provides some useful constructors to wrap these matrices into generic data types. Here are some examples.

Eigen_types.SPMAT_S (Eigen.Sparse.S.create 3 3);;
Eigen_types.SPMAT_D (Eigen.Sparse.D.create 3 3);;
Eigen_types.SPMAT_C (Eigen.Sparse.C.create 3 3);;
Eigen_types.SPMAT_Z (Eigen.Sparse.Z.create 3 3);;
...
Eigen_types.DSMAT_S (Eigen.Dense.S.create 3 3);;
Eigen_types.DSMAT_D (Eigen.Dense.D.create 3 3);;
Eigen_types.DSMAT_C (Eigen.Dense.C.create 3 3);;
Eigen_types.DSMAT_Z (Eigen.Dense.Z.create 3 3);;
...

Interfacing to C++

Interfacing between C and OCaml is relatively straightforward with Ctypes. However, Eigen3 is developed in C++ and heavily utilises template programming, I first expose the native C++ class methods as individual functions then use Ctypes to generate C stubs and interface to these functions.

The C++ functions are compiled into a static library libeigen.a which is linked using -lstdc++.

Other Information

Some functions in NeuralNetwork folder use the code from Google's Tensorflow hence they are subject to Apache License.

Troubleshooting

After updating x86_64-w64-mingw32-gcc to 11.3.0 you will get some internal compiler error from the C++ compiler. Pinning/downgrading x86_64-w64-mingw32-gcc to 11.2.0 should fix this, it seems to be a strange corner case with gcc compatibility. Hopefully it will be fixed in the next gcc update.

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].