Spartns is a SPARse TeNSor representation library. This project moved to Gitlab
Spartns is a SPARse TeNSor representation library (if you don’t know what a tensor is: they are objects from Multilinear Algebra, which can be represented
as matrices, but with any number of dimensions, not just two). Spartns is distributed under the LLGPL license.
See more information on Spartns here
Features:
One simple example: two dimensional matrix multiplication. First, define a type for 2-dimensional matrices:
(defspartn 2dmatrix
:representation (spartns:hash spartns:cvector)
:non-zero (3 4)
:element-type long-float
:sparse-element 0L0)
The Spartn type “2dmatrix
“ is then defined as the type for sparse tensors that map indices onto long-floats using a hashtable of compressed vectors. When they are created, the hashtables start with :size 3
,
and the compressed vectors with :size 4
. Now, create three matrices, X Y and Z, and multiply them:
(let ((X (make-2dmatrix))
(Y (make-2dmatrix))
(Z (make-2dmatrix)))
(set-2dmatrix X 0 0 5L0)
(set-2dmatrix Y 0 1 6L4)
;; set non-zeros in the rest of the matrices X and Y
;; and now multiply them:
(w/fast-traversals ((2dmatrix X i j val-x)
(2dmatrix Y j k val-y))
(set-2dmatrix Z i k
(+ (get-2dmatrix Z i k) (* val-x val-y)))))