Crates.io | compressed-sparse-fiber |
lib.rs | compressed-sparse-fiber |
version | 0.0.6 |
source | src |
created_at | 2021-03-30 09:42:14.608393 |
updated_at | 2022-02-21 16:54:41.219109 |
description | Compressed sparse fiber implementation for Rust |
homepage | |
repository | https://github.com/solidm/compressed-sparse-fiber |
max_upload_size | |
id | 375695 |
size | 23,798 |
CSF is a generalization of compressed sparse row (CSR) index. See smith2017knl
CSF index recursively compresses each dimension of a tensor into a set of prefix trees. Each path from a root to leaf forms one tensor non-zero index. CSF is implemented with two arrays of buffers and one arrays of integers.
let rows = vec![
(vec![1, 1, 1, 2], 1.0),
(vec![1, 1, 1, 3], 2.0),
(vec![1, 2, 1, 1], 3.0),
(vec![1, 2, 1, 3], 4.0),
(vec![1, 2, 2, 1], 5.0),
(vec![2, 2, 2, 1], 6.0),
(vec![2, 2, 2, 2], 7.0),
(vec![2, 2, 2, 3], 8.0),
];
let csf: CompressedSparseFiber<_,_> = rows.into_iter().collect();
The above could be represented by a structure like this:
CompressedSparseFiber {
fptr: [[0, 2, 3], [0, 1, 3, 4], [0, 2, 4, 5, 8]],
fids: [[1, 2], [1, 2, 2], [1, 1, 2, 2], [2, 3, 1, 3, 1, 1, 2, 3]],
vals: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
}
for t in csf {
println!("{:?}", t);
}