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
pub struct LU {
    pub(crate) lu_size: i32,
    pub(crate) lu_nz: Vec<f64>,
    pub(crate) lu_rowind: Vec<i32>,
    pub(crate) l_colptr: Vec<i32>,
    pub(crate) u_colptr: Vec<i32>,

    pub(crate) row_perm: Vec<i32>,
    pub(crate) col_perm: Vec<i32>,
}

impl LU {
    pub(crate) fn new(nrow: i32, ncol: i32, lu_size: i32) -> Self {
        Self {
            lu_size,
            lu_nz: vec![0.0; lu_size as usize],
            lu_rowind: vec![0; lu_size as usize],
            l_colptr: vec![0; ncol as usize],
            u_colptr: vec![0; (ncol + 1) as usize],
            row_perm: vec![0; nrow as usize],
            col_perm: vec![0; ncol as usize],
        }
    }
}

pub struct GP {
    /// 0=none, 1=partial, 2=threshold
    pub pivot_policy: i32,
    pub pivot_threshold: f64,
    pub drop_threshold: f64,
    pub col_fill_ratio: f64,
    pub fill_ratio: f64,
    pub expand_ratio: f64,
    pub col_perm: Option<Vec<i32>>,
    // col_perm_length: i32,
    pub col_perm_base: i32,
    // statistics_reporter_t reporter_func;
    // void*                 reporter_ctxt;
}

impl Default for GP {
    fn default() -> Self {
        Self {
            pivot_policy: 1,
            pivot_threshold: 1.0,
            drop_threshold: 0.0,
            col_fill_ratio: -1.0,
            fill_ratio: 4.0,
            expand_ratio: 1.2,
            col_perm: None,
            // col_perm_length = 0;
            col_perm_base: 0, // reporter_func   = NULL;
        }
    }
}

pub struct CSC {
    pub m: i32,
    pub n: i32,
    pub nnz: i32,
    pub base: i32,
    pub colptr: Vec<i32>,
    pub rowind: Vec<i32>,
}