MOOCHO (Single Doxygen Collection) Version of the Day
ConstrainedOptPack_DecompositionSystemCoordinate.cpp
Go to the documentation of this file.
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 #include <assert.h>
00043 
00044 #include "ConstrainedOptPack_DecompositionSystemCoordinate.hpp"
00045 #include "ConstrainedOptPack_MatrixIdentConcatStd.hpp"
00046 #include "AbstractLinAlgPack_MatrixOpNonsing.hpp"
00047 #include "AbstractLinAlgPack_MatrixOpSubView.hpp"
00048 #include "AbstractLinAlgPack_MatrixZero.hpp"
00049 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
00050 #include "Teuchos_AbstractFactoryStd.hpp"
00051 #include "Teuchos_dyn_cast.hpp"
00052 #include "Teuchos_Assert.hpp"
00053 
00054 namespace ConstrainedOptPack {
00055 
00056 DecompositionSystemCoordinate::DecompositionSystemCoordinate(
00057   const VectorSpace::space_ptr_t     &space_x
00058   ,const VectorSpace::space_ptr_t    &space_c
00059   ,const basis_sys_ptr_t             &basis_sys
00060   ,const basis_sys_tester_ptr_t      &basis_sys_tester
00061   ,EExplicitImplicit                 D_imp
00062   ,EExplicitImplicit                 Uz_imp
00063   )
00064   :DecompositionSystemVarReductImp(
00065     space_x, space_c, basis_sys, basis_sys_tester
00066     ,D_imp, Uz_imp )
00067 {}
00068 
00069 // Overridden from DecompositionSystem
00070 
00071 const DecompositionSystem::mat_fcty_ptr_t
00072 DecompositionSystemCoordinate::factory_Y() const
00073 {
00074   namespace rcp = MemMngPack;
00075   return Teuchos::rcp(
00076     new Teuchos::AbstractFactoryStd<MatrixOp,MatrixIdentConcatStd>()
00077     );
00078 }
00079 
00080 const DecompositionSystem::mat_nonsing_fcty_ptr_t
00081 DecompositionSystemCoordinate::factory_R() const
00082 {
00083   if( basis_sys().get() )
00084     return basis_sys()->factory_C();
00085   return Teuchos::null;
00086 }
00087 
00088 const DecompositionSystem::mat_fcty_ptr_t
00089 DecompositionSystemCoordinate::factory_Uy() const
00090 {
00091   return Teuchos::rcp(  new Teuchos::AbstractFactoryStd<MatrixOp,MatrixOpSubView>() );
00092 }
00093 
00094 // Overridden from DecompositionSystemVarReductImp
00095 
00096 DecompositionSystem::mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t
00097 DecompositionSystemCoordinate::uninitialize_matrices(
00098   std::ostream                                       *out
00099   ,EOutputLevel                                      olevel
00100   ,MatrixOp                                          *Y
00101   ,MatrixOpNonsing                                   *R
00102   ,MatrixOp                                          *Uy
00103   ) const
00104 {
00105   namespace rcp = MemMngPack;
00106   using Teuchos::dyn_cast;
00107 
00108   //
00109   // Get pointers to concreate matrices
00110   //
00111   
00112   MatrixOpSubView
00113     *Uy_sv = Uy ? &dyn_cast<MatrixOpSubView>(*Uy) : NULL;     
00114 
00115   //
00116   // Only uninitialize the sub_view matrices
00117   //
00118 
00119   if(Uy_sv)
00120     Uy_sv->initialize(Teuchos::null);
00121 
00122   //
00123   // Return the basis matrix object R == C as a smart pointer that is
00124   // not owned.  This matrix object (if R != NULL) will get updated
00125   // by the basis_sys object as C in the method
00126   // 
00127   //     DecompositionSystemVarReductImp::update_decomp(...)
00128   //
00129 
00130   return Teuchos::rcp(R,false);
00131 
00132 }
00133 
00134 void DecompositionSystemCoordinate::initialize_matrices(
00135   std::ostream                                           *out
00136   ,EOutputLevel                                          olevel
00137   ,const mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t &C
00138   ,const mat_fcty_ptr_t::element_type::obj_ptr_t         &D
00139   ,MatrixOp                                              *Y
00140   ,MatrixOpNonsing                                       *R
00141   ,MatrixOp                                              *Uy
00142   ,EMatRelations                                         mat_rel
00143   ) const
00144 {
00145   namespace rcp = MemMngPack;
00146   using Teuchos::dyn_cast;
00147 
00148   const size_type
00149     n = this->n(),
00150     r = this->r();
00151   const Range1D
00152     var_dep(1,r),
00153     var_indep(r+1,n);
00154 
00155   //
00156   // Get pointers to concreate matrices
00157   //
00158   
00159   MatrixIdentConcatStd
00160     *Y_coor = Y ? &dyn_cast<MatrixIdentConcatStd>(*Y) : NULL;
00161   MatrixOpSubView
00162     *Uy_sv = Uy ? &dyn_cast<MatrixOpSubView>(*Uy) : NULL;     
00163 
00164   //
00165   // Initialize the matrices
00166   //
00167 
00168   if( Y_coor && Y_coor->D_ptr().get() == NULL ) {
00169     Y_coor->initialize(
00170       space_x()                                         // space_cols
00171       ,space_x()->sub_space(var_dep)->clone()           // space_rows
00172       ,MatrixIdentConcatStd::BOTTOM                     // top_or_bottom
00173       ,0.0                                              // alpha
00174       ,Teuchos::rcp(
00175         new MatrixZero(
00176           space_x()->sub_space(var_indep)->clone()
00177           ,space_x()->sub_space(var_dep)->clone()
00178           ) )                                       // D_ptr
00179       ,BLAS_Cpp::no_trans                               // D_trans
00180       );
00181   }
00182   TEUCHOS_TEST_FOR_EXCEPT( !( Uy_sv == NULL ) ); // ToDo: Implement for undecomposed equalities
00183 
00184   // The R = C matrix object should already be updateded
00185 
00186 }
00187 
00188 void DecompositionSystemCoordinate::print_update_matrices(
00189   std::ostream& out, const std::string& L ) const
00190 {
00191   out
00192     << L << "*** Coordinate decompositon Y, R and Uy matrices (class DecompositionSystemCoordinate)\n"
00193     << L << "Y = [ I; 0 ] (using class MatrixIdentConcatStd with MatrixZero)\n"
00194     << L << "R = Gc(var_dep,equ_decomp)' = C\n"
00195     << L << "Uy = Gc(var_dep,equ_undecomp)'\n"
00196     ;
00197 }
00198     
00199 } // end namespace ConstrainedOptPack
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines