A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bharath1097/matlisp/ below:

bharath1097/matlisp: Matlisp, incorporating multiindex datastructures (tensor-branch).

MatLisp is intended to be a base library for scientific computation in Lisp. This is the development branch of Matlisp.

Lisp is a wonderful language for explorative computing, but lacks general tools for numerical computing, whilst MATLAB/Numpy are excellent for certain tasks but are less well adopted for other tasks. Lisp however allows interesting new constructs without being tied down to a particular language vendor, for instance we use ‘/’ as both a binary and unary operator (like ‘-‘), so that,

solves the matrix equation $A x = b$ . What’s more, it’s extremely simple to define your own syntax by tweaking “src/reader/infix.lisp”. What’s more, with implementations such as SBCL, the code generated by Matlisp tends to be very competitive with equivalent C code. For instance,

> (defun mm (A B C)
    (einstein-sum real-tensor (j k i) (ref C i j) (* (ref A i j) (ref B j k))))

basically generates an extremely tight naive 3-loop version of GEMM (exercise: why ‘j k i’ ?), which is only about 10 times as slow the optimized version of GEMM in OpenBLAS, and about 20% slower than the naive 3-loop version in C.

Matlisp also switches dynamically between BLAS routines (when available) and native lisp code to avoid FFI overheads. This also means that, BLAS functionality of Matlisp can be used (with minimal tweaking) either without a BLAS library, or for commutative-rings which don’t have a BLAS version available.

Matlisp uses CFFI for callng foreign functions. That said, the FFI capabilities of different lisps are quite different. So if your Lisp implementation supports callbacks and calling plain C functions and maps float simple-arrays into C-type arrays in memory, it shouldn’t be too hard to get it working (if it doesn’t work already). We’ve tested Matlisp on CCL and SBCL. The build system is cranky with all the new changes.

> git clone git@github.com:matlisp/matlisp.git 
> ln -s $PWD/matlisp <quicklisp-directory>/local-projects

Fire up your lisp implementation and load as usual with quicklisp:

CL-USER> (ql:quickload :matlisp)
CL-USER> (in-package :matlisp)
MATLISP> (in-readtable :infix-dispatch-table)

The fortran libraries provided by matlisp earlier are now part of matlisp-packages.

More documentation will be added as things reach a nicer stage of development.

;;Creation
MATLISP> (copy! (randn '(2 2)) (zeros '(2 2) 'complex-tensor))
#<COMPLEX-TENSOR #(2 2)
-1.5330     -1.67578E-2
-.62578     -.63278
>

;;gemv
MATLISP> (let ((a (randn '(2 2)))
		 (b (randn 2)))
	     #i(a * b))
#<REAL-TENSOR #(2)
1.1885     0.95746
>

;;Tensor contraction
MATLISP> (let ((H (randn '(2 2 2)))
		 (b (randn 2))
		 (c (randn 2))
		 (f (zeros 2)))
	     (einstein-sum real-tensor (i j k) (ref f i) (* (ref H i j k) (ref b j) (ref c k))))
#<REAL-TENSOR #(2)
0.62586     -1.1128
>

Things are currently done using the iter slice macro (and mapslice*’s), mod-dotimes, and einstein-loop generator. The more elegant course to take would be unify these with a nice syntactic glue; sadly as far I know this hasn’t been done before. This will require quite a bit of prototyping.

(C)Python has far too many things, that we cannot even begin to hope to replicate. Burgled-batteries has a lot of things which could be useful in talking to CPython.

Getting standard-tensor <-> numpy tranlation should be enough. Mostly care about matplotlib at the moment.

Support linking to libraries ?

Parse header files with cffi-grovel.

Symbolics, AD, more fancy stuff {wishlist}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4