Amesos2 - Direct Sparse Solver Interfaces Version of the Day
klu2_defaults.hpp
1/* ========================================================================== */
2/* === KLU_defaults ========================================================= */
3/* ========================================================================== */
4// @HEADER
5// ***********************************************************************
6//
7// KLU2: A Direct Linear Solver package
8// Copyright 2011 Sandia Corporation
9//
10// Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
11// U.S. Government retains certain rights in this software.
12//
13// This library is free software; you can redistribute it and/or modify
14// it under the terms of the GNU Lesser General Public License as
15// published by the Free Software Foundation; either version 2.1 of the
16// License, or (at your option) any later version.
17//
18// This library is distributed in the hope that it will be useful, but
19// WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21// Lesser General Public License for more details.
22//
23// You should have received a copy of the GNU Lesser General Public
24// License along with this library; if not, write to the Free Software
25// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
26// USA
27// Questions? Contact Mike A. Heroux (maherou@sandia.gov)
28//
29// KLU2 is derived work from KLU, licensed under LGPL, and copyrighted by
30// University of Florida. The Authors of KLU are Timothy A. Davis and
31// Eka Palamadai. See Doc/KLU_README.txt for the licensing and copyright
32// information for KLU.
33//
34// ***********************************************************************
35// @HEADER
36
37/* Sets default parameters for KLU */
38#ifndef KLU2_DEFAULTS_HPP
39#define KLU2_DEFAULTS_HPP
40
41#include "klu2_internal.h"
42
43template <typename Entry, typename Int>
44Int KLU_defaults
45(
46 KLU_common<Entry, Int> *Common
47)
48{
49 if (Common == NULL)
50 {
51 return (FALSE) ;
52 }
53
54 /* parameters */
55 Common->tol = 0.001 ; /* pivot tolerance for diagonal */
56 Common->memgrow = 1.2; /* realloc size ratio increase for LU factors */
57 Common->initmem_amd = 1.2 ; /* init. mem with AMD: c*nnz(L) + n */
58 Common->initmem = 10 ; /* init. mem otherwise: c*nnz(A) + n */
59 Common->btf = TRUE ; /* use BTF pre-ordering, or not */
60 Common->maxwork = 0 ; /* no limit to work done by btf_order */
61 Common->ordering = 0 ; /* 0: AMD, 1: COLAMD, 2: user-provided P and Q,
62 * 3: user-provided function */
63 Common->scale = 2 ; /* scale: -1: none, and do not check for errors
64 * in the input matrix in KLU_refactor.
65 * 0: none, but check for errors,
66 * 1: sum, 2: max */
67 Common->halt_if_singular = TRUE ; /* quick halt if matrix is singular */
68
69 /* memory management routines */
70 Common->malloc_memory = malloc ;
71 Common->calloc_memory = calloc ;
72 Common->free_memory = free ;
73 Common->realloc_memory = realloc ;
74
75 /* user ordering function and optional argument */
76 Common->user_order = NULL ;
77 Common->user_data = NULL ;
78
79 /* statistics */
80 Common->status = KLU_OK ;
81 Common->nrealloc = 0 ;
82 Common->structural_rank = AMESOS2_KLU2_EMPTY ;
83 Common->numerical_rank = AMESOS2_KLU2_EMPTY ;
84 Common->noffdiag = AMESOS2_KLU2_EMPTY ;
85 Common->flops = AMESOS2_KLU2_EMPTY ;
86 Common->rcond = AMESOS2_KLU2_EMPTY ;
87 Common->condest = AMESOS2_KLU2_EMPTY ;
88 Common->rgrowth = AMESOS2_KLU2_EMPTY ;
89 Common->work = 0 ; /* work done by btf_order */
90
91 Common->memusage = 0 ;
92 Common->mempeak = 0 ;
93
94 return (TRUE) ;
95}
96
97#endif