Files
obitools4/autodoc/docmd/pkg/obiutils/array.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

24 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# `obiutils` Package: Semantic Overview
This Go package (`obiutils`) provides generic utilities for numerical and matrix operations, leveraging generics (Go 1.18+). It defines foundational types and helper functions for working with multidimensional data structures.
- **Type Interfaces**
- `Integer`: Constraint covering signed integer types (`int`, `int8``int64`).
- `Float`: Constraint for floating-point types (`float32`, `float64`).
- `Numeric`: Union of both, enabling generic numeric functions.
- **Data Structures**
- `Vector[T]`: A slice-based vector (`[]T`).
- `Matrix[T]`: A row-major representation of a 2D matrix (`[][]T`), backed by contiguous memory for performance.
- **Core Functions**
- `Make2DArray[T]`: Allocates a zero-initialized, contiguous-row-major matrix of arbitrary type `T`.
- `Make2DNumericArray[T]`: Same as above, but restricted to numeric types; optionally pre-fills with zeros if `zeroed=true`.
- **Matrix Methods**
- `.Column(i int)`: Extracts column `i` as a slice (not row-wise access).
- `.Rows(i ...int)`: Returns a new matrix containing only the specified row indices.
- `.Dim() (int, int)`: Returns `(rows, cols)` safely handling `nil` or empty matrices.
The design prioritizes memory efficiency (via contiguous backing arrays), type safety through generics, and ergonomic access patterns for linear algebra-like workflows.