Skip to content

MatRust 0.1.4 (alpha)

Pre-release
Pre-release

Choose a tag to compare

@leonaffi-byte leonaffi-byte released this 29 Nov 22:42

Fifth alpha of MatRust. In the Windows test set of real public scripts, 454 of 473 pass the rule below (they finish in time; that does not mean their results are correct). It speeds up scalar loops, and adds sparse, plotting, N-D and toolbox functions found missing by that test set.

This is an alpha, so expect gaps. The README lists what works and what does not yet. Function help lists supported inputs, limits and fallbacks.

What's new

Language and loops

  • Scalar loops use a faster slot form. It covers abs, sqrt, exp, log, sin, cos, tan, floor, ceil, round, fix, mod, rem, min, max and sign. Other statements in the loop run as before. MATRUST_SLOT_LOOPS=0 turns the slot form off. Expressions in such loops are evaluated on plain numbers where possible, anonymous-function calls that capture only numbers reuse their call frame, and matrix literals of real scalars are built directly.
  • Built-in function lookup is done once per name instead of on every call.
  • Language forms: multiple outputs from nested and indexed struct targets ([s.a, s(2).b] = f()), a function file whose name differs from its first function, bsxfun on N-D arrays, A(i,:) on N-D arrays, a scalar object indexed with obj(:).
  • inputParser optional-argument matching, validateattributes on N-D arrays, and isappdata, getappdata, setappdata, rmappdata.
  • rng accepts integer seeds up to 2^32-1 and 'mrg32k3a'.
  • Functions can have up to 4096 inputs and 4096 outputs.
  • struct() with no arguments returns an empty scalar struct.

Numerics, sparse and linear algebra

  • Rectangular A\b and b/A use pivoted QR and return the basic solution, with a rank-deficiency warning.
  • Sparse: symmetric indefinite \ uses an AMD-ordered LDL' factorization, which lowers fill on large meshes; sparse times dense no longer expands the sparse operand; submatrix assignment is limited by the number of nonzeros, not the full size; sparse comparison with a scalar stays sparse; the sparse product workspace is limited by the work it needs.
  • Real dense chol uses a blocked factorization when that succeeds, otherwise the earlier loop. chol above about 4,100 by 4,100 is refused.
  • repmat of a sparse matrix stays sparse.
  • fmincon interior-point solves its dense KKT system with a faster factorization and accepts infinite bounds.
  • fmincon, fminimax and fgoalattain: on an infeasible exit they keep the last iterate if that is finite, and return empty outputs if it is not.
  • New: optimget.
  • N-D arrays: fftn, ifftn, fftshift, ifftshift, interpn (linear and nearest), interp1 with N-D queries, accumarray with N-D subscripts, isnan, isinf and isfinite keep the input shape, and islogical, isnumeric, isinteger, isfloat accept N-D input.
  • sptarn (generalized sparse eigenproblem), eigs with word values for sigma, interp2 with complex values, complex isfinite, isnan and triu, typed histcounts, interp1 with '*method', deal on N-D arrays.
  • mvnrnd checks its size limit before factoring. New: mvnpdf, mvncdf (bivariate and trivariate, fixed-seed quasi-Monte Carlo above three dimensions).
  • linspace(a,b,n) with n at least 2 starts at a and ends at b. linspace(a,b,1) is b.
  • Control: LTI property names are case-insensitive and accept prefixes; margin and allmargin take the data form from bode; c2d returns [sysd,G]; pzmap(b,a); bode with several systems in one plot.
  • Geometry: 3-D delaunayTriangulation, delaunayn, delaunay(x,y,z), 3-D nearestNeighbor, pointLocation, scatteredInterpolant; freeBoundary, circumcenter.

Plots and graphics

  • Plot series: a marker-only plot is a Line object; MarkerIndices; plot(vector,scalar); contourf is one Contour object instead of one series per level; imagesc of a sparse matrix; hold-on appends no longer copy the whole figure; hold all is the same as hold on.
  • Patches and surfaces: polygons with more than four vertices, FaceVertexCData, interpolated FaceColor and EdgeColor, XData and YData set after creation, FaceLighting and lighting properties, camproj and Projection (stored; drawn orthographic).
  • Added: streamline, stream2 (2-D), coneplot, spy, getframe (without a window), tetramesh(T,X,C), daspect, triplot, uistack, and findobj with any property and value pairs.
  • Figures and axes: figure property prefixes and callback properties, XDir, YDir, ZDir, axis colours, label Rotation, setting axes Position (also beyond [0,1] without a subplot overlap error), tiledlayout spacing and titles, legend Title, Color and TextColor, numeric legend locations, textbox defaults and VerticalAlignment, PlotBoxAspectRatio, DefaultAxesPosition, Quiver objects with MaxHeadSize, and quiver3 on N-D data.
  • New colormaps: winter, spring, summer, autumn, pink, lines. New: gobjects, cameratoolbar.
  • Tag and UserData can be set when a plot object is created. HandleVisibility at creation is still not accepted.

Files and system

  • java.security.MessageDigest supports SHA-256 and SHA-512.
  • GIF files can be written with imwrite, including animated append. rgb2ind is new, and imfinfo reports GIF frames. Local \\?\X:\ paths are no longer refused as network paths on Windows.

