/usr/include/trilinos/Amesos2_Superlu_decl.hpp is in libtrilinos-amesos2-dev 12.4.2-2.
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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | // @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_Superlu_decl.hpp
\author Eric Bavier <etbavier@sandia.gov>
\date Thu Jul 8 22:52:34 2010
\brief Amesos2 Superlu declarations.
*/
#ifndef AMESOS2_SUPERLU_DECL_HPP
#define AMESOS2_SUPERLU_DECL_HPP
#include "Amesos2_SolverTraits.hpp"
#include "Amesos2_SolverCore.hpp"
#include "Amesos2_Superlu_FunctionMap.hpp"
namespace Amesos2 {
/** \brief Amesos2 interface to the SuperLU package.
*
* See the \ref superlu_parameters "summary of SuperLU parameters"
* supported by this Amesos2 interface.
*
* \ingroup amesos2_solver_interfaces
*/
template <class Matrix,
class Vector>
class Superlu : public SolverCore<Amesos2::Superlu, Matrix, Vector>
{
friend class SolverCore<Amesos2::Superlu,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 Superlu<Matrix,Vector> type;
typedef SolverCore<Amesos2::Superlu,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::Superlu,scalar_type> type_map;
/*
* The SuperLU interface will need two other typedef's, which are:
* - the superlu 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::Superlu,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 Superlu interface.
*/
Superlu(Teuchos::RCP<const Matrix> A,
Teuchos::RCP<Vector> X,
Teuchos::RCP<const Vector> B);
/// Destructor
~Superlu( );
//@}
/// Returns a short description of this Solver
std::string description() const;
private:
/**
* \brief Performs pre-ordering on the matrix to increase efficiency.
*
* Superlu does not support pre-ordering, so this method does nothing.
*/
int preOrdering_impl();
/**
* \brief Perform symbolic factorization of the matrix using Superlu.
*
* Called first in the sequence before numericFactorization.
*
* \throw std::runtime_error Superlu is not able to factor the matrix.
*/
int symbolicFactorization_impl();
/**
* \brief Superlu specific numeric factorization
*
* \throw std::runtime_error Superlu is not able to factor the matrix
*/
int numericFactorization_impl();
/**
* \brief Superlu 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 Superlu 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 SuperLU 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 "SLU_SINGLE" | \c "SLU_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>
* <li> \c "ILU_Flag" : { \c false | \c true }. If true, run ILU routines.</li>
* <li> \c "ILU_DropTol" : \c double value. ILUT drop tolerance.</li>
* <li> \c "ILU_FillFactor" : \c double value. ILUT fill factor.</li>
* <li> \c "ILU_Norm" : { \c "INF_NORM" | \c "ONE_NORM" | \c "TWO_NORM"}.</li>
* <li> \c "ILU_MILU" : { \c "SILU" | \c "SMILU_1" | \c "SMILU_2" | \c "SMILU_3"}. Type of modified ILU algorithm to use.</li>
* <li> \c "ILU_FillTol" : \c double value. ILUT fill tolerance.</li>
* </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 to make a superlu factorization or solve call
mutable struct SLUData {
SLU::SuperMatrix A, B, X, L, U; // matrix A in NCformat
SLU::SuperMatrix AC; // permuted matrix A in NCPformat
SLU::superlu_options_t options;
SLU::mem_usage_t mem_usage;
SLU::SuperLUStat_t stat;
Teuchos::Array<magnitude_type> berr; ///< backward error bounds
Teuchos::Array<magnitude_type> ferr; ///< forward error bounds
Teuchos::Array<int> perm_r;
Teuchos::Array<int> perm_c;
Teuchos::Array<int> etree;
Teuchos::Array<magnitude_type> R;
Teuchos::Array<magnitude_type> C;
char equed;
bool rowequ, colequ; // flags what type of equilibration
// has been performed
int relax;
int panel_size;
} data_;
// The following Arrays are persisting storage arrays for A, X, and B
/// Stores the values of the nonzero entries for SuperLU
Teuchos::Array<slu_type> nzvals_;
/// Stores the location in \c Ai_ and Aval_ that starts row j
Teuchos::Array<int> rowind_;
/// Stores the row indices of the nonzero entries
Teuchos::Array<int> colptr_;
/// Persisting 1D store for X
Teuchos::Array<slu_type> xvals_; int ldx_;
/// Persisting 1D store for B
Teuchos::Array<slu_type> bvals_; int ldb_;
/* Note: In the above, must use "Amesos2::Superlu" rather than
* "Superlu" because otherwise the compiler references the
* specialized type of the class, and not the templated type that is
* required for Amesos2::TypeMap
*/
/* SuperLU can accept input in either compressed-row or
* compressed-column storage. We will store and pass matrices in
* *compressed-column* format.
*/
/*
* Internal flag that is used for the numericFactorization_impl
* routine. If true, then the superlu gstrf routine should have
* SamePattern_SameRowPerm in its options. Otherwise, it should
* factor from scratch.
*
* This is somewhat of a kludge to get around the fact that the
* superlu routines all expect something different from the options
* struct. The big issue is that we don't want gstrf doing the
* symbolic factorization if it doesn't need to. On the other hand,
* we can't leave options.Fact set to SamePattern_SameRowPerm
* because the solver driver needs it to be set at FACTORED. But
* having it set at FACTORED upon re-entrance into
* numericFactorization prompts gstrf to redo the symbolic
* factorization.
*/
bool same_symbolic_;
bool ILU_Flag_;
}; // End class Superlu
// Specialize solver_traits struct for SuperLU
template <>
struct solver_traits<Superlu> {
#ifdef HAVE_TEUCHOS_COMPLEX
typedef Meta::make_list6<float,
double,
std::complex<float>,
std::complex<double>,
SLU::C::complex,
SLU::Z::doublecomplex> supported_scalars;
#else
typedef Meta::make_list2<float, double> supported_scalars;
#endif
};
} // end namespace Amesos2
#endif // AMESOS2_SUPERLU_DECL_HPP
|