Amesos2 - Direct Sparse Solver Interfaces  Version of the Day
klu2_defaults.hpp
1 /* ========================================================================== */
2 /* === KLU_defaults ========================================================= */
3 /* ========================================================================== */
4 // @HEADER
5 // *****************************************************************************
6 // KLU2: A Direct Linear Solver package
7 //
8 // Copyright 2011 NTESS and the KLU2 contributors.
9 // SPDX-License-Identifier: LGPL-2.1-or-later
10 // *****************************************************************************
11 // @HEADER
12 
13 /* Sets default parameters for KLU */
14 #ifndef KLU2_DEFAULTS_HPP
15 #define KLU2_DEFAULTS_HPP
16 
17 #include "klu2_internal.h"
18 
19 template <typename Entry, typename Int>
20 Int KLU_defaults
21 (
22  KLU_common<Entry, Int> *Common
23 )
24 {
25  if (Common == NULL)
26  {
27  return (FALSE) ;
28  }
29 
30  /* parameters */
31  Common->tol = 0.001 ; /* pivot tolerance for diagonal */
32  Common->memgrow = 1.2; /* realloc size ratio increase for LU factors */
33  Common->initmem_amd = 1.2 ; /* init. mem with AMD: c*nnz(L) + n */
34  Common->initmem = 10 ; /* init. mem otherwise: c*nnz(A) + n */
35  Common->btf = TRUE ; /* use BTF pre-ordering, or not */
36  Common->maxwork = 0 ; /* no limit to work done by btf_order */
37  Common->ordering = 0 ; /* 0: AMD, 1: COLAMD, 2: user-provided P and Q,
38  * 3: user-provided function */
39  Common->scale = 2 ; /* scale: -1: none, and do not check for errors
40  * in the input matrix in KLU_refactor.
41  * 0: none, but check for errors,
42  * 1: sum, 2: max */
43  Common->halt_if_singular = TRUE ; /* quick halt if matrix is singular */
44 
45  /* memory management routines */
46  Common->malloc_memory = malloc ;
47  Common->calloc_memory = calloc ;
48  Common->free_memory = free ;
49  Common->realloc_memory = realloc ;
50 
51  /* user ordering function and optional argument */
52  Common->user_order = NULL ;
53  Common->user_data = NULL ;
54 
55  /* statistics */
56  Common->status = KLU_OK ;
57  Common->nrealloc = 0 ;
58  Common->structural_rank = AMESOS2_KLU2_EMPTY ;
59  Common->numerical_rank = AMESOS2_KLU2_EMPTY ;
60  Common->noffdiag = AMESOS2_KLU2_EMPTY ;
61  Common->flops = AMESOS2_KLU2_EMPTY ;
62  Common->rcond = AMESOS2_KLU2_EMPTY ;
63  Common->condest = AMESOS2_KLU2_EMPTY ;
64  Common->rgrowth = AMESOS2_KLU2_EMPTY ;
65  Common->work = 0 ; /* work done by btf_order */
66 
67  Common->memusage = 0 ;
68  Common->mempeak = 0 ;
69 
70  return (TRUE) ;
71 }
72 
73 #endif