chickadee » matrico

matrico

A flonum matrix module for CHICKEN Scheme.

matrico Function

matricoprocedure

returns void, prints help message for matrico function.

matrico symprocedure

returns any, depending on argument symbol sym:

  • 'list - returns void, prints list of "mx" functions;
  • 'about - returns void, prints summary about matrico;
  • 'banner - returns void, prints the matrico banner;
  • 'version - returns pair holding major and minor version numbers of matrico;
  • 'citation - returns void, prints citation information for matrico;
  • '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.

Matrix Type

matrixtype

a list-of-f64vectors (flonum-)matrix type. This record type is not directly accessible, and can only be manipulated through "mx-" functions.

Matrix Generators

mx rows cols valprocedure

returns rows-by-cols matrix with all entries set to flonum val for positive fixnums rows and cols.

mx% lstprocedure

returns matrix from row-major list-of-lists-of-flonums lst.

mx-identity dimsprocedure

returns dims-by-dims identity matrix for a positive fixnum dims.

mx-exchange dimsprocedure

returns dims-by-dims exchange matrix for a positive fixnum dims.

mx-hilbert dimsprocedure

returns dims-by-dims Hilbert matrix for a positive fixnum dims.

mx-pascal dimsprocedure

returns dims-by-dims (lower triangular) Pascal matrix for a positive fixnum dims.

mx-lehmer rows colsprocedure

returns rows-by-cols Lehmer matrix for the positive fixnums rows and cols.

mx-random rows cols low uppprocedure

returns rows-by-cols uniformly distributed random matrix in the interval flonum low to flonum upp for the positive fixnums rows and cols.

mx-tridiag dims low mid uppprocedure

returns dims-by-dims matrix with lower, main, upper band entries given by the flonums low, mid, upp for a positive fixnum dims.

mx-unit rows numprocedure

returns dims-by-one matrix of zeros except the positive fixnum num-th entry set to one for a positive fixnum dims, aka canonical base vector.

mx-iota dimsprocedure

returns dims-by-one matrix with entries set to corresponding row index for a positive fixnum dims.

mx-linspace x y numprocedure

returns matrix of positive fixnum num row-wise linearly spaced entries with endpoints given by flonums or column-matrixes x and y.

mx-logspace x y numprocedure

returns matrix of positive fixnum num row-wise (base-10) logarithmic spaced entries with endpoints given by flonums or column matrixes x and y.

Matrix Dimensions

mx-cols matprocedure

returns fixnum number of columns of matrix mat.

mx-rows matprocedure

returns fixnum number of rows of matrix mat.

mx-numel matprocedure

returns fixnum number of entries of matrix mat.

mx-dims matprocedure

returns fixnum number of dimensions of matrix mat.

Matrix Predicates

mx? anyprocedure

returns boolean answering if any is a matrix.

mx-col? matprocedure

returns boolean answering if matrix mat has only a single column.

mx-row? matprocedure

returns boolean answering if matrix mat has only a single row.

mx-scalar? matprocedure

returns boolean answering if matrix mat has only a single row and single column.

mx-vector? matprocedure

returns boolean answering if matrix mat has only a single row or single column.

mx-square? matprocedure

returns boolean answering if matrix mat has the same number of rows and columns.

mx-samecols? x yprocedure

returns boolean answering if matrixes x and y have same number of columns.

mx-samerows? x yprocedure

returns boolean answering if matrixes x and y have same number of rows.

mx-samedim? x yprocedure

returns boolean answering if matrixes x and y have same number of columns and rows.

mx-any? pred matprocedure

returns boolean answering if any entry of matrix mat fulfills predicate procedure pred.

mx-all? pred matprocedure

returns boolean answering if all entries of matrix mat fulfills predicate procedure pred.

mx=? x y tolprocedure

returns boolean answering if all entry-wise distances between matrixes x and y are below tolerance flonum `tol`.

Matrix Accessors

mx-ref11 matprocedure

returns flonum being the entry in the first row and first column of matrix mat.

mx-ref mat row colprocedure

returns flonum being matrix mat entry in row and column specified by fixnums row, col.

mx-set mat row col valprocedure

returns matrix copy of matrix mat but with entry in row fixnum row and column fixnum col set to flonum or one-by-one matrix val.

mx-set! mat row col valprocedure

returns void, sets entry of matrix mat in row and column specified by fixnums row and col to flonum or one-by-one matrix val.

mx-col mat colprocedure

returns matrix being matrix mat's column specified by fixnum col.

mx-row mat rowprocedure

returns matrix being matrix mat's row specified by fixnum row.

mx-diag matprocedure

returns column-matrix holding square matrix mat's diagonal entries.

mx-submatrix mat row1 row2 col1 col2procedure

returns matrix holding entries of matrix mat in rows specified by fixnums row1 to row2 and columns specified by fixnums col1 to col2.

Matrix Expanders

mx+ x yprocedure

returns matrix of entry-wise addition of matrixes x and y.

mx* x yprocedure

returns matrix of entry-wise multiplication of matrixes x and y.

mx- xprocedure

returns matrix of entry-wise negation of matrix x.

mx- x yprocedure

returns matrix of entry-wise subtraction of matrixes x and y.

mx/ xprocedure

returns matrix of entry-wise reciprocal of matrix x.

mx/ x yprocedure

returns matrix of entry-wise division of matrixes x by y.

mx*2 xprocedure

returns matrix of entry-wise doubling of matrix x.

mx^2 xprocedure

returns matrix of entry-wise squaring of matrix x.

mx^ x yprocedure

returns matrix of entry-wise exponentiation of matrixes x to the y.

mx-log x yprocedure

returns matrix of entry-wise base matrix x logarithms of matrix y.

mx-where pred x yprocedure

returns matrix of entries of matrixes x or y based on predicate procedure pred.

mx*+ a x yprocedure

returns matrix of entry-wise generalized addition of flonum a times matrix x plus matrix y.

Matrix Mappers

Entry-Wise Rounding Functions

mx-round matprocedure

returns matrix with entries of matrix mat rounded to nearest integer.

mx-floor matprocedure

returns matrix with entries of matrix mat rounded to nearest upper integer.

mx-ceil matprocedure

returns matrix with entries of matrix mat rounded to nearest lower integer.

Entry-Wise Generalized Functions

mx-abs matprocedure

returns matrix with entry-wise absolute value of matrix mat.

mx-sign matprocedure

returns matrix with entry-wise sign of matrix mat.

mx-delta matprocedure

returns matrix with entry-wise Kronecker delta of matrix mat.

mx-heaviside matprocedure

returns matrix with entry-wise Heaviside step of matrix mat.

Entry-Wise Trigonometric Functions

mx-sin matprocedure

returns matrix with entry-wise sine of matrix mat.

mx-cos matprocedure

returns matrix with entry-wise cosine of matrix mat.

mx-tan matprocedure

returns matrix with entry-wise tangent of matrix mat.

Entry-Wise Inverse Trigonometric Functions

mx-asin matprocedure

returns matrix with entry-wise inverse sine of matrix mat, aka arcsine.

mx-acos matprocedure

returns matrix with entry-wise inverse cosine of matrix mat, aka arccosine.

mx-atan matprocedure

returns matrix with entry-wise inverse tangent of matrix mat, aka arctangent.

Entry-Wise Hyperbolic Functions

mx-sinh matprocedure

returns matrix with entry-wise hyperbolic sine of matrix mat.

mx-cosh matprocedure

returns matrix with entry-wise hyperbolic cosine of matrix mat.

mx-tanh matprocedure

returns matrix with entry-wise hyperbolic tangent of matrix mat.

Entry-Wise Inverse Hyperbolic Functions

mx-asinh matprocedure

returns matrix with entry-wise inverse hyperbolic sine of matrix mat, aka area hyperbolic sine.

mx-acosh matprocedure

returns matrix with entry-wise inverse hyperbolic cosine of matrix mat, aka area hyperbolic cosine.

mx-atanh matprocedure

returns matrix with entry-wise inverse hyperbolic tangent of matrix mat, aka area hyperbolic tangent.

Entry-Wise Haversed Trigonometric Functions

mx-hsin matprocedure

returns matrix with entry-wise haversed sine of matrix mat.

