-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathspqr_tol.cpp
71 lines (57 loc) · 1.79 KB
/
spqr_tol.cpp
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
// =============================================================================
// === spqr_tol ================================================================
// =============================================================================
// SPQR, Copyright (c) 2008-2022, Timothy A Davis. All Rights Reserved.
// SPDX-License-Identifier: GPL-2.0+
//------------------------------------------------------------------------------
// Return the default column 2-norm tolerance
#include <limits>
#include <algorithm>
#include "spqr.hpp"
// return the default tol (-1 if error)
template <typename Entry, typename Int> double spqr_tol
(
// inputs, not modified
cholmod_sparse *A,
// workspace and parameters
cholmod_common *cc
)
{
RETURN_IF_NULL_COMMON (EMPTY) ;
RETURN_IF_NULL (A, EMPTY) ;
double tol = (20 * ((double) A->nrow + (double) A->ncol) * DBL_EPSILON *
spqr_maxcolnorm <Entry, Int> (A, cc));
// MathWorks modification: if the tolerance becomes Inf, replace it with
// realmax; otherwise, we may end up with an all-zero matrix R
// (see g1284493)
tol = std::min(tol, std::numeric_limits<double>::max());
return (tol) ;
}
template double spqr_tol <double, int32_t>
(
// inputs, not modified
cholmod_sparse *A,
// workspace and parameters
cholmod_common *cc
) ;
template double spqr_tol <Complex, int32_t>
(
// inputs, not modified
cholmod_sparse *A,
// workspace and parameters
cholmod_common *cc
) ;
template double spqr_tol <double, int64_t>
(
// inputs, not modified
cholmod_sparse *A,
// workspace and parameters
cholmod_common *cc
) ;
template double spqr_tol <Complex, int64_t>
(
// inputs, not modified
cholmod_sparse *A,
// workspace and parameters
cholmod_common *cc
) ;