AbstractLinAlgPack_MultiVectorMutableThyra.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 #include <assert.h>
00030 
00031 #include "AbstractLinAlgPack_MultiVectorMutableThyra.hpp"
00032 #include "AbstractLinAlgPack_VectorMutableThyra.hpp"
00033 #include "Teuchos_TestForException.hpp"
00034 #include "Teuchos_dyn_cast.hpp"
00035 
00036 namespace AbstractLinAlgPack {
00037 
00038 // Constructors / Initializers
00039 
00040 MultiVectorMutableThyra::MultiVectorMutableThyra()
00041 {}
00042 
00043 MultiVectorMutableThyra::MultiVectorMutableThyra(
00044   const Teuchos::RCP<Thyra::MultiVectorBase<value_type> >& thyra_multi_vec
00045   )
00046 {
00047   this->initialize(thyra_multi_vec);
00048 }
00049 
00050 void MultiVectorMutableThyra::initialize(
00051   const Teuchos::RCP<Thyra::MultiVectorBase<value_type> >& thyra_multi_vec
00052   )
00053 {
00054   namespace mmp = MemMngPack;
00055   TEST_FOR_EXCEPTION(
00056     thyra_multi_vec.get()==NULL, std::invalid_argument
00057     ,"MultiVectorMutableThyra::initialize(thyra_multi_vec): Error!"
00058     );
00059   MatrixOpThyra::initialize(thyra_multi_vec);
00060 }
00061 
00062 Teuchos::RCP<Thyra::MultiVectorBase<value_type> > 
00063 MultiVectorMutableThyra::set_uninitialized()
00064 {
00065   Teuchos::RCP<Thyra::MultiVectorBase<value_type> >
00066     tmp_thyra_multi_vec = cast_thyra_multi_vec();
00067   MatrixOpThyra::set_uninitialized();
00068   return tmp_thyra_multi_vec;
00069 }
00070 
00071 Teuchos::RCP<const Thyra::MultiVectorBase<value_type> >
00072 MultiVectorMutableThyra::thyra_multi_vec() const
00073 {
00074   return Teuchos::rcp_dynamic_cast<const Thyra::MultiVectorBase<value_type> >(this->thyra_linear_op());
00075 }
00076 
00077 // Overridden from MatrixOpThyra
00078 
00079 void MultiVectorMutableThyra::initialize(
00080   const Teuchos::RCP<const Thyra::LinearOpBase<value_type> >& thyra_linear_op
00081   )
00082 {
00083   namespace mmp = MemMngPack;
00084   this->initialize(
00085     Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<value_type> >(
00086       Teuchos::rcp_const_cast<Thyra::LinearOpBase<value_type> >(thyra_linear_op)
00087       )
00088     );
00089 }
00090 
00091 // Overridden from MatrixOp
00092 
00093 MatrixOp::mat_mut_ptr_t
00094 MultiVectorMutableThyra::clone()
00095 {
00096   return this->MatrixOpThyra::clone();
00097 }
00098 
00099 MatrixOp& MultiVectorMutableThyra::operator=(const MatrixOp& mwo_rhs)
00100 {
00101   return this->MultiVectorMutable::operator=(mwo_rhs);
00102 }
00103 
00104 void MultiVectorMutableThyra::Vp_StMtV(
00105   VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00106   ,const Vector& v_rhs2, value_type beta
00107   ) const
00108 {
00109   this->MatrixOpThyra::Vp_StMtV(v_lhs,alpha,trans_rhs1,v_rhs2,beta);
00110 }
00111 
00112 bool MultiVectorMutableThyra::Mp_StMtM(
00113   MatrixOp* mwo_lhs, value_type alpha
00114   ,BLAS_Cpp::Transp trans_rhs1
00115   ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2
00116   ,value_type beta
00117   ) const
00118 {
00119   return this->MatrixOpThyra::Mp_StMtM(mwo_lhs,alpha,trans_rhs1,mwo_rhs2,trans_rhs2,beta);
00120 }
00121 
00122 // Overridden from MultiVector
00123 
00124 MultiVector::access_by_t
00125 MultiVectorMutableThyra::access_by() const
00126 {
00127   return COL_ACCESS;
00128 }
00129 
00130 void MultiVectorMutableThyra::apply_op(
00131   EApplyBy apply_by, const RTOpPack::RTOp& primary_op
00132   ,const size_t num_multi_vecs,      const MultiVector*   multi_vecs[]
00133   ,const size_t num_targ_multi_vecs, MultiVectorMutable*  targ_multi_vecs[]
00134   ,RTOpPack::ReductTarget* reduct_objs[]
00135   ,const index_type primary_first_ele,   const index_type primary_sub_dim, const index_type primary_global_offset
00136   ,const index_type secondary_first_ele, const index_type secondary_sub_dim
00137   ) const
00138 {
00139   MultiVector::apply_op(
00140     apply_by,primary_op,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
00141     ,reduct_objs
00142     ,primary_first_ele,primary_sub_dim,primary_global_offset
00143     ,secondary_first_ele,secondary_sub_dim
00144     ); // ToDo: Specialize!
00145 }
00146 
00147 void MultiVectorMutableThyra::apply_op(
00148   EApplyBy apply_by, const RTOpPack::RTOp& primary_op, const RTOpPack::RTOp& secondary_op
00149   ,const size_t num_multi_vecs,      const MultiVector*   multi_vecs[]
00150   ,const size_t num_targ_multi_vecs, MultiVectorMutable*  targ_multi_vecs[]
00151   ,RTOpPack::ReductTarget *reduct_obj
00152   ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset
00153   ,const index_type secondary_first_ele, const index_type secondary_sub_dim
00154   ) const
00155 {
00156   MultiVector::apply_op(
00157     apply_by,primary_op,secondary_op,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
00158     ,reduct_obj
00159     ,primary_first_ele,primary_sub_dim,primary_global_offset
00160     ,secondary_first_ele,secondary_sub_dim
00161     ); // ToDo: Specialize!
00162 }
00163 
00164 // Overridden from MultiVectorMutable
00165 
00166 MultiVectorMutable::vec_mut_ptr_t
00167 MultiVectorMutableThyra::col(index_type j)
00168 {
00169   return Teuchos::rcp(new VectorMutableThyra(cast_thyra_multi_vec()->col(j-1)));
00170 }
00171 
00172 MultiVectorMutable::vec_mut_ptr_t
00173 MultiVectorMutableThyra::row(index_type i)
00174 {
00175   return Teuchos::null;
00176 }
00177 
00178 MultiVectorMutable::vec_mut_ptr_t
00179 MultiVectorMutableThyra::diag(int k)
00180 {
00181   return Teuchos::null;
00182 }
00183 
00184 MultiVectorMutable::multi_vec_mut_ptr_t
00185 MultiVectorMutableThyra::mv_sub_view(const Range1D& row_rng_in, const Range1D& col_rng_in)
00186 {
00187   const index_type  this_rows = this->rows();
00188   const Range1D     row_rng = RangePack::full_range(row_rng_in,1,this->rows());
00189   TEST_FOR_EXCEPTION(
00190     !(row_rng.lbound()==1 && row_rng.ubound()==this_rows), std::invalid_argument
00191     ,"MultiVectorMutableThyra::mv_sub_view(thyra_multi_vec): Error, can not handle subviews of the"
00192     " elements in a row yet!"
00193     );
00194   return Teuchos::rcp(new MultiVectorMutableThyra(cast_thyra_multi_vec()->subView(convert(col_rng_in))));
00195 }
00196 
00197 // private
00198 
00199 Teuchos::RCP<Thyra::MultiVectorBase<value_type> >
00200 MultiVectorMutableThyra::cast_thyra_multi_vec()
00201 {
00202   namespace mmp = MemMngPack;
00203   return Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<value_type> >(
00204     Teuchos::rcp_const_cast<Thyra::LinearOpBase<value_type> >(this->thyra_linear_op())
00205     );
00206 }
00207 
00208 } // end namespace AbstractLinAlgPack
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:10:57 2011 for MOOCHO (Single Doxygen Collection) by  doxygen 1.6.3