mx-hcos matprocedure

returns matrix with entry-wise haversed cosine of matrix mat.

Entry-Wise Logarithmic Hyperbolic Functions

mx-lnsinh matprocedure

returns matrix with entry-wise log-sinh of matrix mat.

mx-lncosh matprocedure

returns matrix with entry-wise log-cosh of matrix mat.

Entry-Wise Roots

mx-sqrt matprocedure

returns matrix with entry-wise square root of matrix mat.

mx-signsqrt matprocedure

returns matrix with entry-wise sign times square-root of absolute value of matrix mat.

Entry-Wise Logarithms

mx-ln matprocedure

returns matrix with entry-wise natural logarithm of matrix mat.

mx-lb matprocedure

returns matrix with entry-wise base-2 logarithm of matrix mat.

mx-lg matprocedure

returns matrix with entry-wise base-10 logarithm of matrix mat.

Entry-Wise Exponential

mx-exp matprocedure

returns matrix with entry-wise exponential of matrix mat.

mx-gauss matprocedure

returns matrix with entry-wise Gaussian of matrix mat.

Entry-Wise Special Functions

mx-sinc matprocedure

returns matrix with entry-wise cardinal sine of matrix mat.

mx-sigm matprocedure

returns matrix with entry-wise sigmoid of matrix mat.

mx-stirling matprocedure

returns matrix with entry-wise Stirling approximation of matrix mat.

Matrix Reducers

Sums

mx-rowsum matprocedure

returns column-matrix of summing row entries of matrix mat.

mx-colsum matprocedure

returns row-matrix of summing column entries of matrix mat.

mx-sum matprocedure

returns flonum of summing all entries of matrix mat.

Products

mx-rowprod matprocedure

returns column-matrix of multiplying row entries of matrix mat.

mx-colprod matprocedure

returns row-matrix of multiplying column entries of matrix mat.

mx-prod matprocedure

returns flonum of multiplying all entries of matrix mat.

Minima

mx-rowmin matprocedure

returns column-matrix of row-wise minima of matrix mat.

mx-colmin matprocedure

returns row-matrix of column-wise minima of matrix mat.

mx-min matprocedure

returns flonum minimum of all matrix mat entries.

Maxima

mx-rowmax matprocedure

returns column-matrix of row-wise maxima of matrix mat.

mx-colmax matprocedure

returns row-matrix of column-wise maxima of matrix mat.

mx-max matprocedure

returns flonum maximum of all matrix mat entries.

Midrange

mx-rowmidr matprocedure

returns column-matrix of row-wise midrange of matrix mat.

mx-colmidr matprocedure

returns row-matrix of column-wise midrange of matrix mat.

mx-midr matprocedure

returns flonum midrange of all matrix mat entries.

Means

mx-rowmean mat typprocedure

returns column-matrix of row-wise power means of matrix mat of type symbol typ, which can be -1, 0, 1, 2, or 'inf.

mx-colmean mat typprocedure

returns row-matrix of column-wise power means of matrix mat of type symbol typ, which can be -1, 0, 1, 2, or 'inf.

mx-mean mat typprocedure

returns flonum power mean of all matrix mat entries of type symbol typ, which can be -1, 0, 1, 2, or 'inf.

Norms

mx-rownorm mat typprocedure

returns column matrix of row-wise matrix norms of matrix mat of type symbol typ, which can be 1, 2, or 'inf.

mx-colnorm mat typprocedure

returns row matrix of column-wise matrix norms of matrix mat of type symbol typ, which can be 1, 2, or 'inf.

mx-norm mat typprocedure

returns flonum matrix norms of matrix mat of type symbol typ, which can be 1, 'inf, 'fro, or 'max.

Linear Algebra

mx-horcat x yprocedure

returns matrix of horizontally concatenated matrixes x and y.

mx-vercat x yprocedure

returns matrix of vertically concatenated matrixes x and y.

mx-vec matprocedure

returns matrix of vertically concatenated columns of matrix mat, aka vectorization.

mx-transpose matprocedure

returns matrix of entries of matrix mat with swapped row and column indices.

mx-sympart matprocedure

