/usr/include/trilinos/Amesos2_KLU2_decl.hpp is in libtrilinos-amesos2-dev 12.10.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | // @HEADER
//
// ***********************************************************************
//
// Amesos2: Templated Direct Sparse Solver Package
// Copyright 2011 Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
//
// @HEADER
/**
\file Amesos2_KLU2_decl.hpp
\author Siva Rajamanickam <srajama@sandia.gov>
\brief Amesos2 KLU2 declarations.
*/
#ifndef AMESOS2_KLU2_DECL_HPP
#define AMESOS2_KLU2_DECL_HPP
#include "Amesos2_SolverTraits.hpp"
#include "Amesos2_SolverCore.hpp"
#include "Amesos2_KLU2_FunctionMap.hpp"
namespace Amesos2 {
/** \brief Amesos2 interface to the KLU2 package.
*
* See the \ref KLU2_parameters "summary of KLU2 parameters"
* supported by this Amesos2 interface.
*
* \ingroup amesos2_solver_interfaces
*/
template <class Matrix,
class Vector>
class KLU2 : public SolverCore<Amesos2::KLU2, Matrix, Vector>
{
friend class SolverCore<Amesos2::KLU2,Matrix,Vector>; // Give our base access
// to our private
// implementation funcs
public:
/// Name of this solver interface.
static const char* name; // declaration. Initialization outside.
typedef KLU2<Matrix,Vector> type;
typedef SolverCore<Amesos2::KLU2,Matrix,Vector> super_type;
// Since typedef's are not inheritted, go grab them
typedef typename super_type::scalar_type scalar_type;
typedef typename super_type::local_ordinal_type local_ordinal_type;
typedef typename super_type::global_ordinal_type global_ordinal_type;
typedef typename super_type::global_size_type global_size_type;
typedef TypeMap<Amesos2::KLU2,scalar_type> type_map;
/*
* The KLU2 interface will need two other typedef's, which are:
* - the KLU2 type that corresponds to scalar_type and
* - the corresponding type to use for magnitude
*/
typedef typename type_map::type slu_type;
typedef typename type_map::magnitude_type magnitude_type;
typedef FunctionMap<Amesos2::KLU2,slu_type> function_map;
/// \name Constructor/Destructor methods
//@{
/**
* \brief Initialize from Teuchos::RCP.
*
* \warning Should not be called directly! Use instead
* Amesos2::create() to initialize a KLU2 interface.
*/
KLU2(Teuchos::RCP<const Matrix> A,
Teuchos::RCP<Vector> X,
Teuchos::RCP<const Vector> B);
/// Destructor
~KLU2( );
//@}
private:
/**
* \brief Performs pre-ordering on the matrix to increase efficiency.
*
* KLU2 does not support pre-ordering, so this method does nothing.
*/
int preOrdering_impl();
/**
* \brief Perform symbolic factorization of the matrix using KLU2.
*
* Called first in the sequence before numericFactorization.
*
* \throw std::runtime_error KLU2 is not able to factor the matrix.
*/
int symbolicFactorization_impl();
/**
* \brief KLU2 specific numeric factorization
*
* \throw std::runtime_error KLU2 is not able to factor the matrix
*/
int numericFactorization_impl();
/**
* \brief KLU2 specific solve.
*
* Uses the symbolic and numeric factorizations, along with the RHS
* vector \c B to solve the sparse system of equations. The
* solution is placed in X.
*
* \throw std::runtime_error KLU2 is not able to solve the system.
*
* \callgraph
*/
int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X,
const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const;
/**
* \brief Determines whether the shape of the matrix is OK for this solver.
*/
bool matrixShapeOK_impl() const;
/**
* Currently, the following KLU2 parameters/options are
* recognized and acted upon:
*
* <ul>
* <li> \c "Trans" : { \c "NOTRANS" | \c "TRANS" |
* \c "CONJ" }. Specifies whether to solve with the transpose system.</li>
* <li> \c "Equil" : { \c true | \c false }. Specifies whether
* the solver to equilibrate the matrix before solving.</li>
* <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA"
* }. Specifies whether to perform iterative refinement, and in
* what precision to compute the residual.</li>
* <li> \c "SymmetricMode" : { \c true | \c false }.</li>
* <li> \c "DiagPivotThresh" : \c double value. Specifies the threshold
* used for a diagonal to be considered an acceptable pivot.</li>
* <li> \c "ColPerm" which takes one of the following:
* <ul>
* <li> \c "NATURAL" : natural ordering.</li>
* <li> \c "MMD_AT_PLUS_A" : minimum degree ordering on the structure of
* \f$ A^T + A\f$ .</li>
* <li> \c "MMD_ATA" : minimum degree ordering on the structure of
* \f$ A T A \f$ .</li>
* <li> \c "COLAMD" : approximate minimum degree column ordering.
* (default)</li>
* </ul>
* </ul>
*/
void setParameters_impl(
const Teuchos::RCP<Teuchos::ParameterList> & parameterList );
/**
* Hooked in by Amesos2::SolverCore parent class.
*
* \return a const Teuchos::ParameterList of all valid parameters for this
* solver.
*/
Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const;
/**
* \brief Reads matrix data into internal structures
*
* \param [in] current_phase an indication of which solution phase this
* load is being performed for.
*
* \return \c true if the matrix was loaded, \c false if not
*/
bool loadA_impl(EPhase current_phase);
// struct holds all data necessary for KLU2 factorization or solve call
mutable struct KLU2Data {
::KLU2::klu_symbolic<slu_type, local_ordinal_type> *symbolic_;
::KLU2::klu_numeric<slu_type, local_ordinal_type> *numeric_;
::KLU2::klu_common<slu_type, local_ordinal_type> common_;
} data_ ;
// The following Arrays are persisting storage arrays for A, X, and B
/// Stores the values of the nonzero entries for KLU2
Teuchos::Array<slu_type> nzvals_;
/// Stores the location in \c Ai_ and Aval_ that starts row j
Teuchos::Array<local_ordinal_type> rowind_;
/// Stores the row indices of the nonzero entries
Teuchos::Array<local_ordinal_type> colptr_;
/// Persisting 1D store for X
Teuchos::Array<slu_type> xvals_; local_ordinal_type ldx_;
/// Persisting 1D store for B
Teuchos::Array<slu_type> bvals_; local_ordinal_type ldb_;
/// Transpose flag
/// 0: Non-transpose, 1: Transpose, 2: Conjugate-transpose
int transFlag_;
}; // End class KLU2
// Specialize solver_traits struct for KLU2
// TODO
template <>
struct solver_traits<KLU2> {
#ifdef HAVE_TEUCHOS_COMPLEX
typedef Meta::make_list4<float,
double,
std::complex<float>,
std::complex<double> > supported_scalars;
#else
typedef Meta::make_list2<float, double> supported_scalars;
#endif
};
} // end namespace Amesos2
#endif // AMESOS2_KLU2_DECL_HPP
|