triangle_matrix
Upper and lower triangle matrix indexing operations.
Provides indexing operations for one dimensional collections using
Index<usize>
. Requires implementing [Triangle
] for any Index<usize>
type, and optionally [TriangleMut
] for any IndexMut<usize>
type.
Usage requires delegation to the collection, and the axis length, n
.
use crate;
// A vector represented as a triangle matrix.
;
Triangle matrix types
For all types, the indices i
and j
refer to rows and columns respectively.
The indices of a diagonal element (i == j
) are out of bounds for all types.
Simple Upper Triangle ([SimpleUpperTri
], [SimpleUpperTriMut
])
Indexing operations for an upper triangle matrix with no diagonal elements.
Allows getting the element or one dimensional index for any i
and j
indices
where i < j
. Does not allow indexing into rows or columns outside of the
triangle.
use crate SimpleUpperTri;
let n = 5;
let m = TriVec;
// Get the elements of rows 0..4.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Symmetric Upper Triangle ([SymmetricUpperTri
], [SymmetricUpperTriMut
])
Indexing operations for a symmetric upper triangle matrix with no diagonal
elements. Allows getting the element or one dimensional index for any i
and
j
indices where any pair of (i, j)
indices is equal to the pair, (j, i)
.
Does not allow indexing into rows or columns outside of the triangle.
use crate SymmetricUpperTri;
let n = 5;
let m = TriVec;
// Get the elements of rows 0..5.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Simple Lower Triangle ([SimpleLowerTri
], [SimpleLowerTriMut
])
Indexing operations for a lower triangle matrix with no diagonal elements.
Allows getting the element or one dimensional index for any i
and j
indices
where j < i
. Does not allow indexing into rows or columns outside of the
triangle.
let n = 5;
let m = TriVec;
// Get the elements of rows 1..4.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Symmetric Lower Triangle ([SymmetricLowerTri
], [SymmetricLowerTriMut
])
Indexing operations for a symmetric lower triangle matrix with no diagonal
elements. Allows getting the element or one dimensional index for any i
and
j
indices where any pair of (i, j)
indices is equal to the pair, (j, i)
.
Does not allow indexing into rows or columns outside of the triangle.
use crate SymmetricLowerTri;
let n = 5;
let m = TriVec;
// Get the elements of rows 0..5.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;