ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization Version of the Day
ConstrainedOptPack_MatrixVarReductImplicit.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_VAR_REDUCT_IMPLICIT_H
00043 #define MATRIX_VAR_REDUCT_IMPLICIT_H
00044 
00045 #include <vector>
00046 #include <list>
00047 
00048 #include "ConstrainedOptPack_Types.hpp"
00049 #include "AbstractLinAlgPack_MatrixOp.hpp"
00050 #include "AbstractLinAlgPack_VectorSpace.hpp"
00051 
00052 namespace ConstrainedOptPack {
00053 
00091 class MatrixVarReductImplicit
00092   : public AbstractLinAlgPack::MatrixOp
00093 {
00094 public:
00095 
00098   
00100   typedef Teuchos::RCP<const MatrixOpNonsing>   mat_nonsing_ptr_t;
00102   typedef Teuchos::RCP<const MatrixOp>              mat_ptr_t;
00103 
00105 
00108 
00144   virtual void initialize(
00145     const mat_nonsing_ptr_t          &C
00146     ,const mat_ptr_t                 &N
00147     ,const mat_ptr_t                 &D_direct
00148     );
00157   virtual void set_uninitialized();
00158 
00160 
00163 
00169   const mat_nonsing_ptr_t& C_ptr() const;
00170   
00176   const mat_ptr_t& N_ptr() const;
00177   
00183   const mat_ptr_t& D_direct_ptr() const;
00184   
00186 
00190   size_type rows() const;
00192   size_type cols() const;
00194 
00197 
00199   const VectorSpace& space_cols() const;
00201   const VectorSpace& space_rows() const;
00203   MatrixOp& operator=(const MatrixOp& M);
00205   std::ostream& output(std::ostream&) const;
00207   void Vp_StMtV(
00208     VectorMutable* v_lhs, value_type alpha
00209     ,BLAS_Cpp::Transp trans_rhs1
00210     ,const Vector& v_rhs2, value_type beta
00211     ) const;
00213   void Vp_StMtV(
00214     VectorMutable* v_lhs, value_type alpha
00215     ,BLAS_Cpp::Transp trans_rhs1
00216     ,const SpVectorSlice& sv_rhs2, value_type beta
00217     ) const;
00219   void Vp_StPtMtV(
00220     VectorMutable* v_lhs, value_type alpha
00221     ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00222     ,BLAS_Cpp::Transp M_rhs2_trans
00223     ,const Vector& v_rhs3, value_type beta
00224     ) const;
00226   void Vp_StPtMtV(
00227     VectorMutable* v_lhs, value_type alpha
00228     ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans
00229     ,BLAS_Cpp::Transp M_rhs2_trans
00230     ,const SpVectorSlice& sv_rhs3, value_type beta
00231     ) const;
00232   
00234   
00235 private:
00236   
00237   // //////////////////////////
00238   // Private types
00239   
00240   typedef std::vector<VectorSpace::vec_mut_ptr_t>    InvCtN_rows_t;
00241   typedef std::list<index_type>                      InvCtN_rows_set_list_t;
00242 
00243   // //////////////////////////
00244   // Private data members
00245 
00246 #ifdef DOXYGEN_COMPILE
00247   AbstractLinAlgPack::MatrixOpNonsing  *C;
00248   AbstractLinAlgPack::MatrixOp             *N;
00249   AbstractLinAlgPack::MatrixOp             *D_direct;
00250 #else
00251   mat_nonsing_ptr_t                   C_;
00252   mat_ptr_t                           N_;
00253   mat_ptr_t                           D_direct_;
00254 
00255   mutable InvCtN_rows_t               InvCtN_rows_;
00256   // InvCtN_rows_ keeps track of a set pointers of computed rows of inv(C)*N.
00257   // If D_direct_ is setup then InvCtN_rows_ is not necessary.  However, if
00258   // not, then InvCtN_rows_[j-1] will be !=NULL if it points to the precomputed
00259   // jth row of inv(C)*N and will be ==NULL if this row has not been computed
00260   // yet.  Each time initialize(...) is called, these rows are deallocated and
00261   // InvCtN_rows_[j-1], j=1...this->rows() is set to NULL.
00262 
00263   mutable InvCtN_rows_set_list_t      InvCtN_rows_set_list_;
00264   // InvCtN_rows_set_list_ keeps a unorderd=ed list of the row indexes that are
00265   // currently updated.  Keeping this list allows the vectors allocated in 
00266   // InvCtN_rows_[] to be deallocated much faster than if the whole array
00267   // had to be searched everytime that this->initialize() was called again.
00268 
00269 #endif
00270 
00271   // //////////////////////////////////
00272   // Private member functions
00273 
00275   void assert_initialized() const;
00276 
00277 };  // end class MatrixVarReductImplicit
00278 
00279 // ////////////////////////////////
00280 // Inline members
00281 
00282 inline
00283 const MatrixVarReductImplicit::mat_nonsing_ptr_t&
00284 MatrixVarReductImplicit::C_ptr() const
00285 {
00286   return C_;
00287 }
00288 
00289 inline
00290 const MatrixVarReductImplicit::mat_ptr_t&
00291 MatrixVarReductImplicit::N_ptr() const
00292 {
00293   return N_;
00294 }
00295 
00296 inline
00297 const MatrixVarReductImplicit::mat_ptr_t&
00298 MatrixVarReductImplicit::D_direct_ptr() const
00299 {
00300   return D_direct_;
00301 }
00302 
00303 } // end namespace ConstrainedOptPack 
00304 
00305 #endif  // MATRIX_VAR_REDUCT_IMPLICIT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends