1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
use crateLinearError;
use Vec;
use Zero;
/// Read access to a matrix: its shape, and its entries by value.
///
/// Every representation in this crate implements this, the compressed-sparse-row one included. It
/// is the half of the seam that carries no assumption about storage layout.
///
/// # Access is by value
///
/// `get` returns `Self::Scalar` rather than `&Self::Scalar`, because a bit-packed representation has
/// no element to lend a reference to — the entry exists as one bit inside a word, and there is no
/// `Gf2` in memory to point at. Returning by value costs nothing here: the scalars in this workspace
/// are `Clone`, and the ones that matter numerically are `Copy`.
///
/// # A structural zero is a zero
///
/// A sparse matrix stores only its non-zeros. Reading a position outside the stored pattern returns
/// `Self::Scalar::zero()` and is not an error — the entry is genuinely zero, and the caller asking
/// for it has done nothing wrong. Only an index outside the *shape* fails.
///
/// # Why `Zero` on the associated type
///
/// Two things need it, and neither is optional. The structural-zero rule above is one. The other is
/// [`RowOps::pivot_in_column`](crate::traits::row_ops::RowOps::pivot_in_column), whose default
/// implementation has to recognise a non-zero entry, and which would otherwise need a bound that
/// every caller of every elimination would have to repeat.