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
//! CSC (Compressed Sparse Column) layout descriptor.
//!
//! Tag `0x08`. Rank MUST be 2. Buffer count = 3 (values + row_indices + col_ptr).
//! See `docs/spec/layouts/csc.md`.
/// Descriptor for the CSC (Compressed Sparse Column) sparse layout.
///
/// CSC is the column analog of CSR and is defined **only for rank-2 tensors**.
/// A conforming implementation MUST reject a CSC descriptor whose tensor rank
/// is not 2 (checked by [`crate::layout::LayoutDescriptor::validate_against_shape`]).
///
/// Three buffers are required:
///
/// | Buffer | Contents |
/// |--------|----------|
/// | 0 — `values` | Non-zero values in column-major order; `nnz` elements. |
/// | 1 — `row_indices` | Row index of each non-zero; `nnz` `uint64` elements. |
/// | 2 — `col_ptr` | Column pointer array; `ncols + 1` `uint64` elements where `ncols = shape[1]`. |
///
/// The `byte_offset` field MUST be `0` for CSC tensors.
///
/// > Also known as **CCS (Compressed Column Storage)**.
///
/// # Examples
///
/// ```
/// use hurray_core::layout::{CscLayout, LayoutDescriptor};
///
/// let layout = LayoutDescriptor::Csc(CscLayout::new(5));
/// assert_eq!(layout.tag(), 0x08);
/// assert_eq!(layout.buffer_count().map(|n| n.get()), Some(3));
/// ```