PDE toolbox

  • initmesh, refinemesh and pdeInterpolant (with evaluate) on the existing deterministic mesher.

Browser console and Windows

  • Browser console (matrust.dev /try/): an operator chain taller than 1,024 levels gives the error "Expression tree exceeds 1024 levels". The desktop and command line allow 4,096. Parentheses stop at 128 levels everywhere.
  • Windows: the programs now reserve an 8 MiB main stack (it was 1 MiB).
  • Each cell or struct value holds up to 512 MiB on the desktop and command line (256 MiB in the browser), 65536 slots, or 16 levels.

Compatibility fixes from running real public scripts

A set of real public scripts is run on Windows each round and the commonest failures are fixed. In round 5 a script passes if it finishes without error within 600 s on Windows and, where GNU Octave finishes it, is faster than Octave. Octave was timed on a Linux machine; MatRust's time is from the Windows PC, which is the slower of the two (5 close cases were timed on the same Linux machine). Passing is not the same as giving correct results.

  • Result: 454 of 473 in-scope scripts pass (96 %), round 5. Of those, 252 finish faster than Octave; for the other 202, Octave stopped with an error (198) or did not finish within 600 s (4). The v0.1.3 figure, 273 of 515 (53.01 %), used the earlier rule (the script ran without error), so the two numbers are not comparable.
  • The set is smaller: 40 scripts left the in-scope set (515 to 475) after triage and were tagged upstream-error, and 2 more (475 to 473) in round 5: binomial2 passes a non-integer seed to rng, and Poisson3vemrate indexes with 0. The manifest stores the tag; the write-up for the 40 is in docs/corpus/round-4-triage.md. One of the 40 is a Finder alias, not a script.
  • The 19 that do not pass: 14 time out at 600 s, 4 stop with an error, and 1 is slower than Octave.

Behaviour changes

  • Rectangular least-squares solves with \ and / return the basic solution from pivoted QR and warn when the matrix is rank deficient.
  • isnan, isinf and isfinite on N-D arrays keep the input shape.
  • contourf creates one Contour object, so code that counted one child per level sees one.
  • A marker-only plot call creates a Line object.
  • linspace(a,b,n) with n at least 2 starts at a and ends at b.
  • A cell or struct value above the new limit (512 MiB desktop and command line, 256 MiB browser) gives an error.
  • struct() returns an empty scalar struct.
  • A blank default legend title is the same as no title.

Known gaps

  • In the browser console, an operator chain taller than 1,024 levels errors (desktop and command line: 4,096). Parentheses stop at 128 levels everywhere.
  • Not included in the PDE toolbox: 3-D geometry, STL import, structural, thermal and electromagnetic models, adaptmesh, assempde.
  • Not included in the UI components: uihtml, GUIDE .fig files, matlab.uitest, custom component authoring.
  • Video: uncompressed and Motion JPEG AVI work natively; reading other containers or AVI codecs needs both ffmpeg and ffprobe (absolute tool paths also work). DICOM: some compressed transfer syntaxes error with their UID; individual DICOM reads and writes refuse files over 256 MiB, while the collection browser lists larger files from bounded headers.
  • Not supported yet: complex single and complex integer values, ?Name metaclass syntax, enumeration object arrays.
  • A named desktop layout does not save Command-only mode; it restores as Editor. In Separate layout, a figure created during a run detaches once the desktop is idle.
  • Updating an existing .xlsx workbook with xlswrite keeps other sheets and cell values outside the written area as values. Formatting, formulas and charts are not kept. webread and websave need the system curl and only do http and https. pspectrum is not available.
  • Sound: on a real device, buffering can affect where playback resumes. Silent playback resumes at the paused sample.

Install

  • Homebrew: brew install leoom-labs/tap/matrust
  • Scoop: scoop bucket add matrust https://github.com/leoom-labs/scoop-bucket, then scoop install matrust
  • Or download an archive below.

Downloads

File System
MatRust-0.1.4-windows-x64.zip Windows, 64-bit (x64)
MatRust-0.1.4-linux-x64.tar.gz Linux, x86-64 (glibc 2.35 or newer: Ubuntu 22.04, Debian 12, Fedora 36 and later)
MatRust-0.1.4-linux-x64.AppImage Linux, x86-64, single file: chmod +x it and run (same glibc minimum)
MatRust-0.1.4-macos-arm64.tar.gz macOS on Apple silicon, unsigned
  • Each download has a .sha256 file next to it, so you can check that the file is complete and unchanged.
  • macOS: the programs are not signed. After unpacking, run once in Terminal: xattr -dr com.apple.quarantine <unpacked folder>, then start ./matrust-desktop from that folder.
  • Each archive holds three programs: matrust-desktop (the desktop app), matrust (the command line) and matrust-pdf-worker (a helper; keep it in the same folder).

License

GNU General Public License, version 3 or later. Third-party notices ship in each archive.

MATLAB is a registered trademark of The MathWorks, Inc. MatRust is not affiliated with, endorsed by, or sponsored by MathWorks.