-
Project: matrico (Esperanto for "matrix")
-
Summary: A flonum matrix module for CHICKEN Scheme.
-
Authors: Christian Himpe (0000-0003-2194-6754)
-
License: zlib-acknowledgement
-
Version: 0.7 (2024-11-??)
-
Depends: CHICKEN Scheme (>= 5.1)
-
Website: http://numerical-schemer.xyz (Development Blog)
-
Reference: http://wiki.call-cc.org/eggref/5/matrico (User Reference)
-
Repository: https://github.com/gramian/matrico (Developer Documentation)
-
Category: math (numerical mathematics)
-
Audience: MATLAB, Octave, Scilab, Julia, NumPy (Python) users
-
Wikidata: https://www.wikidata.org/wiki/Q113997718
-
Container: https://hub.docker.com/r/gramian/matrico
matrico
is a Scheme module for numerical matrix computations encapsulated in a CHICKEN Scheme egg.
docker run -it gramian/matrico
./matrico.sh
CHICKEN_INSTALL_REPOSITORY="/my/egg/directory/" chicken-install -test matrico
CHICKEN_REPOSITORY_PATH="`chicken-install -repository`:/my/egg/directory/" csi
./RUNME.sh
csi demos/heat.scm
csi demos/flame.scm
matrico
is a ...
-
... matrix-based numerical computing environment for, and fully written in, Scheme.
-
... self-contained implementation with minimal dependencies.
-
... numerical linear algebra code with functional back-end design.
-
Provide more numerical capabilities to CHICKEN Scheme community.
-
Contribute scientific computing knowledge as Scheme code.
-
Educational project for author and readers.
-
Provide dense two-dimensional arrays (matrix) of floating-point numbers (flonum) for CHICKEN Scheme.
-
Provide linear algebra and typical calculator functions for matrices.
-
Use only included modules of CHICKEN Scheme.
-
A matrix is a list of (homogeneous) vectors.
-
A matrix uses column-major ordering of entries.
-
A matrix uses one-based indexing.
-
A matrix can only have real-valued flonum entries.
-
Everything is a matrix, particularly, matrixes are incompatible with Scheme's (homogeneous) vectors.
-
Matrix transformations are based on functional map-reduce approach.
-
Common Lisp MatLisp
-
Common Lisp Lisplab
-
Common Lisp CLEM
-
Chez Scheme chez-matrices
-
Racket math/matrix
-
Racket flomat
-
Clojure core.matrix
matrico
Modulemx
Library (User-Facing Matrix Frontend)dense
Module (Column Interface Specialization)matrix
Functor (Functional Matrix Backend)f64vector
Module (Homogeneous Flonum Vector Functions)fpmath
Module (User-Facing Additional Flonum Functions)utils
Module (Additional Foundational Functions)
- Extra Tools
check
Library (Testing Helper Functions)
User-Facing Function Reference (click to expand)
-
(matrico)
returns void, prints help message formatrico
function. -
(matrico sym)
returns any, depending on argument symbolsym
:'list
- returns void, prints list of "mx
" functions;'about
- returns void, prints summary aboutmatrico
;'banner
- returns void, prints thematrico
banner;'version
- returns pair holding major and minor version numbers ofmatrico
;'citation
- returns void, prints citation information formatrico
;'benchmark
- returns fixnum, prints approximated million-instructions-per-second for current machine;- otherwise - returns boolean answering if argument is a symbol matching an existing function, starting with "
mx
", and prints its docstring.
-
(mx rows cols val)
returnsrows
-by-cols
matrix with all entries set to flonumval
for positive fixnumsrows
andcols
. -
(mx% lst)
returns matrix from row-major list-of-lists-of-flonumslst
. -
(mx-identity dims)
returnsdims
-by-dims
identity matrix for a positive fixnumdims
. -
(mx-exchange dims)
returnsdims
-by-dims
exchange matrix for a positive fixnumdims
. -
(mx-hilbert dims)
returnsdims
-by-dims
Hilbert matrix for a positive fixnumdims
. -
(mx-pascal dims)
returnsdims
-by-dims
(lower triangular) Pascal matrix for a positive fixnumdims
. -
(mx-lehmer rows cols)
returnsrows
-by-cols
Lehmer matrix for the positive fixnumsrows
andcols
. -
(mx-random rows cols low upp)
returnsrows
-by-cols
uniformly distributed random matrix in the interval flonumlow
to flonumupp
for the positive fixnumsrows
andcols
. -
(mx-tridiag dims low mid upp)
returnsdims
-by-dims
matrix with lower, main, upper band entries given by the flonumslow
,mid
,upp
for a positive fixnumdims
. -
(mx-unit dims num)
returnsdims
-by-one column-matrix of zeros except the positive fixnumnum
-th entry set to one, for a positive fixnumdims
, aka canonical base vector. -
(mx-iota dims)
returnsdims
-by-one column-matrix with entries set to corresponding row index for a positive fixnumdims
. -
(mx-linspace x y num)
returns matrix of positive fixnumnum
row-wise linearly spaced entries with endpoints given by flonums or column-matrix
esx
andy
. -
(mx-logspace x y num)
returns matrix of positive fixnumnum
row-wise (base-10) logarithmic spaced entries with endpoints given by flonums or column-matrixesx
andy
.
-
(mx-cols mat)
returns fixnum number of columns of matrixmat
. -
(mx-rows mat)
returns fixnum number of rows of matrixmat
. -
(mx-numel mat)
returns fixnum number of entries of matrixmat
. -
(mx-dims mat)
returns fixnum number of dimensions of matrixmat
.
-
(mx? any)
returns boolean answering ifany
is a matrix. -
(mx-col? mat)
returns boolean answering if matrixmat
has only a single column. -
(mx-row? mat)
returns boolean answering if matrixmat
has only a single row. -
(mx-scalar? mat)
returns boolean answering if matrixmat
has only a single row and single column. -
(mx-vector? mat)
returns boolean answering if matrixmat
has only a single row or single column. -
(mx-square? mat)
returns boolean answering if matrixmat
has the same number of rows and columns. -
(mx-samecols? x y)
returns boolean answering if matrixesx
andy
have same number of columns. -
(mx-samerows? x y)
returns boolean answering if matrixesx
andy
have same number of rows. -
(mx-samedim? x y)
returns boolean answering if matrixesx
andy
have same number of columns and rows. -
(mx-any? pred mat)
returns boolean answering if any entry of matrixmat
fulfills predicate procedurepred
. -
(mx-all? pred mat)
returns boolean answering if all entries of matrixmat
fulfill predicate procedurepred
. -
(mx=? x y tol)
returns boolean answering if all entry-wise distances between matrixesx
andy
are below tolerance flonumtol
.
-
(mx-ref11 mat)
returns flonum being the top, left entry of matrixmat
. -
(mx-ref mat row col)
flonum being matrixmat
entry in row and column specified by positive fixnumsrow
,col
. -
(mx-set mat row col val)
returns matrix copy of matrixmat
but with entry in row fixnumrow
and column fixnumcol
set to flonum or one-by-one matrixval
. -
(mx-set! mat row col val)
returns void, sets entry of matrixmat
in row and column specified by positive fixnumsrow
andcol
to flonum or one-by-one matrixval
. -
(mx-col mat col)
returns matrix being matrixmat
's column specified by positive fixnumcol
. -
(mx-row mat row)
returns matrix being matrixmat
's row specified by positive fixnumrow
. -
(mx-diag mat)
returns column-matrix holding matrixmat
's diagonal entries. -
(mx-submatrix mat row1 row2 col1 col2)
returns matrix holding entries of matrixmat
in rows specified by positive fixnumsrow1
torow2
and columns specified by positive fixnumscol1
tocol2
.
-
(mx+ x y)
returns matrix of entry-wise addition of matrixesx
andy
. -
(mx* x y)
returns matrix of entry-wise multiplication of matrixesx
andy
. -
(mx- x y)
returns matrix of entry-wise subtraction of matrixesx
andy
. -
(mx/ x y)
returns matrix of entry-wise division of matrixesx
byy
. -
(mx^ x y)
returns matrix of entry-wise exponentiation of matrixesx
to they
. -
(mx-where pred x y)
returns matrix of entries of matrixesx
ory
based on predicate procedurepred
.
-
(mx- x)
returns matrix of entry-wise negation of matrixx
. -
(mx/ x)
returns matrix of entry-wise reciprocal of matrixx
. -
(mx*2 x)
returns matrix of entry-wise doubling of matrixx
. -
(mx^2 x)
returns matrix of entry-wise squaring of matrixx
.
-
(mx-round mat)
returns matrix with entries of matrixmat
rounded to nearest integer. -
(mx-floor mat)
returns matrix with entries of matrixmat
rounded to nearest upper integer. -
(mx-ceil mat)
returns matrix with entries of matrixmat
rounded to nearest lower integer.
-
(mx-abs mat)
returns matrix with entry-wise absolute value of matrixmat
. -
(mx-sign mat)
returns matrix with entry-wise sign of matrixmat
. -
(mx-delta mat)
returns matrix with entry-wise Kronecker delta of matrixmat
. -
(mx-heaviside mat)
returns matrix with entry-wise Heaviside step of matrixmat
.
-
(mx-sin mat)
returns matrix with entry-wise sine of matrixmat
. -
(mx-cos mat)
returns matrix with entry-wise cosine of matrixmat
. -
(mx-tan mat)
returns matrix with entry-wise tangent of matrixmat
.
-
(mx-asin mat)
returns matrix with entry-wise inverse sine of matrixmat
, aka arcsine. -
(mx-acos mat)
returns matrix with entry-wise inverse cosine of matrixmat
, aka arccosine. -
(mx-atan mat)
returns matrix with entry-wise inverse tangent of matrixmat
, aka arctangent.
-
(mx-sinh mat)
returns matrix with entry-wise hyperbolic sine of matrixmat
. -
(mx-cosh mat)
returns matrix with entry-wise hyperbolic cosine of matrixmat
. -
(mx-tanh mat)
returns matrix with entry-wise hyperbolic tangent of matrixmat
.
-
(mx-asinh mat)
returns matrix with entry-wise inverse hyperbolic sine of matrixmat
, aka area hyperbolic sine. -
(mx-acosh mat)
returns matrix with entry-wise inverse hyperbolic cosine of matrixmat
, aka area hyperbolic cosine. -
(mx-atanh mat)
returns matrix with entry-wise inverse hyperbolic tangent of matrixmat
, aka area hyperbolic tangent.
-
(mx-hsin mat)
returns matrix with entry-wise haversed sine of matrixmat
. -
(mx-hcos mat)
returns matrix with entry-wise haversed cosine of matrixmat
.
-
(mx-lnsinh mat)
returns matrix with entry-wise log-sinh of matrixmat
. -
(mx-lncosh mat)
returns matrix with entry-wise log-cosh of matrixmat
.
-
(mx-sqrt mat)
returns matrix with entry-wise square root of matrixmat
. -
(mx-signsqrt mat)
returns matrix with entry-wise sign times square-root of absolute value of matrixmat
.
-
(mx-ln mat)
returns matrix with entry-wise natural logarithm of matrixmat
. -
(mx-lb mat)
returns matrix with entry-wise base-2 logarithm of matrixmat
. -
(mx-lg mat)
returns matrix with entry-wise base-10 logarithm of matrixmat
.
-
(mx-exp mat)
returns matrix with entry-wise exponential of matrixmat
. -
(mx-gauss mat)
returns matrix with entry-wise Gaussian of matrixmat
.
-
(mx-sinc mat)
returns matrix with entry-wise cardinal sine of matrixmat
. -
(mx-sigm mat)
returns matrix with entry-wise sigmoid of matrixmat
. -
(mx-stirling mat)
returns matrix with entry-wise Stirling approximation of matrixmat
.
-
(mx-rowsum mat)
returns column-matrix of summing row entries of matrixmat
. -
(mx-colsum mat)
returns row-matrix of summing column entries of matrixmat
. -
(mx-sum mat)
returns flonum of summing all entries of matrixmat
.
-
(mx-rowprod mat)
returns column-matrix of multiplying row entries of matrixmat
. -
(mx-colprod mat)
returns row-matrix of multiplying column entries of matrixmat
. -
(mx-prod mat)
returns flonum of multiplying all entries of matrixmat
.
-
(mx-rowmin mat)
returns column-matrix of row-wise minima of matrixmat
. -
(mx-colmin mat)
returns row-matrix of column-wise minima of matrixmat
. -
(mx-min mat)
returns flonum minimum of all matrixmat
entries.
-
(mx-rowmax mat)
returns column-matrix of row-wise maxima of matrixmat
. -
(mx-colmax mat)
returns row-matrix of column-wise maxima of matrixmat
. -
(mx-max mat)
returns flonum maximum of all matrixmat
entries.
-
(mx-rowmidr mat)
returns column-matrix of row-wise midrange of matrixmat
. -
(mx-colmidr mat)
returns row-matrix of column-wise midrange of matrixmat
. -
(mx-midr mat)
returns flonum midrange of all matrixmat
entries.
-
(mx-rowmean mat typ)
returns column-matrix of row-wise power means of matrixmat
of type symboltyp
, which can be-1
,0
,1
,2
, or'inf
. -
(mx-colmean mat typ)
returns row-matrix of column-wise power means of matrixmat
of type symboltyp
, which can be-1
,0
,1
,2
, or'inf
. -
(mx-mean mat typ)
returns flonum power mean of all matrixmat
entries of type symboltyp
, which can be-1
,0
,1
,2
, or'inf
.
-
(mx-rownorm mat typ)
returns column-matrix of row-wise matrix norms of matrixmat
of type symboltyp
, which can be1
,2
, or'inf
. -
(mx-colnorm mat typ)
returns row-matrix of column-wise matrix norms of matrixmat
of type symboltyp
, which can be1
,2
, or'inf
. -
(mx-norm mat typ)
returns flonum matrix norms of matrixmat
of type symboltyp
, which can be1
,'inf
,'fro
, or'max
.
-
(mx-horcat x y)
returns matrix of horizontally concatenated matrixesx
andy
. -
(mx-vercat x y)
returns matrix of vertically concatenated matrixesx
andy
. -
(mx-vec mat)
returns matrix of vertically concatenated columns of matrixmat
, aka vectorization. -
(mx-transpose mat)
returns matrix of entries of matrixmat
with swapped row and column indices. -
(mx-axpy a x y)
returns matrix of entry-wise generalized addition of flonuma
times matrixx
plus matrixy
, aka "a times x plus y". -
(mx-sympart mat)
returns matrix being symmetric part of square matrixmat
. -
(mx-skewpart mat)
returns matrix being skey-symmetric part of square matrixmat
, aka anti-symmetric part. -
(mx-diagonal mat)
returns diagonal matrix from column matrixmat
.
-
(mx-qr mat)
returns pair of orthogonal matrix Q and upper right triangular matrix R factoring full column rank matrixmat
, via QR. -
(mx-solver mat)
returns function returning column-matrix solving the linear (least-squares) problem of matrixmat
, given a column-matrixvec
. -
(mx-solve mat vec)
returns column-matrix solving the linear (least-squares) problem of matrixmat
and column-matrixvec
. -
(mx-orth mat)
returns matrix orthogonalizing matrixmat
. -
(mx-absdet mat)
returns flonum being absolute value of the determinant of matrixmat
. -
(mx-logdet mat)
returns flonum being the (natural) logarithm of the determinant of matrixmat
.
-
(mx-trace mat)
returns flonum being sum of square matrixmat
diagonal entries. -
(mx-multrace mat)
returns flonum being product of square matrixmat
diagonal entries. -
(mx-prodtrace* x yt)
returns flonum being the trace of the matrix product of matrixx
and transposed matrixyt
. -
(mx-prodtrace x y)
returns flonum being the trace of the matrix product of matrixesx
andy
.
-
(mx-scalar xt y)
returns flonum resulting from scalar product of column-matrixesxt
andy
. -
(mx-dyadic x y)
returns flonum resulting from dyadic product of column-matrixx
and row-matrixy
. -
(mx-dot* xt y)
returns matrix resulting from matrix multiplication of transposed matrixxt
and matrixy
. -
(mx-dot x y)
returns matrix resulting from matrix multiplication of matrixesx
andy
. -
(mx-gram mat)
returns matrix resulting from matrix multiplication of (transposed) matrixmat
with itself, aka Gram matrix. -
(mx-gram* mat)
returns matrix resulting from matrix multiplication of matrixmat
with itself transposed. -
(mx-square mat)
returns matrix resulting from matrix multiplication of matrixmat
with itself.
-
(mx-xcov x y)
returns matrix of cross-covariances of matrixesx
andy
, representing columns of observations. -
(mx-cov mat)
returns matrix of covariances of matrixmat
, representing columns of observations. -
(mx-var mat)
returns column matrix of variances of matrixmat
, representing columns of observations. -
(mx-std mat)
returns column matrix of standard deviations of matrixmat
, representing columns of observations. -
(mx-xcor x y)
returns matrix of cross-correlations of matrixesx
andy
, representing columns of observations. -
(mx-cor mat)
returns matrix of correlations of matrixmat
, representing columns of observations. -
(mx-angle x y)
returns matrix of angles between matrixesx
andy
, representing columns of observations. -
(mx-coher x y)
returns flonum of distance coherence between matrixesx
andy
.
-
(mx-diff mat)
returns matrix of differences of consecutives columns of matrixmat
. -
(mx-trapz mat)
returns column-matrix trapezoid approximate integral of matrixmat
being columns data-points of rows-dimensional function. -
(mx-ode2-hyp num sys tim x0)
states-times-steps matrix trajectory solving an ordinary differential equation, by a 2nd order hyperbolic Runge-Kutta method of fixnumnum
stages, with vector field procedure or pair of vector field and output proceduressys
, time step flonum and time horizon flonum in pairtim
, initial state column-matrixx0
. -
(mx-ode2-ssp num sys tim x0)
states-times-steps matrix trajectory solving an ordinary differential equation, by a 2nd order strong stability preserving Runge-Kutta method of fixnumnum
stages, with vector field procedure or pair of vector field and output proceduressys
, time step flonum and time horizon flonum in pairtim
, initial state column-matrixx0
.
-
(mx->list mat)
returns list of entries of one-dimensional matrixmat
. -
(mx-print mat)
returns void, prints matrixmat
to terminal. -
(mx-export str mat . sep)
void, writes matrixmat
to new charactersep
-separated-value file in relative path stringstr
, by defaultsep
is,
resulting in CSV. -
(mx-save str mat)
returns void, writes matrixmat
to new Scheme (SCM) file in relative path stringstr
. -
(mx-load str)
returns matrix loaded from SCM file in relative path stringstr
.
The matrico module implicitly exports the (chicken flonum) module, as well as the following additional flonum
operations:
-
fp
is alias forexact->inexact
. -
(fp% n d)
returns flonum fraction with numerator fixnumn
and denominator fixnumd
. -
(fpzero?? x)
returns boolean answering if flonumx
is exactly zero. -
(fpzero? x tol)
returns boolean answering if absolute value of flonumx
is less than flonumtol
. -
(fp*2 x)
returns flonum double of flonumx
. -
(fp^2 x)
returns flonum square of flonumx
. -
(fprec x)
returns flonum reciprocal of flonumx
. -
(fptau)
returns flonum circle constant Tau via fraction. -
(fpeul)
returns flonum Euler's number via fraction. -
(fpphi)
returns flonum golden ratio via fraction of consecutive Fibonacci numbers. -
(fpdelta x)
returns flonum Kronecker delta of flonumx
. -
(fpheaviside x)
returns flonum Heaviside step function of flonumx
. -
(fpsign x)
returns flonum sign of flonumx
. -
(fpln x)
returns flonum natural logarithm of flonumx
. -
(fplb x)
returns flonum base-2 logarithm of flonumx
. -
(fplg x)
returns flonum base-10 logarithm of flonumx
. -
(fphsin x)
returns flonum haversed sine of flonumx
. -
(fphcos x)
returns flonum haversed cosine of flonumx
. -
(fplnsinh x)
returns flonum log-sinh of flonumx
. -
(fplncosh x)
returns flonum log-cosh of flonumx
. -
(fpsignsqrt x)
returns flonum sign times square root of absolute value of flonumx
. -
(fpsinc x)
returns flonum cardinal sine function with removed singularity of flonumx
. -
(fpsigm x)
returns flonum standard logistic function of flonumx
, aka sigmoid. -
(fpgauss x)
returns flonum Gauss bell curve function evaluation of flonumx
. -
(fpstirling x)
returns flonum Stirling approximation of factorial of flonumx
.
Developer Function Reference (click to expand)
-
(matrix-or-flonum? val)
returns boolean answering if argumentval
is a flonum or matrix. -
(scalar-or-flonum? val)
returns boolean answering if argumentval
is a flonum or scalar matrix. -
(column-or-flonum? val)
returns boolean answering if argumentval
is a flonum or column matrix. -
(ensure-mx val)
returns one-by-one matrix ifval
is flonum, orval
ifval
is matrix. -
(ensure-fp val)
returns flonum ifval
is flonum, or element ifval
is one-by-one matrix. -
(translate-cols idx)
returns fixnum for matrixmat
translated column index fixnumidx
(from 1-based to 0-based and from end). -
(translate-rows idx)
returns fixnum for matrixmat
translated row index fixnumidx
(from 1-based to 0-based and from end). -
(time-stepper typ sys tim x0)
states-times-steps matrix trajectory solving an ordinary differential equation, by method proceduretyp
, with vector field procedure or vector field and output function pair-of-proceduressys
, time step and time horizon pair-of-flonumstim
, initial state column-matrixx0
.
Defines the matrix type (record) as column-major list-of-columns and provides generic basic and functional methods wrapped in a functor
-
(matrix-data mat)
returns list-of-columns, generated bydefine-record
. -
(matrix? any)
returns boolean answering ifany
is a matrix, generated bydefine-record
. -
(make-matrix cols lst)
returns matrix from listlst
of columns and fixnum numbercols
of columns, generated bydefine-record
. -
(make-matrix* rows cols val)
returnsrows
-by-cols
matrix with all entries set toval
for fixnumsrows
,cols
. -
(make-matrix** lst)
returns matrix from row-major list-of-listslst
. -
(matrix-generate fun rows cols)
returnsrows
-by-cols
matrix generated procedurally from applying procedurefun
(one-based), fixnumsrows
,cols
. -
(matrix-horcat . mat)
returns matrix of horizontally concatenating matrixes from list-ofmatrixesmat
. -
(matrix-vercat . mat)
returns matrix of vertically concatenating matrixes from list-of-matrixesmat
. -
(matrix-cols mat)
returns fixnum number of columns of matrixmat
, generated bydefine-record
. -
(matrix-rows mat)
returns fixnum number of rows of matrixmat
. -
(matrix-numel mat)
returns fixnum number of entries of matrixmat
. -
(matrix-dims mat)
returns fixnum number of dimensions of matrixmat
. -
(matrix-ref00 mat)
returns: any being the entry of matrixmat
in the first row and first column. -
(matrix-ref*0 mat row)
returns any being matrixmat
entry in fixnumrow
and the first column. -
(matrix-ref mat row col)
returns any being matrixmat
entry in fixnumrow
and fixnumcol
umns. -
(matrix-set mat row col val)
returns matrix copy of matrixmat
but with entry in row fixnumrow
and column fixnumcol
set toval
. -
(matrix-set! mat row col val)
returns any, sets entry of matrixmat
in row fixnumrow
and column fixnumcol
toval
. -
(matrix-col mat col)
returns matrix being matrixmat
column specified by fixnumcol
. -
(matrix-row mat row)
returns matrix being matrixmat
row specified by fixnumrow
. -
(matrix-diag mat)
returns matrix holding matrixmat
diagonal entries as column-matrix. -
(matrix-submatrix mat row1 row2 col1 col2)
returns matrix holding entries of matrixmat
from rows fixnumsrow1
torow2
in columns fixnumscol1
tocol2
. -
(matrix-col? mat)
returns boolean answering if matrixmat
has only a single column. -
(matrix-row? mat)
returns boolean answering if matrixmat
has only a single row. -
(matrix-scalar? mat)
returns boolean answering if matrixmat
has only a single row and single column, aka scalar. -
(matrix-vector? mat)
returns: boolean answering if matrixmat
has only a single row or single column, aka vector. -
(matrix-square? mat)
returns boolean answering if matrixmat
has the same number of rows and columns. -
(matrix-samecols? mat)
returns boolean answering if matrixesx
andy
have same number of columns. -
(matrix-samerows? mat)
returns boolean answering if matrixesx
andy
have same number of rows. -
(matrix-samedims? mat)
returns boolean answering if matrixesx
andy
have same number of columns and rows. -
(matrix-any? pred mat)
returns boolean answering if any entry of matrixmat
fulfills predicate procedurepred
. -
(matrix-all? pred mat)
returns boolean answering if all entries of matrixmat
fulfill predicate procedurepred
. -
(matrix-colfold fun ini mat)
returns row matrix resulting from folding by two-argument procedurefun
each column of matrixmat
. -
(matrix-rowfold fun ini mat)
returns column matrix resulting from folding by two-argument procedurefun
each row of matrixmat
. -
(matrix-allfold fun ini mat)
returns any resulting from folding by two-argument procedurefun
all matrixmat
entries. -
(matrix-map fun mat)
returns matrix resulting from applying procedurefun
to each entry of matrixmat
. -
(matrix-broadcast fun x y)
returns matrix resulting from applying procedurefun
to each element of matrixx
,y
, expanded if necessary. -
(matrix-vec mat)
returns column matrix of vertically concatenated columns of matrixmat
, aka vectorization. -
(matrix-transpose mat)
returns matrix of entries of matrixmat
with swapped row and column indices. -
(matrix-axpy a x y)
returns matrix resulting from scaling matrixx
by anya
and add matrixy
. -
(matrix-scalar xt y)
returns any resulting from the scalar product of column-matrixesxt
andy
. -
(matrix-dot* xt y)
returns matrix resulting from matrix multiplication of transposed of matrixxt
and matrixy
. -
(matrix-explode mat)
returns list-of-column-matrix from matrixmat
. -
(matrix-implode lst)
returns matrix of horizontally concatenated list-of-column-matrixeslst
. -
(matrix->list mat)
returns: list of entries of one-dimensional matrixmat
. -
(matrix-print mat)
returns void, prints matrixmat
to terminal. -
(matrix-export str mat sep)
returns void, writes matrixmat
to new charactersep
-separated-value file in relative path (string)str
. -
(matrix-save str mat)
returns void, writes matrixmat
to new Scheme (SCM) file in relative path (string)str
. -
(matrix-load str)
returns matrix loaded from file in relative path (string)str
.
-
(matrix-map* fun x)
returns matrix resulting from applying procedurefun
to each column of matrixx
. -
(matrix-map** fun x y)
returns matrix resulting from applying procedurefun
to each column of matrixesx
andy
.
Specifies generic column functions for matrix library with f64vector (flonum vector).
Provides homogeneous vector transformations analogous to vectors.
-
(f64vector-unfold dim fun)
returns f64vector of dimension fixnumdim
with procedurally generated elements by procedurefun
. -
(f64vector-concat . vecs)
returns f64vector of concatenated list-of-f64vector(s)vecs
. -
(f64vector-any? pred vec)
returns boolean answering if any element of f64vectorvec
fulfills predicate procedurepred
from left to right. -
(f64vector-all? pred vec)
returns boolean answering if all elements of f64vectorvec
fulfill predicate procedurepred
from left to right. -
(f64vector-map fun . vecs)
returns f64vector resulting from applying procedurefun
to all corresponding f64vector(s)vecs
elements. -
(f64vector-map-index fun . vecs)
returns f64vector resulting from applying procedurefun
to index and all corresponding f64vector(s)vecs
elements. -
(f64vector-foreach fun . vecs)
returns void, applies procedurefun
to all corresponding f64vector(s)vecs
elements. -
(f64vector-foreach-index fun . vecs)
returns void, applies procedurefun
to index and all corresponding f64vector(s)vecs
elements. -
(f64vector-axpy a x y)
returns f64vector resulting from applying fused-multiply-add to the flonuma
and to all f64vectorsx
,y
elements. -
(f64vector-fold fun ini . vecs)
returns any resulting from applying procedurefun
toini
initialized accumulator and sequentially to all f64vector(s)vecs
elements from left to right. -
(f64vector-fold* fun ini . vecs)
returns any resulting from applying procedurefun
toini
initialized accumulator and sequentially to all f64vector(s)vecs
elements from right to left. -
(f64vector-dot x y)
returns flonum resulting from applying fused-multiply-add to zero initialized accumulator and sequentially to all f64vectorsx
,y
elements from left to right.
Provides extra flonum procedures.
-
(fp*+ x y z)
returns flonum sum with product:x * y + z
of flonumsx
,y
,z
. (Fallback) -
(fptaper x)
returns string representation of flonumx
formatted to 8 character fixed width.
Provides a few base functions, macros and aliases for convenience.
-
(define-syntax-rule (name args) (body ...))
returns macro generating single-rule macro. -
(must-be . args)
macro wrappingassert
ofand
with variable number of arguments. -
(comment . any)
returns void. -
nil
is alias for'()
. -
head
is alias forcar
. -
tail
is alias forcdr
. -
empty?
is alias fornull?
. -
(fx+1 x)
returns fixnum incremented fixnumx
. -
(fx-1 x)
returns fixnum decremented fixnumx
. -
(fx=0? x)
returns boolean answering if fixnumx
is zero. -
(fx<0? x)
returns boolean answering if fixnumx
is smaller than zero. -
(fx>0? x)
returns boolean answering if fixnumx
is greater than zero. -
(fx<=0? x)
returns boolean answering if fixnumx
is smaller or equal to zero. -
(fx>=0? x)
returns boolean answering if fixnumx
is greater or equal to zero. -
(append* lst any)
returns list of list argumentlst
with appended argumentany
. -
(sublist lst start end)
returns list containing elements of listlst
from indices fixnumsstart
toend
. -
(any? pred lst)
returns boolean answering if any element of listlst
fulfills predicate procedurepred
. -
(all? pred lst)
returns boolean answering if all elements of listlst
fulfill predicate procedurepred
. -
(factorial n)
returns fixnum multiplying consecutive integers up to fixnumn
. -
(binomial n k)
returns fixnum binomial coefficient for fixnumssn
andk
based on Pascal's rule. -
(define* (name args ...) (returns str) (body ...))
returns macro generating function binding with docstring. -
(define* name (returns str) (body ...))
returns macro generating function binding with docstring. -
(load* str)
returns any result of the last expressions in loaded and evaluated file with path stringstr
.
Tools Reference (click to expand)
-
(ok?)
returns boolean answering if all test passed. -
(check exe arg-ret-lst)
returns boolean answering if procedureexe
evaluated for car of each element of list-of-pairsarg-ret-lst
corresponds to its cdr.
Please note:
The author is fully aware that the performance of matrico
cannot compete with
current numerical environments, which predominantly utilize the highly tuned
BLAS
and LAPACK libraries.
The following matrico
benchmarks in turn are meant as an indicator to track
version-by-version performance evolution of this pure Scheme implementation.
- Matrix dimension: 1000x1000
- Optimization level:
-O5
Run by:
make matmul
- Matrix dimension: 1000x1000
- Optimization level:
-O5
Run by:
make linpack
- Based on BogoMips
- Optimization level:
-O5
Run by:
make mips
-
CPU:
M2 (4+4 Cores @ 3.5Ghz) -
RAM:
16GB (LPDDR5 @ 6400MT/s) -
SYS:
MacOS Monterey (12.7) -
SCM:
CHICKEN Scheme (5.4) -
MATMUL:
267
Megaflops -
LINPACK:
313
Megaflops -
BOGOMIPS:
273
Mips
-
[
check
] Add morematrico
tests -
[
matrico
] Add examples, equation images and links to documentation -
[
mx
] Add rank-revealing QR and pseudo-inverse via QR -
[
mx
] Add Eigenvalue decomposition and singular value decomposition via QR -
[
mx
] AddUnicodePlot
-like lineplot functionality
0.7 (2024-11-??)
- FIXED readded integrated
fpXXX
functions for pre 5.4 compatibility - ... and many minor updates and fixes.
0.6 (2024-07-18)
- ADDED
mx->list
- IMPROVED
mx-export
- CHANGED
mx-diag
- CHANGED
mx-qr
- CHANGED
mx-orth
- ... and many minor updates and fixes.
0.5 (2023-06-06)
- ADDED
f64vector-axpy
- ADDED
matrix-axpy
- CHANGED
mx*+
tomx-axpy
- IMPROVED
mx-qr
- IMPROVED
mx-solver
- ... and many minor updates and fixes.
0.4 (2023-06-01)
- ADDED
mx-angle
- ADDED
mx-var
- ADDED
mx-orth
- IMPROVED
mx-std
- IMPROVED
mx-solver
- IMPROVED
f64vector-dot
- REMOVED
mx-logb
- ... and many minor updates and fixes.
0.3 (2022-09-16)
- ADDED
matrico
function - ADDED
mx-set
- ADDED
mx-lnsinh
,mx-lncosh
- ADDED
mx-dyadic
- ADDED
mx-heaviside
- CHANGED default optimization level to
-O3
- CHANGED inlining of local functions
- CHANGED testing framework
- IMPROVED argument checking
- IMPROVED performance
- REMOVED
matrico-ver
,matrico-cite
,matrico-about
,matrico?
- ... and many minor updates and fixes.
0.2 (2022-07-07)
- ADDED
matrico-cite
- ADDED
mx-scalar
- ADDED (re)export of
fpmath
bymatrico
- ADDED instrumentation and statistical profiling targets
- CHANGED rename
matrico-help
tomatrico-about
- CHANGED rename and adapt
fp+*
andmx+*
tofp*+
andmx*+
- CHANGED rename
fpdirac
andmx-dirac
tofpdelta
andmx-delta
- IMPROVED argument checking
- IMPROVED performance
- REMOVED
mx-dist
- REMOVED
mx-repeat
- ... and many minor updates and fixes.
0.1 (2022-05-01)
- Initial Release
-
Every source file states: project, author, license, version, summary!
-
Every function has a one-line summary!
-
Import only included modules!
-
Avoid
do
, prefer namedlet
-recursion! -
Avoid
set-car!
andset-cdr!
! -
Avoid "multiple values"!
-
Avoid
mx-ref
for non-column matrices if possible!
-
matrico
should be build with-O3
if used as a shared object (default). -
matrico
can be build with-O5
ifmatrico.scm
is included into the source.