returns matrix being symmetric part of square matrix mat.

mx-skewpart matprocedure

returns matrix being skey-symmetric part of square matrix mat, aka anti-symmetric part.

mx-diagonal matprocedure

returns diagonal matrix from column matrix mat.

Linear Problems

mx-qr matprocedure

returns pair of orthogonal matrix (Q) and upper right triangular matrix (R) factoring full column rank matrix mat.

mx-solver matprocedure

returns function returning column-matrix solving the linear (least-squares) problem of matrix mat, given a column-matrix vec via QR decomposition.

mx-solve mat vecprocedure

returns column-matrix solving the linear problem of matrix mat and column-matrix vec via QR decomposition.

mx-absdet matprocedure

returns flonum being absolute value of the determinant of matrix mat.

mx-logdet matprocedure

returns flonum being the (natural) logarithm of the determinant of matrix mat.

Traces

mx-trace matprocedure

returns flonum being sum of square matrix mat's diagonal entries.

mx-multrace matprocedure

returns flonum being product of square matrix mat's diagonal entries.

mx-prodtrace* x ytprocedure

returns flonum being the trace of the matrix product of matrix x and transposed matrix yt.

mx-prodtrace x yprocedure

returns flonum being the trace of the matrix product of matrixes x and y.

Matrix Multiplication

mx-scalar xt yprocedure

returns flonum resulting from scalar product of column-matrixes xt and y.

mx-dyadic x yprocedure

returns flonum resulting from dyadic product of column-matrix x and row-matrix y.

mx-dot* xt yprocedure

returns matrix resulting from matrix multiplication of (transposed) matrix xt and matrix y.

mx-dot x yprocedure

returns matrix resulting from matrix multiplication of matrixes x and y.

mx-gram matprocedure

returns matrix resulting from matrix multiplication of transposed matrix mat with itself, aka Gram matrix.

mx-gram* matprocedure

returns matrix resulting from matrix multiplication of matrix mat with itself transposed.

mx-square matprocedure

returns matrix resulting from matrix multiplication of matrix mat with itself.

Multivariate Statistics

mx-xcov x yprocedure

returns matrix of cross-covariances of matrixes x and y, representing columns of observations.

mx-cov matprocedure

returns matrix of covariances of matrix mat, representing columns of observations.

mx-std matprocedure

returns column matrix of standard deviations of matrix mat, representing columns of observations.

mx-xcor x yprocedure

returns matrix of cross-correlations of matrixes x and y, representing columns of observations.

mx-cor matprocedure

returns matrix of correlations of matrix mat, representing columns of observations.

mx-coher x yprocedure

returns flonum of distance coherence between matrixes x and y.

Analysis

mx-diff matprocedure

returns matrix of differences of consecutives columns of matrix mat.

mx-trapz matprocedure

returns column-matrix trapezoid approximate integral of matrix mat being columns data-points of rows-dimensional function.

mx-ode2-hyp num fun x0 dt tfprocedure

returns states-times-steps matrix trajectory solving an ordinary differential equation, by a 2nd order hyperbolic Runge-Kutta method of fixnum num stages, with vector field procedure fun, initial state column-matrix x0, time step flonum dt, and time horizon flonum tf.

mx-ode2-ssp num fun x0 dt tfprocedure

returns states-times-steps matrix trajectory solving an ordinary differential equation, by a 2nd order strong stability preserving Runge-Kutta method of fixnum num stages, with vector field procedure fun, initial state column-matrix x0, time step flonum dt, and time horizon flonum tf.

Matrix Utilities

mx-print matprocedure

returns void, prints matrix mat to terminal.

mx-export str matprocedure

returns void, writes matrix mat to new comma-separated-value (CSV) file with name string str.

mx-save str matprocedure

returns void, writes matrix mat to new Scheme (SCM) file with name string str.

mx-load strprocedure

returns matrix loaded from SCM file in relative path specified by string str.

Authors

Christian Himpe

Repository

https://git.io/matrico

License

Copyright (c) 2022 Christian Himpe. zlib-acknowledgement license

Version History

0.1
Initial Release
0.2
Major Update (details)
0.3
Major Update (details)

Contents »