Skip to content

Improve MATLAB bindings (SSMC pipeline, type minimization, allocator safety, tests)#25

Open
BenBrock wants to merge 46 commits into
mainfrom
Tim_matlab
Open

Improve MATLAB bindings (SSMC pipeline, type minimization, allocator safety, tests)#25
BenBrock wants to merge 46 commits into
mainfrom
Tim_matlab

Conversation

@BenBrock

Copy link
Copy Markdown
Contributor

Overview

  • Added end‑to‑end SSMC pipeline in MATLAB, expanded SSMC conversion to support dense inputs, and
    introduced comprehensive tests.
  • Improved type minimization (float→int, ISO pass) and allocator correctness for MATLAB MEX bindings.
  • Fixed empty‑array handling to avoid uninitialized reads and invalid class IDs.

Key changes

  • binsparse_from_ssmc
    • Supports dense vectors/matrices (DVEC/DMAT) and optional Zeros.
    • Default format is COO; dense inputs enforce DVEC/DMAT.
    • Uses allocator‑aware bsp_convert_matrix_allocator.
  • New MATLAB function generate_bsp_from_ssmc
    • Converts primary matrix and aux/x/b, minimizes types, writes to HDF5 root/aux groups.
    • Defaults: format='COO', compression_level=0.
  • New tests
    • test_generate_bsp_from_ssmc
    • test_binsparse_from_ssmc
    • test_binsparse_minimize_roundtrip
  • Type minimization upgrades
    • Downcast float→int when all values are integral.
    • ISO pass to compress equal‑valued arrays; special‑case iso[bint8] for value=1.
  • Allocator consistency and safety
    • Added bsp_convert_matrix_allocator and restored bsp_convert_matrix wrapper.
    • Removed mexMakeMemoryPersistent allocator in binsparse_read.c.
    • Fixed empty array conversions (now 0×1 with valid type fallback).
    • MATLAB helpers are header‑only; build scripts updated accordingly.

Files touched (high level)

  • bindings/matlab/
    • New: generate_bsp_from_ssmc.m, test_generate_bsp_from_ssmc.m
    • Updated: binsparse_from_ssmc.c, binsparse_minimize_types.c, binsparse_read.c,
      Contents.m, build scripts
    • Helpers now header‑only in matlab_bsp_helpers.h
  • include/binsparse/convert_matrix.h
    • Added allocator‑aware conversion API.

Notes

  • Metadata handling is intentionally deferred; string aux entries are currently ignored with a note.
  • HDF5 dataset ordering is not guaranteed unless link order is enabled in library code (unchanged).

Testing

  • build_matlab_bindings
  • test_generate_bsp_from_ssmc
  • test_binsparse_from_ssmc
  • test_binsparse_minimize_roundtrip

BenBrock and others added 30 commits August 18, 2025 13:23
…ders.

`binsparse_all.h` includes everything.
Base automatically changed from feature/matlab-bindings to feature/refactor-error-handling July 15, 2026 19:46
@BenBrock
BenBrock changed the base branch from feature/refactor-error-handling to main July 15, 2026 19:46
BenBrock and others added 3 commits July 15, 2026 22:19
Remove the six stale per-file compile scripts (superseded by
build_matlab_bindings / build_octave_bindings and broken against the
static-cJSON build) and the root Makefile scaffold.  Clean debug
leftovers out of build_matlab_bindings.m: restore the dead 'verbose'
flag, drop the always-on -g, remove variable echoes and stale
comments, and guard rpath on non-Unix platforms.

Move the SPDX header below the help comment block in the bindings .m
files: MATLAB's help shows the first comment block in a file, so a
leading SPDX block hid the real help text and filled Contents.m with
license boilerplate.  Replace the FIXME help stubs for binsparse_read,
binsparse_write, and binsparse_from_ssmc with real documentation,
hand-write Contents.m, and bring the README file table and examples in
line with the actual behavior.

Also remove a dead nnz assignment in matlab_bsp_helpers.h and replace
the static lock guards with mexIsLocked(), with comments explaining
why the HDF5-using MEX files stay locked.

All six MEX functions rebuild cleanly and all eight binding tests pass
in MATLAB R2025b.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants