pub fn compute_sparse_cholesky(
    numthreads_: i32,
    ordermethod_: i32,
    tolsingular_: f64,
    anzc_: &[i32],
    aptrc_: &[i64],
    asubc_: &[i32],
    avalc_: &[f64],
    perm_: &mut Vec<i32>,
    diag_: &mut Vec<f64>,
    lnzc_: &mut Vec<i32>,
    lptrc_: &mut Vec<i64>,
    lensubnval_: &mut i64,
    lsubc_: &mut Vec<i32>,
    lvalc_: &mut Vec<f64>
) -> Result<(), String>
Expand description

Computes a Cholesky factorization of sparse matrix.

§Arguments

  • numthreads_ The number threads that can be used to do the computation. 0 means the code makes the choice.
  • ordermethod_ If nonzero, then a sparsity preserving ordering will be employed.
  • tolsingular_ A positive parameter controlling when a pivot is declared zero.
  • anzc_ anzc[j] is the number of nonzeros in the jth column of A.
  • aptrc_ aptrc[j] is a pointer to the first element in column j.
  • asubc_ Row indexes for each column stored in increasing order.
  • avalc_ The value corresponding to row indexed stored in asubc.
  • perm_ Permutation array used to specify the permutation matrix P computed by the function.
  • diag_ The diagonal elements of matrix D.
  • lnzc_ lnzc[j] is the number of non zero elements in column j.
  • lptrc_ lptrc[j] is a pointer to the first row index and value in column j.
  • lensubnval_ Number of elements in lsubc and lvalc.
  • lsubc_ Row indexes for each column stored in increasing order.
  • lvalc_ The values corresponding to row indexed stored in lsubc.

Full documentation: https://docs.mosek.com/latest/capi/alphabetic-functionalities.html#mosek.env.computesparsecholesky

Examples found in repository?
examples/sparsecholesky.rs (lines 60-65)
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
fn main() -> Result<(),String> {
    /* Create the mosek environment. */
    //Example from the manual
    //Observe that anzc, aptrc, asubc and avalc only specify the lower triangular part.
    let n     = 4;
    let anzc  = [4, 1, 1, 1];
    let asubc = [0, 1, 2, 3, 1, 2, 3];
    let aptrc = [0, 4, 5, 6];
    let avalc = [4.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
    let b     = [13.0, 3.0, 4.0, 5.0];

    let mut perm   = Vec::new();
    let mut lnzc   = Vec::new();
    let mut lsubc  = Vec::new();
    let mut diag   = Vec::new();
    let mut lptrc  = Vec::new();
    let mut lvalc  = Vec::new();
    let mut lensubnval = 0;

    mosek::compute_sparse_cholesky(0,        //Mosek chooses number of threads
                                   1,        //Apply reordering heuristic
                                   1.0e-14,  //Singularity tolerance
                                   &anzc, &aptrc, &asubc, &avalc,
                                   & mut perm, & mut diag,
                                   & mut lnzc, & mut lptrc, & mut lensubnval, & mut lsubc, & mut lvalc)?;
    print_sparse(n, perm.as_slice(), diag.as_slice(), lnzc.as_slice(), lptrc.as_slice(), lsubc.as_slice(), lvalc.as_slice());

    /* Permuted b is stored as x. */
    let mut x : Vec<f64> = perm.iter().map(|&i| b[i as usize]).collect();

    /*Compute  inv(L)*x.*/
    mosek::sparse_triangular_solve_dense(Transpose::NO,  lnzc.as_slice(), lptrc.as_slice(), lsubc.as_slice(), lvalc.as_slice(), x.as_mut_slice())?;
    /*Compute  inv(L^T)*x.*/
    mosek::sparse_triangular_solve_dense(Transpose::YES, lnzc.as_slice(), lptrc.as_slice(), lsubc.as_slice(), lvalc.as_slice(), x.as_mut_slice())?;

    print!("\nSolution A x = b, x = [ {:?} ]",
           iproduct!(0..n,izip!(perm.iter(),x.iter()))
           .filter_map(|(i,(&pj,&xj))|if pj as usize == i { Some(xj) } else { None })
           .collect::<Vec<f64>>());
    let n     = 3;
    let anzc  = [3, 2, 1];
    let asubc = [0, 1, 2, 1, 2, 2];
    let aptrc = [0, 3, 5, ];
    let avalc = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0];

    let mut perm   = Vec::new();
    let mut lnzc   = Vec::new();
    let mut lsubc  = Vec::new();
    let mut diag   = Vec::new();
    let mut lptrc  = Vec::new();
    let mut lvalc  = Vec::new();
    let mut lensubnval = 0;

    mosek::compute_sparse_cholesky(0,        //Mosek chooses number of threads
                                   1,        //Apply reordering heuristic
                                   1.0e-14,  //Singularity tolerance
                                   &anzc, &aptrc, &asubc, &avalc,
                                   & mut perm, & mut diag,
                                   & mut lnzc, & mut lptrc, & mut lensubnval, & mut lsubc, & mut lvalc)?;

    print_sparse(n, perm.as_slice(), diag.as_slice(), lnzc.as_slice(), lptrc.as_slice(), lsubc.as_slice(), lvalc.as_slice());

    Ok(())
}