|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00005 // Copyright (2003) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #ifndef ALAP_DIRECT_SPARSE_SOLVER_MA28_H 00043 #define ALAP_DIRECT_SPARSE_SOLVER_MA28_H 00044 00045 #include <valarray> 00046 #include <vector> 00047 #include <string> 00048 00049 #include "AbstractLinAlgPack_DirectSparseSolverImp.hpp" 00050 #include "AbstractLinAlgPack_MA28Solver.hpp" 00051 #include "DenseLinAlgPack_DVectorClass.hpp" 00052 #include "DenseLinAlgPack_IVector.hpp" 00053 #include "Teuchos_StandardMemberCompositionMacros.hpp" 00054 00055 namespace AbstractLinAlgPack { 00056 00061 class DirectSparseSolverMA28 : public DirectSparseSolverImp { 00062 public: 00063 00066 00068 enum EScalingMethod { NO_SCALING, INITIAL_SCALING, SUCCESSIVE_SCALING }; 00069 00071 00074 00076 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, u ); 00077 00079 STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, grow ); 00080 00082 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, tol ); 00083 00085 STANDARD_MEMBER_COMPOSITION_MEMBERS( index_type, nsrch ); 00086 00088 STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, lbig ); 00089 00091 STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, print_ma28_outputs ); 00092 00094 STANDARD_MEMBER_COMPOSITION_MEMBERS( std::string, output_file_name ); 00095 00097 00100 00102 DirectSparseSolverMA28( 00103 value_type estimated_fillin_ratio = 10.0 00104 ,value_type u = 0.1 00105 ,bool grow = false 00106 ,value_type tol = 0.0 00107 ,index_type nsrch = 4 00108 ,bool lbig = false 00109 ,bool print_ma28_outputs = false 00110 ,const std::string& output_file_name = "" 00111 ); 00112 00114 00117 00119 const basis_matrix_factory_ptr_t basis_matrix_factory() const; 00121 void estimated_fillin_ratio( value_type estimated_fillin_ratio ); 00122 00124 00125 protected: 00126 00129 00132 class BasisMatrixMA28 : public BasisMatrixImp { 00133 public: 00134 00137 00139 Teuchos::RCP<BasisMatrixImp> create_matrix() const; 00141 void V_InvMtV( 00142 VectorMutable* v_lhs, BLAS_Cpp::Transp trans_rhs1 00143 ,const Vector& v_rhs2) const ; 00144 00146 00147 }; // end class BasisMatrixMA28 00148 00151 class FactorizationStructureMA28 : public FactorizationStructure { 00152 public: 00154 friend class DirectSparseSolverMA28; 00156 friend class BasisMatrixMA28; 00157 private: 00158 // ///////////////////////////////////////// 00159 // Private types 00160 typedef Teuchos::RCP<MatrixScaling_Strategy> matrix_scaling_ptr_t; 00161 // ///////////////////////////////////////// 00162 // Private data members 00163 mutable MA28_Cpp::MA28Solver ma28_; // Management of common block data 00164 // Keep a memory of the size of the system to check for consistent usage. 00165 index_type m_; // number of rows (keep for checks on consistancy) 00166 index_type n_; // number of columns ("") 00167 index_type max_n_; // max(m_,n_) 00168 index_type nz_; // numner of non-zero elements in unfactorized matrix ("") 00169 index_type licn_; // size of icn_ and a_ (default = 3 * nz_) 00170 index_type lirn_; // size of irn_ (default = 3 * nz_) 00171 // Control parameters 00172 value_type u_; // fill-in vs. stability ratio (default = 0.1) 00173 EScalingMethod scaling_; // Scaling method 00174 // Matrix scaling 00175 matrix_scaling_ptr_t matrix_scaling_; 00176 // Memory for factorization structure 00177 std::valarray<index_type> ivect_; 00178 std::valarray<index_type> jvect_; 00179 std::valarray<index_type> icn_; 00180 std::valarray<index_type> ikeep_; 00181 // Basis matrix selection 00182 IVector row_perm_; 00183 IVector col_perm_; 00184 index_type rank_; 00185 // ///////////////////////////////////////// 00186 // Private member functions 00188 FactorizationStructureMA28(); 00189 }; // end class FactorizationStructureMA28 00190 00193 class FactorizationNonzerosMA28 : public FactorizationNonzeros { 00194 public: 00196 friend class DirectSparseSolverMA28; 00198 friend class BasisMatrixMA28; 00199 private: 00200 std::valarray<value_type> a_; // holds the non-zeros of the factorized matrix 'a' 00201 }; // end class FactorizationNonzerosMA28 00202 00204 00207 00209 const Teuchos::RCP<FactorizationStructure> create_fact_struc() const; 00211 const Teuchos::RCP<FactorizationNonzeros> create_fact_nonzeros() const; 00213 void imp_analyze_and_factor( 00214 const AbstractLinAlgPack::MatrixConvertToSparse &A 00215 ,FactorizationStructure *fact_struc 00216 ,FactorizationNonzeros *fact_nonzeros 00217 ,DenseLinAlgPack::IVector *row_perm 00218 ,DenseLinAlgPack::IVector *col_perm 00219 ,size_type *rank 00220 ,std::ostream *out 00221 ); 00223 void imp_factor( 00224 const AbstractLinAlgPack::MatrixConvertToSparse &A 00225 ,const FactorizationStructure &fact_struc 00226 ,FactorizationNonzeros *fact_nonzeros 00227 ,std::ostream *out 00228 ); 00229 00231 00232 private: 00233 00234 // ///////////////////////////////// 00235 // Private types 00236 00238 enum E_IFlag { 00239 SLOW_ITER_CONV = -17, 00240 MAXIT_REACHED = -16, 00241 MA28BD_CALLED_WITH_DROPPED = -15, 00242 DUPLICATE_ELEMENTS = -14, 00243 NEW_NONZERO_ELEMENT = -13, 00244 N_OUT_OF_RANGE = -11, 00245 NZ_LE_ZERO = -10, 00246 LICN_LE_NZ = -9, 00247 LIRN_LE_NZ = -8, 00248 ERROR_DURRING_BLOCK_TRI = -7, 00249 LICN_AND_LIRN_TOO_SMALL = -6, 00250 LICN_TOO_SMALL = -5, 00251 LICN_FAR_TOO_SMALL = -4, 00252 LIRN_TOO_SMALL = -3, 00253 NUMERICALLY_SINGULAR = -2, 00254 STRUCTURALLY_SINGULAR = -1, 00255 SUCCESSFUL_DECOMP_ON_STRUCT_SINGULAR = 1, 00256 SUCCESSFUL_DECOMP_ON_NUMER_SINGULAR = 2 00257 }; 00258 00259 // ///////////////////////////////// 00260 // Private data members 00261 00262 value_type estimated_fillin_ratio_; 00263 Teuchos::RCP<std::ostream> output_file_; 00264 int file_output_num_; 00265 00266 // //////////////////////////////// 00267 // Private member functions 00268 00269 // Set MA28 control parameters 00270 void set_ma28_parameters( FactorizationStructureMA28* fs ); 00271 00272 // Print MA28 return parameters 00273 void print_ma28_outputs( 00274 bool ma28ad_bd 00275 ,index_type iflag 00276 ,const FactorizationStructureMA28 &fs 00277 ,const value_type w[] 00278 ,std::ostream *out 00279 ); 00280 00281 // Throw an exception for an iflag error 00282 void ThrowIFlagException(index_type iflag); 00283 00284 }; // end class DirectSparseSolverMA28 00285 00286 // //////////////////////////////////////// 00287 // Inline members 00288 00289 } // end namespace AbstractLinAlgPack 00290 00291 #endif // ALAP_DIRECT_SPARSE_SOLVER_MA28_H
1.7.6.1