-
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.shCHICKEN_INSTALL_REPOSITORY="/my/egg/directory/" chicken-install -test matricoCHICKEN_REPOSITORY_PATH="`chicken-install -repository`:/my/egg/directory/" csi./RUNME.shcsi demos/heat.scmcsi demos/flame.scmmatrico 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
matricoModulemxLibrary (User-Facing Matrix Frontend)denseModule (Column Interface Specialization)matrixFunctor (Functional Matrix Backend)f64vectorModule (Homogeneous Flonum Vector Functions)fpmathModule (User-Facing Additional Flonum Functions)utilsModule (Additional Foundational Functions)
- Extra Tools
checkLibrary (Testing Helper Functions)
User-Facing Function Reference (click to expand)
-
(matrico)returns void, prints help message formatricofunction. -
(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 thematricobanner;'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-colsmatrix with all entries set to flonumvalfor positive fixnumsrowsandcols. -
(mx% lst)returns matrix from row-major list-of-lists-of-flonumslst. -
(mx-identity dims)returnsdims-by-dimsidentity matrix for a positive fixnumdims. -
(mx-exchange dims)returnsdims-by-dimsexchange matrix for a positive fixnumdims. -
(mx-hilbert dims)returnsdims-by-dimsHilbert 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-colsLehmer matrix for the positive fixnumsrowsandcols. -
(mx-random rows cols low upp)returnsrows-by-colsuniformly distributed random matrix in the interval flonumlowto flonumuppfor the positive fixnumsrowsandcols. -
(mx-tridiag dims low mid upp)returnsdims-by-dimsmatrix with lower, main, upper band entries given by the flonumslow,mid,uppfor 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 fixnumnumrow-wise linearly spaced entries with endpoints given by flonums or column-matrixesxandy. -
(mx-logspace x y num)returns matrix of positive fixnumnumrow-wise (base-10) logarithmic spaced entries with endpoints given by flonums or column-matrixesxandy.
-
(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 ifanyis a matrix. -
(mx-col? mat)returns boolean answering if matrixmathas only a single column. -
(mx-row? mat)returns boolean answering if matrixmathas only a single row. -
(mx-scalar? mat)returns boolean answering if matrixmathas only a single row and single column. -
(mx-vector? mat)returns boolean answering if matrixmathas only a single row or single column. -
(mx-square? mat)returns boolean answering if matrixmathas the same number of rows and columns. -
(mx-samecols? x y)returns boolean answering if matrixesxandyhave same number of columns. -
(mx-samerows? x y)returns boolean answering if matrixesxandyhave same number of rows. -
(mx-samedim? x y)returns boolean answering if matrixesxandyhave same number of columns and rows. -
(mx-any? pred mat)returns boolean answering if any entry of matrixmatfulfills predicate procedurepred. -
(mx-all? pred mat)returns boolean answering if all entries of matrixmatfulfill predicate procedurepred. -
(mx=? x y tol)returns boolean answering if all entry-wise distances between matrixesxandyare below tolerance flonumtol.
-
(mx-ref11 mat)returns flonum being the top, left entry of matrixmat. -
(mx-ref mat row col)flonum being matrixmatentry in row and column specified by positive fixnumsrow,col. -
(mx-set mat row col val)returns matrix copy of matrixmatbut with entry in row fixnumrowand column fixnumcolset to flonum or one-by-one matrixval. -
(mx-set! mat row col val)returns void, sets entry of matrixmatin row and column specified by positive fixnumsrowandcolto 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 matrixmatin rows specified by positive fixnumsrow1torow2and columns specified by positive fixnumscol1tocol2.
-
(mx+ x y)returns matrix of entry-wise addition of matrixesxandy. -
(mx* x y)returns matrix of entry-wise multiplication of matrixesxandy. -
(mx- x y)returns matrix of entry-wise subtraction of matrixesxandy. -
(mx/ x y)returns matrix of entry-wise division of matrixesxbyy. -
(mx^ x y)returns matrix of entry-wise exponentiation of matrixesxto they. -
(mx-where pred x y)returns matrix of entries of matrixesxorybased 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 matrixmatrounded to nearest integer. -
(mx-floor mat)returns matrix with entries of matrixmatrounded to nearest upper integer. -
(mx-ceil mat)returns matrix with entries of matrixmatrounded 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 matrixmatentries.
-
(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 matrixmatentries.
-
(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 matrixmatentries.
-
(mx-rowmean mat typ)returns column-matrix of row-wise power means of matrixmatof type symboltyp, which can be-1,0,1,2, or'inf. -
(mx-colmean mat typ)returns row-matrix of column-wise power means of matrixmatof type symboltyp, which can be-1,0,1,2, or'inf. -
(mx-mean mat typ)returns flonum power mean of all matrixmatentries 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 matrixmatof type symboltyp, which can be1,2, or'inf. -
(mx-colnorm mat typ)returns row-matrix of column-wise matrix norms of matrixmatof type symboltyp, which can be1,2, or'inf. -
(mx-norm mat typ)returns flonum matrix norms of matrixmatof type symboltyp, which can be1,'inf,'fro, or'max.
-
(mx-horcat x y)returns matrix of horizontally concatenated matrixesxandy. -
(mx-vercat x y)returns matrix of vertically concatenated matrixesxandy. -
(mx-vec mat)returns matrix of vertically concatenated columns of matrixmat, aka vectorization. -
(mx-transpose mat)returns matrix of entries of matrixmatwith swapped row and column indices. -
(mx-axpy a x y)returns matrix of entry-wise generalized addition of flonumatimes matrixxplus 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 matrixmatand 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 matrixmatdiagonal entries. -
(mx-multrace mat)returns flonum being product of square matrixmatdiagonal entries. -
(mx-prodtrace* x yt)returns flonum being the trace of the matrix product of matrixxand transposed matrixyt. -
(mx-prodtrace x y)returns flonum being the trace of the matrix product of matrixesxandy.
-
(mx-scalar xt y)returns flonum resulting from scalar product of column-matrixesxtandy. -
(mx-dyadic x y)returns flonum resulting from dyadic product of column-matrixxand row-matrixy. -
(mx-dot* xt y)returns matrix resulting from matrix multiplication of transposed matrixxtand matrixy. -
(mx-dot x y)returns matrix resulting from matrix multiplication of matrixesxandy. -
(mx-gram mat)returns matrix resulting from matrix multiplication of (transposed) matrixmatwith itself, aka Gram matrix. -
(mx-gram* mat)returns matrix resulting from matrix multiplication of matrixmatwith itself transposed. -
(mx-square mat)returns matrix resulting from matrix multiplication of matrixmatwith itself.
-
(mx-xcov x y)returns matrix of cross-covariances of matrixesxandy, 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 matrixesxandy, 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 matrixesxandy, representing columns of observations. -
(mx-coher x y)returns flonum of distance coherence between matrixesxandy.
-
(mx-diff mat)returns matrix of differences of consecutives columns of matrixmat. -
(mx-trapz mat)returns column-matrix trapezoid approximate integral of matrixmatbeing 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 fixnumnumstages, 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 fixnumnumstages, 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 matrixmatto terminal. -
(mx-export str mat . sep)void, writes matrixmatto new charactersep-separated-value file in relative path stringstr, by defaultsepis,resulting in CSV. -
(mx-save str mat)returns void, writes matrixmatto 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:
-
fpis alias forexact->inexact. -
(fp% n d)returns flonum fraction with numerator fixnumnand denominator fixnumd. -
(fpzero?? x)returns boolean answering if flonumxis exactly zero. -
(fpzero? x tol)returns boolean answering if absolute value of flonumxis 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 argumentvalis a flonum or matrix. -
(scalar-or-flonum? val)returns boolean answering if argumentvalis a flonum or scalar matrix. -
(column-or-flonum? val)returns boolean answering if argumentvalis a flonum or column matrix. -
(ensure-mx val)returns one-by-one matrix ifvalis flonum, orvalifvalis matrix. -
(ensure-fp val)returns flonum ifvalis flonum, or element ifvalis one-by-one matrix. -
(translate-cols idx)returns fixnum for matrixmattranslated column index fixnumidx(from 1-based to 0-based and from end). -
(translate-rows idx)returns fixnum for matrixmattranslated 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 ifanyis a matrix, generated bydefine-record. -
(make-matrix cols lst)returns matrix from listlstof columns and fixnum numbercolsof columns, generated bydefine-record. -
(make-matrix* rows cols val)returnsrows-by-colsmatrix with all entries set tovalfor fixnumsrows,cols. -
(make-matrix** lst)returns matrix from row-major list-of-listslst. -
(matrix-generate fun rows cols)returnsrows-by-colsmatrix 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 matrixmatin the first row and first column. -
(matrix-ref*0 mat row)returns any being matrixmatentry in fixnumrowand the first column. -
(matrix-ref mat row col)returns any being matrixmatentry in fixnumrowand fixnumcolumns. -
(matrix-set mat row col val)returns matrix copy of matrixmatbut with entry in row fixnumrowand column fixnumcolset toval. -
(matrix-set! mat row col val)returns any, sets entry of matrixmatin row fixnumrowand column fixnumcoltoval. -
(matrix-col mat col)returns matrix being matrixmatcolumn specified by fixnumcol. -
(matrix-row mat row)returns matrix being matrixmatrow specified by fixnumrow. -
(matrix-diag mat)returns matrix holding matrixmatdiagonal entries as column-matrix. -
(matrix-submatrix mat row1 row2 col1 col2)returns matrix holding entries of matrixmatfrom rows fixnumsrow1torow2in columns fixnumscol1tocol2. -
(matrix-col? mat)returns boolean answering if matrixmathas only a single column. -
(matrix-row? mat)returns boolean answering if matrixmathas only a single row. -
(matrix-scalar? mat)returns boolean answering if matrixmathas only a single row and single column, aka scalar. -
(matrix-vector? mat)returns: boolean answering if matrixmathas only a single row or single column, aka vector. -
(matrix-square? mat)returns boolean answering if matrixmathas the same number of rows and columns. -
(matrix-samecols? mat)returns boolean answering if matrixesxandyhave same number of columns. -
(matrix-samerows? mat)returns boolean answering if matrixesxandyhave same number of rows. -
(matrix-samedims? mat)returns boolean answering if matrixesxandyhave same number of columns and rows. -
(matrix-any? pred mat)returns boolean answering if any entry of matrixmatfulfills predicate procedurepred. -
(matrix-all? pred mat)returns boolean answering if all entries of matrixmatfulfill predicate procedurepred. -
(matrix-colfold fun ini mat)returns row matrix resulting from folding by two-argument procedurefuneach column of matrixmat. -
(matrix-rowfold fun ini mat)returns column matrix resulting from folding by two-argument procedurefuneach row of matrixmat. -
(matrix-allfold fun ini mat)returns any resulting from folding by two-argument procedurefunall matrixmatentries. -
(matrix-map fun mat)returns matrix resulting from applying procedurefunto each entry of matrixmat. -
(matrix-broadcast fun x y)returns matrix resulting from applying procedurefunto 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 matrixmatwith swapped row and column indices. -
(matrix-axpy a x y)returns matrix resulting from scaling matrixxby anyaand add matrixy. -
(matrix-scalar xt y)returns any resulting from the scalar product of column-matrixesxtandy. -
(matrix-dot* xt y)returns matrix resulting from matrix multiplication of transposed of matrixxtand 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 matrixmatto terminal. -
(matrix-export str mat sep)returns void, writes matrixmatto new charactersep-separated-value file in relative path (string)str. -
(matrix-save str mat)returns void, writes matrixmatto 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 procedurefunto each column of matrixx. -
(matrix-map** fun x y)returns matrix resulting from applying procedurefunto each column of matrixesxandy.
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 fixnumdimwith 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 f64vectorvecfulfills predicate procedurepredfrom left to right. -
(f64vector-all? pred vec)returns boolean answering if all elements of f64vectorvecfulfill predicate procedurepredfrom left to right. -
(f64vector-map fun . vecs)returns f64vector resulting from applying procedurefunto all corresponding f64vector(s)vecselements. -
(f64vector-map-index fun . vecs)returns f64vector resulting from applying procedurefunto index and all corresponding f64vector(s)vecselements. -
(f64vector-foreach fun . vecs)returns void, applies procedurefunto all corresponding f64vector(s)vecselements. -
(f64vector-foreach-index fun . vecs)returns void, applies procedurefunto index and all corresponding f64vector(s)vecselements. -
(f64vector-axpy a x y)returns f64vector resulting from applying fused-multiply-add to the flonumaand to all f64vectorsx,yelements. -
(f64vector-fold fun ini . vecs)returns any resulting from applying procedurefuntoiniinitialized accumulator and sequentially to all f64vector(s)vecselements from left to right. -
(f64vector-fold* fun ini . vecs)returns any resulting from applying procedurefuntoiniinitialized accumulator and sequentially to all f64vector(s)vecselements 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,yelements from left to right.
Provides extra flonum procedures.
-
(fp*+ x y z)returns flonum sum with product:x * y + zof flonumsx,y,z. (Fallback) -
(fptaper x)returns string representation of flonumxformatted 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 wrappingassertofandwith variable number of arguments. -
(comment . any)returns void. -
nilis alias for'(). -
headis alias forcar. -
tailis 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 fixnumxis zero. -
(fx<0? x)returns boolean answering if fixnumxis smaller than zero. -
(fx>0? x)returns boolean answering if fixnumxis greater than zero. -
(fx<=0? x)returns boolean answering if fixnumxis smaller or equal to zero. -
(fx>=0? x)returns boolean answering if fixnumxis greater or equal to zero. -
(append* lst any)returns list of list argumentlstwith appended argumentany. -
(sublist lst start end)returns list containing elements of listlstfrom indices fixnumsstarttoend. -
(any? pred lst)returns boolean answering if any element of listlstfulfills predicate procedurepred. -
(all? pred lst)returns boolean answering if all elements of listlstfulfill predicate procedurepred. -
(factorial n)returns fixnum multiplying consecutive integers up to fixnumn. -
(binomial n k)returns fixnum binomial coefficient for fixnumssnandkbased 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 procedureexeevaluated for car of each element of list-of-pairsarg-ret-lstcorresponds 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:
267Megaflops -
LINPACK:
313Megaflops -
BOGOMIPS:
273Mips
-
[
check] Add morematricotests -
[
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
fpXXXfunctions 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
matricofunction - 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
fpmathbymatrico - ADDED instrumentation and statistical profiling targets
- CHANGED rename
matrico-helptomatrico-about - CHANGED rename and adapt
fp+*andmx+*tofp*+andmx*+ - CHANGED rename
fpdiracandmx-diractofpdeltaandmx-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-reffor non-column matrices if possible!
-
matricoshould be build with-O3if used as a shared object (default). -
matricocan be build with-O5ifmatrico.scmis included into the source.