ConstrainedOptPack_MatrixSymAddDelBunchKaufman.hpp

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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef MATRIX_SYM_POS_DEF_BUNCH_KAUFMAN_H
00030 #define MATRIX_SYM_POS_DEF_BUNCH_KAUFMAN_H
00031 
00032 #include <vector>
00033 
00034 #include "ConstrainedOptPack_MatrixSymAddDelUpdateableWithOpNonsingular.hpp"
00035 #include "AbstractLinAlgPack_MatrixSymAddDelUpdateable.hpp"
00036 #include "AbstractLinAlgPack_MatrixSymPosDefCholFactor.hpp"
00037 #include "AbstractLinAlgPack_MatrixSymOpNonsingSerial.hpp"
00038 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
00039 
00040 namespace ConstrainedOptPack {
00041 
00053 class MatrixSymAddDelBunchKaufman
00054   :public virtual MatrixSymOpNonsingSerial
00055   ,public virtual MatrixSymAddDelUpdateable
00056   ,public virtual MatrixSymAddDelUpdateableWithOpNonsingular
00057 {
00058 public:
00059 
00061   MatrixSymAddDelBunchKaufman();
00062 
00064   void pivot_tols( PivotTolerances pivot_tols );
00066   PivotTolerances pivot_tols() const;
00067 
00070 
00072   const MatrixSymOpNonsing& op_interface() const;
00074   MatrixSymAddDelUpdateable& update_interface();
00076   const MatrixSymAddDelUpdateable& update_interface() const;
00077 
00079 
00082 
00084   void initialize(
00085     value_type         alpha
00086     ,size_type         max_size
00087     );
00089   void initialize(
00090     const DMatrixSliceSym      &A
00091     ,size_type         max_size
00092     ,bool              force_factorization
00093     ,Inertia           inertia
00094     ,PivotTolerances   pivot_tols
00095     );
00097   size_type max_size() const;
00099   Inertia inertia() const;
00101   void set_uninitialized();
00103   void augment_update(
00104     const DVectorSlice  *t
00105     ,value_type        alpha
00106     ,bool              force_refactorization
00107     ,EEigenValType     add_eigen_val
00108     ,PivotTolerances   pivot_tols
00109     );
00111   void delete_update(
00112     size_type          jd
00113     ,bool              force_refactorization
00114     ,EEigenValType     drop_eigen_val
00115     ,PivotTolerances   pivot_tols
00116     );
00117 
00119 
00122 
00124   size_type rows() const;
00126   std::ostream& output(std::ostream& out) const;
00128   void Vp_StMtV(
00129     DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00130     ,const DVectorSlice& vs_rhs2, value_type beta
00131     ) const;
00133   void V_InvMtV(
00134     DVectorSlice* vs_lhs, BLAS_Cpp::Transp trans_rhs1
00135     ,const DVectorSlice& vs_rhs2
00136     )const;
00137 
00138 private:
00139 
00140   // /////////////////////////////////////////////////////
00141   // Private types
00142 
00143   typedef std::vector<FortranTypes::f_int> IPIV_t;
00144 
00145   // /////////////////////////////////////////////////////
00146   // Private data members
00147 
00148   size_type S_size_;      // The size of the current symmetric matrix.  Size == 0 if flag for uninitialized.
00149   bool      S_indef_;     // True if the current matrix is indefinite.
00150   bool      fact_updated_;// True if the factorization for the current matrix is updated.  Only meaningful
00151                           // if S_indef_==true.
00152   bool      fact_in1_;    // If true then the current factorization is in S_store1_
00153                           // otherwise it is in S_store2_.  Only meaningful if S_indef_==true and
00154                           // fact_updated_==true
00155   MatrixSymAddDelUpdateable::Inertia
00156             inertia_;     // Inertial for the indefinite L*D*L' factorization.  If fact_updated_ == false
00157                           // then this will be UNKNOWN.  IF S_indef_==false then this is meaningless.
00158   DMatrix S_store1_;    // Storage for the factored matrix in the
00159                           // upper triangle as well as the original matrix
00160                           // in the lower triangle.  This uses the same storage scheme as
00161                           // in MatrixSymPosDefCholFactor.
00162   DMatrix S_store2_;    // Storage for the factorization also.  We need
00163                           // two storage locations for the L*D*L factorization
00164                           // in case an update is singular.  This will not
00165                           // be initialized for a p.d. or n.d. matrix.
00166   IPIV_t    IPIV_;        // Stores permutations computed by LAPACK
00167   mutable DVector
00168               WORK_;        // workspace
00169   MatrixSymPosDefCholFactor
00170           S_chol_;      // Used to factorize the matrix
00171                           // when it is p.d. or n.d.
00172 
00173   // /////////////////////////////////////////////////////
00174   // Private member funcitons.
00175 
00178   DMatrixSliceTriEle DU(size_type S_size, bool fact_in1);
00180   const DMatrixSliceTriEle DU(size_type S_size, bool fact_in1) const;
00183   DMatrixSliceSym S(size_type S_size);
00185   const DMatrixSliceSym S(size_type S_size) const;
00187   void assert_initialized() const;
00189   void resize_DU_store( bool in_store1 );
00194   void copy_and_factor_matrix( size_type S_size, bool fact_in1 );
00199   void factor_matrix( size_type S_size, bool fact_in1 );
00206   bool compute_assert_inertia(
00207     size_type S_size, bool fact_in1
00208     ,const Inertia& expected_inertia, const char func_name[]
00209     ,PivotTolerances pivot_tols, Inertia* comp_inertia, std::ostringstream* err_msg, value_type* gamma );
00210 
00212   MatrixSymAddDelBunchKaufman( const MatrixSymAddDelBunchKaufman& );
00213   MatrixSymAddDelBunchKaufman& operator=( const MatrixSymAddDelBunchKaufman& );
00214 
00215 };  // end class MatrixSymAddDelBunchKaufman
00216 
00217 // ///////////////////////////
00218 // Inline member functions
00219 
00220 inline
00221 DMatrixSliceTriEle MatrixSymAddDelBunchKaufman::DU(size_type S_size, bool fact_in1)
00222 {
00223   resize_DU_store(fact_in1);
00224   return DenseLinAlgPack::nonconst_tri_ele(
00225     ( fact_in1 ? S_store1_ : S_store2_ )(1,S_size,2,S_size+1)
00226     ,BLAS_Cpp::upper );
00227 }
00228 
00229 inline
00230 const DMatrixSliceTriEle MatrixSymAddDelBunchKaufman::DU(size_type S_size, bool fact_in1) const
00231 {
00232   return DenseLinAlgPack::tri_ele(
00233     ( fact_in1 ? S_store1_ : S_store2_ )(1,S_size,2,S_size+1)
00234     ,BLAS_Cpp::upper);
00235 }
00236 
00237 inline
00238 DMatrixSliceSym MatrixSymAddDelBunchKaufman::S(size_type S_size)
00239 {
00240   return DenseLinAlgPack::nonconst_sym(
00241     S_store1_(2,S_size+1,1,S_size)
00242     , BLAS_Cpp::lower );
00243 }
00244 
00245 inline
00246 const DMatrixSliceSym MatrixSymAddDelBunchKaufman::S(size_type S_size) const
00247 {
00248   return DenseLinAlgPack::sym(
00249     S_store1_(2,S_size+1,1,S_size)
00250     , BLAS_Cpp::lower );
00251 }
00252 
00253 } // namespace ConstrainedOptPack 
00254 
00255 #endif  // MATRIX_SYM_POS_DEF_BUNCH_KAUFMAN_H

Generated on Thu Sep 18 12:34:15 2008 for ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization by doxygen 1.3.9.1