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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#![deny(warnings)]
#[cfg(feature = "alga")]
extern crate alga;
extern crate ndarray;
extern crate num_complex;
extern crate num_traits;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[cfg(test)]
extern crate tempdir;
pub mod array_backend;
pub mod errors;
pub mod indexing;
pub mod io;
mod num_kinds;
mod sparse;
pub mod stack;
pub type Ix_ = ndarray::Ix1;
pub type Ix1 = ndarray::Ix1;
pub type Ix2 = ndarray::Ix2;
pub use indexing::SpIndex;
pub use sparse::{
CsMat, CsMatBase, CsMatI, CsMatVecView, CsMatView, CsMatViewI,
CsMatViewMut, CsMatViewMutI, CsVec, CsVecBase, CsVecI, CsVecView,
CsVecViewI, CsVecViewMut, CsVecViewMutI, SparseMat, TriMat, TriMatBase,
TriMatI, TriMatIter, TriMatView, TriMatViewI, TriMatViewMut,
TriMatViewMutI,
};
pub use sparse::symmetric::is_symmetric;
pub use sparse::permutation::{
PermOwned, PermOwnedI, PermView, PermViewI, Permutation,
};
pub use sparse::CompressedStorage::{self, CSC, CSR};
pub use sparse::binop;
pub use sparse::linalg;
pub use sparse::prod;
pub mod vec {
pub use sparse::{CsVec, CsVecBase, CsVecView, CsVecViewMut};
pub use sparse::vec::{
IntoSparseVecIter, NnzEither, NnzIndex, NnzOrZip, SparseIterTools,
VecDim, VectorIterator, VectorIteratorMut,
};
}
pub use sparse::construct::{bmat, hstack, vstack};
pub use sparse::to_dense::assign_to_dense;
pub type Shape = (usize, usize);
pub type SpRes<T> = Result<T, errors::SprsError>;
#[cfg(test)]
mod test_data;
#[cfg(test)]
mod test {
use super::CsMat;
#[test]
fn iter_rbr() {
let mat = CsMat::new(
(3, 3),
vec![0, 2, 3, 3],
vec![1, 2, 0],
vec![0.1, 0.2, 0.3],
);
let view = mat.view();
let mut iter = view.iter();
assert_eq!(iter.next(), Some((&0.1, (0, 1))));
assert_eq!(iter.next(), Some((&0.2, (0, 2))));
assert_eq!(iter.next(), Some((&0.3, (1, 0))));
assert_eq!(iter.next(), None);
}
}