Expand description
§use-linear
Small linear-system helpers for RustUse.
Solver-style helpers that build on use-matrix and use-vector instead of redefining primitives.
§Install
[dependencies]
use-linear = "0.0.5"
use-matrix = "0.0.5"
use-vector = "0.0.5"§Foundation
use-linear provides a deliberately small linear-algebra surface focused on
algorithms that compose the primitive crates. The current slice includes
solve_2x2 plus LinearError for explicit handling of singular or non-finite
systems. Matrix primitives live in use-matrix, and vector primitives live in
use-vector.
Algorithm layersolve_2x2 solves small systems without redefining the underlying matrix or vector types.
|
Explicit errorsLinearError keeps singular and non-finite solve failures visible at the call site.
|
Focused composition Pair use-linear with use-matrix and use-vector when the primitive ownership boundaries matter.
|
| Helper group | Primary items | Best fit |
|---|---|---|
| Solves and error handling | solve_2x2, LinearError | Small systems where singular behavior should stay explicit |
| Neighbor primitives | use-matrix, use-vector | Call sites that want focused matrix and vector ownership boundaries |
§When to use directly
Choose use-linear directly when solve-oriented helpers are the only linear
surface you need and you want primitive ownership to stay in neighboring crates.
| Scenario | Use use-linear directly? | Why |
|---|---|---|
| You need explicit handling of singular 2×2 solves | Yes | The API keeps solve failures visible through LinearError |
| You want matrix and vector types to stay in focused crates | Yes | use-linear composes use-matrix and use-vector instead of redefining them |
| You also need geometry, calculus, or other math domains | Usually no | use-math can compose the concrete surfaces behind features |
§Scope
use-matrixowns matrix primitives and direct matrix operations.use-vectorowns vector primitives and vector operations.use-linearowns higher-level linear algorithms over those primitives.- The crate intentionally does not define its own matrix/vector types, geometry transforms, or decomposition frameworks.
§Examples
§Solving a 2x2 system
use use_linear::solve_2x2;
use use_matrix::Matrix2;
use use_vector::Vector2;
let matrix = Matrix2::new(2.0, 1.0, 5.0, 3.0);
let rhs = Vector2::new(1.0, 2.0);
assert_eq!(solve_2x2(matrix, rhs)?, Vector2::new(1.0, -1.0));§Handling singular systems
use use_linear::{LinearError, solve_2x2};
use use_matrix::Matrix2;
use use_vector::Vector2;
let matrix = Matrix2::new(1.0, 2.0, 2.0, 4.0);
let rhs = Vector2::new(1.0, 2.0);
assert_eq!(
solve_2x2(matrix, rhs),
Err(LinearError::SingularMatrix { determinant: 0.0 })
);§Status
use-linear is a concrete pre-1.0 crate in the RustUse math workspace. The
API remains intentionally small while use-matrix and use-vector own the
primitive surface and adjacent crates continue to grow around them.
Linear-algebra utilities for RustUse.
Modules§
- prelude
- Common ergonomic imports for
use-linear.
Enums§
- Linear
Error - Errors returned by linear helpers when a system cannot be solved.
Functions§
- solve_
2x2 - Solves
matrix * x = rhsforx.