MOOCHO (Single Doxygen Collection) Version of the Day
AbstractLinAlgPack_MatrixOpNonsingThyra.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 // 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 
00030 #include "AbstractLinAlgPack_MatrixOpNonsingThyra.hpp"
00031 #include "AbstractLinAlgPack_VectorMutableThyra.hpp"
00032 #include "Thyra_VectorStdOps.hpp"
00033 #include "Thyra_MultiVectorStdOps.hpp"
00034 #include "Teuchos_TestForException.hpp"
00035 #include "Teuchos_dyn_cast.hpp"
00036 
00037 namespace AbstractLinAlgPack {
00038 
00039 // Constructors / Initializers
00040 
00041 MatrixOpNonsingThyra::MatrixOpNonsingThyra()
00042 {}
00043 
00044 MatrixOpNonsingThyra::MatrixOpNonsingThyra(
00045   const Teuchos::RCP<const Thyra::LinearOpWithSolveBase<value_type> >  &thyra_linear_op_ns
00046   ,BLAS_Cpp::Transp                                                            thyra_linear_op_trans
00047   )
00048 {
00049   this->initialize(thyra_linear_op_ns,thyra_linear_op_trans);
00050 }
00051 
00052 void MatrixOpNonsingThyra::initialize(
00053   const Teuchos::RCP<const Thyra::LinearOpWithSolveBase<value_type> >  &thyra_linear_op_ns
00054   ,BLAS_Cpp::Transp                                                            thyra_linear_op_trans
00055   )
00056 {
00057   namespace mmp = MemMngPack;
00058   TEST_FOR_EXCEPTION(
00059     thyra_linear_op_ns.get()==NULL, std::invalid_argument
00060     ,"MatrixOpNonsingThyra::initialize(thyra_linear_op_ns): Error!"
00061     );
00062   MatrixOpThyra::initialize(thyra_linear_op_ns,thyra_linear_op_trans);
00063 }
00064 
00065 Teuchos::RCP<const Thyra::LinearOpWithSolveBase<value_type> > 
00066 MatrixOpNonsingThyra::set_uninitialized()
00067 {
00068   Teuchos::RCP<const Thyra::LinearOpWithSolveBase<value_type> >
00069     tmp_thyra_linear_op_ns = thyra_linear_op_ns();
00070   MatrixOpThyra::set_uninitialized();
00071   return tmp_thyra_linear_op_ns;
00072 }
00073 
00074 Teuchos::RCP<const Thyra::LinearOpWithSolveBase<value_type> >
00075 MatrixOpNonsingThyra::thyra_linear_op_ns() const
00076 {
00077   return Teuchos::rcp_dynamic_cast<const Thyra::LinearOpWithSolveBase<value_type> >(this->thyra_linear_op());
00078 }
00079 
00080 // Overridden from MatrixOp (needed to remove ambiguities)
00081 
00082 MatrixOp::mat_mut_ptr_t
00083 MatrixOpNonsingThyra::clone()
00084 {
00085   return this->MatrixOpThyra::clone();
00086 }
00087 
00088 // Overridden from MatrixNonsing
00089 
00090 void MatrixOpNonsingThyra::V_InvMtV(
00091   VectorMutable* v_lhs, BLAS_Cpp::Transp trans_rhs1
00092   ,const Vector& v_rhs2
00093   ) const
00094 {
00095   using Teuchos::dyn_cast;
00096   using BLAS_Cpp::trans_trans;
00097 #ifdef TEUCHOS_DEBUG
00098   TEST_FOR_EXCEPTION(
00099     v_lhs==NULL, std::invalid_argument
00100     ,"MatrixOpThyra::Vp_StMtV(...): Error!"
00101     );
00102 #endif
00103   *v_lhs = 0.0; // Must initialize before sending to solve(...)!
00104   VectorMutableThyra &v_thyra_lhs = dyn_cast<VectorMutableThyra>(*v_lhs);
00105   Teuchos::RCP<Thyra::VectorBase<value_type> > thyra_vec_lhs = v_thyra_lhs.set_uninitialized();
00106   Thyra::solve(
00107     *thyra_linear_op_ns()
00108     ,trans_trans(trans_rhs1,thyra_linear_op_trans())==BLAS_Cpp::no_trans ? Thyra::NOTRANS : Thyra::TRANS  // M_trans
00109     ,*dyn_cast<const VectorMutableThyra>(v_rhs2).thyra_vec()                                              // y
00110     ,thyra_vec_lhs.get()                                                                                  // x
00111     );
00112   v_thyra_lhs.initialize(thyra_vec_lhs);
00113 }
00114 
00115 void MatrixOpNonsingThyra::M_StInvMtM(
00116   MatrixOp* m_lhs, value_type alpha
00117   ,BLAS_Cpp::Transp trans_rhs1
00118   ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2
00119   ) const
00120 {
00121   MatrixNonsing::M_StInvMtM(m_lhs,alpha,trans_rhs1,mwo_rhs2,trans_rhs2); // ToDo: Specialize!
00122 }
00123 
00124 // Overridden from MatrixOpNonsing
00125 
00126 MatrixOpNonsing::mat_mwons_ptr_t
00127 MatrixOpNonsingThyra::clone_mwons() const
00128 {
00129   return Teuchos::null; // ToDo: Add a clone function to Thyra::LinearOpWithSolveBase???
00130   //return Teuchos::rcp(new MatrixOpNonsingThyra(thyra_linear_op_ns()->clone_lows()));
00131 }
00132 
00133 } // end namespace AbstractLinAlgPack
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines