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
use super::{Matching, Ordering, Pivoting, Scaling};
/// Defines the configuration parameters for the linear system solver
#[derive(Clone, Copy, Debug)]
pub struct LinSolParams {
/// Defines the symmetric permutation (ordering)
pub ordering: Ordering,
/// Defines the scaling strategy
pub scaling: Scaling,
/// Defines the matching algorithm (cuDSS only)
pub matching: Matching,
/// Defines the pivoting strategy (cuDSS only)
pub pivoting: Pivoting,
/// Pivoting epsilon (cuDSS only)
///
/// This is the absolute value to test and replace small diagonal elements encountered during numerical factorization.
///
/// `None` will let cuDSS select the default value. Currently, the default value for double precision is `1e-13`.
///
/// See: <https://docs.nvidia.com/cuda/cudss/types.html#c.cudssConfigParam_t.CUDSS_CONFIG_PIVOT_EPSILON>
pub pivot_epsilon: Option<f64>,
/// Sets the number of iterative refinement steps (cuDSS only)
///
/// When > 0, the solver performs iterative refinement with the specified number of steps. Set to 0 to disable.
///
/// `None` will let cuDSS select the default value. Currently, the default value is `0` (disabled).
///
/// See: <https://docs.nvidia.com/cuda/cudss/types.html#c.cudssConfigParam_t.CUDSS_CONFIG_IR_N_STEPS>
pub refinement_nstep: Option<i32>,
/// Enables the hybrid memory mode for cuDSS (holds a factor from 0.01 to 0.99)
///
/// `None` means that the hybrid mode is not enabled.
pub hybrid_memory_factor: Option<f64>,
/// Indicates that the coefficient matrix is positive-definite (only considered if the matrix is symmetric)
pub positive_definite: bool,
/// Requests that the determinant be computed
///
/// **Note:** The determinant will be available after `factorize`
pub compute_determinant: bool,
/// Requests that the error estimates be computed
///
/// **Note:** Will need to use the `actual` solver to access the results.
pub compute_error_estimates: bool,
/// Requests that condition numbers be computed
///
/// **Note:** Will need to use the `actual` solver to access the results.
pub compute_condition_numbers: bool,
/// Sets the % increase in the estimated working space (MUMPS only)
///
/// **Note:** The default (recommended) value is 100 (%)
pub mumps_pct_inc_workspace: usize,
/// Sets the max size of the working memory in mega bytes (MUMPS only)
///
/// **Note:** Set this value to 0 for an automatic configuration
pub mumps_max_work_memory: usize,
/// Defines the number of threads for MUMPS
///
/// **Note:** Set this value to 0 to allow an automatic detection
pub mumps_num_threads: usize,
/// Overrides the prevention of number-of-threads issue with OpenBLAS (not recommended)
pub mumps_override_prevent_nt_issue_with_openblas: bool,
/// Enforces the unsymmetric strategy, even for symmetric matrices (not recommended; UMFPACK only)
pub umfpack_enforce_unsymmetric_strategy: bool,
/// Show additional messages
pub verbose: bool,
}
impl LinSolParams {
/// Allocates a new instance with default values
pub fn new() -> Self {
LinSolParams {
ordering: Ordering::Auto,
scaling: Scaling::Auto,
matching: Matching::None,
pivoting: Pivoting::Auto,
pivot_epsilon: None,
refinement_nstep: None,
hybrid_memory_factor: None,
positive_definite: false,
compute_determinant: false,
compute_error_estimates: false,
compute_condition_numbers: false,
mumps_pct_inc_workspace: 100,
mumps_max_work_memory: 0,
mumps_num_threads: 0,
mumps_override_prevent_nt_issue_with_openblas: false,
umfpack_enforce_unsymmetric_strategy: false,
verbose: false,
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#[cfg(test)]
mod tests {
use super::LinSolParams;
use crate::{Ordering, Scaling};
#[test]
fn clone_copy_and_debug_work() {
let params = LinSolParams::new();
let copy = params;
let clone = params.clone();
assert!(format!("{:?}", params) == format!("{:?}", copy));
assert!(format!("{:?}", params) == format!("{:?}", clone));
}
#[test]
fn lin_sol_params_new_works() {
let params = LinSolParams::new();
assert_eq!(params.ordering, Ordering::Auto);
assert_eq!(params.scaling, Scaling::Auto);
assert_eq!(params.compute_determinant, false);
assert_eq!(params.mumps_pct_inc_workspace, 100);
assert_eq!(params.mumps_max_work_memory, 0);
assert_eq!(params.mumps_num_threads, 0);
assert!(!params.umfpack_enforce_unsymmetric_strategy);
}
}