ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization Version of the Day
ConstrainedOptPack_MatrixSymPosDefBandedChol.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 // 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 MATRIX_SYM_POS_DEF_BANDED_CHOL_H
00043 #define MATRIX_SYM_POS_DEF_BANDED_CHOL_H
00044 
00045 #include "ConstrainedOptPack_Types.hpp"
00046 #include "AbstractLinAlgPack/src/MatrixSymWithOpFactorized.hpp"
00047 #include "DenseLinAlgPack_DMatrixClass.hpp"
00048 #include "Miref_count_ptr.h"
00049 #include "MiReleaseResource.h"
00050 
00051 namespace ConstrainedOptPack {
00078 class MatrixSymPosDefBandedChol : public MatrixSymWithOpFactorized
00079 {
00080 public:
00081   
00083   typedef Teuchos::RCP<
00084     MemMngPack::ReleaseResource>  release_resource_ptr_t;
00085 
00086   // //////////////
00087     // Constructors
00088 
00093   MatrixSymPosDefBandedChol(
00094     size_type                         n                       = 0
00095     ,size_type                        kd                      = 0
00096     ,DMatrixSlice                   *MB                     = NULL
00097     ,const release_resource_ptr_t&    MB_release_resource_ptr = NULL
00098     ,BLAS_Cpp::Uplo                   MB_uplo                 = BLAS_Cpp::lower
00099     ,DMatrixSlice                   *UB                     = NULL
00100     ,const release_resource_ptr_t&    UB_release_resource_ptr = NULL
00101     ,BLAS_Cpp::Uplo                   UB_uplo                 = BLAS_Cpp::lower
00102     ,bool                             update_factor           = false
00103     ,value_type                       scale                   = 1.0
00104     );
00105 
00106   // ///////////////////////////
00107     // Access representation
00108 
00141   void initialize(
00142     size_type                         n                       = 0
00143     ,size_type                        kd                      = 0
00144     ,DMatrixSlice                   *MB                     = NULL
00145     ,const release_resource_ptr_t&    MB_release_resource_ptr = NULL
00146     ,BLAS_Cpp::Uplo                   MB_uplo                 = BLAS_Cpp::lower
00147     ,DMatrixSlice                   *UB                     = NULL
00148     ,const release_resource_ptr_t&    UB_release_resource_ptr = NULL
00149     ,BLAS_Cpp::Uplo                   UB_uplo                 = BLAS_Cpp::lower
00150     ,bool                             update_factor           = false
00151     ,value_type                       scale                   = 1.0
00152     );
00153 
00155   size_type kd() const;
00158   DMatrixSlice& MB();
00160   const DMatrixSlice& MB() const;
00162   BLAS_Cpp::Uplo MB_uplo() const;
00165   DMatrixSlice& UB();
00167   const DMatrixSlice& UB() const;
00169   BLAS_Cpp::Uplo UB_uplo() const;
00170 
00171   // /////////////////////////////
00172   // Overridden from MatrixOp
00173 
00175   size_type rows() const;
00177   size_type nz() const;
00179   std::ostream& output(std::ostream& out) const;
00181   void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00182     , const DVectorSlice& vs_rhs2, value_type beta) const;
00184   void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00185     , const SpVectorSlice& sv_rhs2, value_type beta) const;
00187   void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00188     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00189     , BLAS_Cpp::Transp M_rhs2_trans
00190     , const DVectorSlice& vs_rhs3, value_type beta) const;
00192   void Vp_StPtMtV(DVectorSlice* vs_lhs, value_type alpha
00193     , const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00194     , BLAS_Cpp::Transp M_rhs2_trans
00195     , const SpVectorSlice& sv_rhs3, value_type beta) const;
00196 
00197   // //////////////////////////////////
00198   // Overridden from MatrixFactorized
00199 
00201   void V_InvMtV(DVectorSlice* vs_lhs, BLAS_Cpp::Transp trans_rhs1
00202     , const DVectorSlice& vs_rhs2) const;
00203 
00204 private:
00205   
00206   // /////////////////////////////
00207   // Private data members
00208 
00209   size_type                       n_;
00210   size_type                       kd_;
00211   DMatrixSlice                  MB_;
00212   release_resource_ptr_t          MB_release_resource_ptr_;
00213   BLAS_Cpp::Uplo                  MB_uplo_;
00214   mutable DMatrixSlice          UB_;
00215   mutable release_resource_ptr_t  UB_release_resource_ptr_;
00216   mutable BLAS_Cpp::Uplo          UB_uplo_;
00217   mutable bool                    factor_updated_;
00218   value_type                      scale_;
00219 
00220   // /////////////////////////////
00221   // Private member functions
00222 
00223   void assert_initialized() const;
00224   void update_factorization() const;
00225 
00226 }; // end class MatrixSymPosDefBandedChol
00227 
00228 // ///////////////////////////////////////////////////////
00229 // Inline members for MatrixSymPosDefBandedChol
00230 
00231 inline
00232 size_type MatrixSymPosDefBandedChol::kd() const
00233 {
00234   return kd_;
00235 }
00236 
00237 inline
00238 DMatrixSlice& MatrixSymPosDefBandedChol::MB()
00239 {
00240   return MB_;
00241 }
00242 
00243 inline
00244 const DMatrixSlice& MatrixSymPosDefBandedChol::MB() const
00245 {
00246   return MB_;
00247 }
00248 
00249 inline
00250 BLAS_Cpp::Uplo MatrixSymPosDefBandedChol::MB_uplo() const
00251 {
00252   return MB_uplo_;
00253 }
00254 
00255 inline
00256 DMatrixSlice& MatrixSymPosDefBandedChol::UB()
00257 {
00258   return UB_;
00259 }
00260 
00261 inline
00262 const DMatrixSlice& MatrixSymPosDefBandedChol::UB() const
00263 {
00264   return UB_;
00265 }
00266 
00267 inline
00268 BLAS_Cpp::Uplo MatrixSymPosDefBandedChol::UB_uplo() const
00269 {
00270   return UB_uplo_;
00271 }
00272 
00273 } // end namespace ConstrainedOptPack
00274 
00275 #endif // MATRIX_SYM_POS_DEF_BANDED_CHOL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends