Mat (C) — Print Helpers & Convenience Wrapper¶
Overview¶
tiny_mat.h serves two purposes in the post-refactoring TinyMath:
- Print helpers — debug-print matrices to serial console
- Convenience header — includes all submodules for backward compatibility
Header: #include "tiny_mat.h"
Architecture¶
Since the refactoring that split the original monolithic tiny_mat.c (1920 lines) into dedicated submodules, tiny_mat.h is now a thin wrapper:
tiny_mat.h
├── #include "tiny_linalg.h" → element-wise ops
├── #include "tiny_cfloat.h" → complex arithmetic
├── #include "tiny_decomp.h" → matrix decomposition
├── #include "tiny_eigen.h" → eigenvalue computation
├── #include "tiny_modal.h" → modal analysis
└── #include "tiny_iterative.h" → Krylov methods & RSVD
(plus print_matrix declarations)
Backward Compatibility
Existing code that uses #include "tiny_mat.h" continues to work without changes — all functions are re-exported through the submodule includes.
Print Functions¶
Prints a contiguous matrix (no padding, row-major).
| Param | Description |
|---|---|
name | Label printed before the matrix |
mat | Row-major matrix data |
rows | Number of rows |
cols | Number of columns |
Output:
Prints a matrix with row padding. step = logical columns + padding.
| Param | Description |
|---|---|
name | Label printed before the matrix |
mat | Row-major matrix data |
rows | Number of rows |
cols | Number of logical columns to display |
step | Total elements per row (including padding) |
Platform Support¶
Both functions use printf() from <stdio.h> — no platform-specific dispatch.
Usage¶
#include "tiny_mat.h"
// Print a 2×3 matrix
float A[6] = {1, 2, 3, 4, 5, 6};
print_matrix("A", A, 2, 3);
// Print the same matrix with padding info
print_matrix_padded("A (padded)", A, 2, 3, 3); // step = cols (no padding)
// All submodule functions are also available:
tiny_cfloat_t z = tiny_cf(1.0f, 2.0f);
Related Pages¶
For detailed function documentation, see the dedicated submodule pages:
| Module | Page |
|---|---|
| Vector operations | VECTOR API |
| Basic linear algebra | LINALG API |
| Complex numbers | CFLOAT API |
| Matrix decomposition | DECOMP API |
| Eigenvalue & modal | EIGEN API |
| Iterative methods | ITERATIVE API |