|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) 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 Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP 00030 #define THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP 00031 00032 00033 #include "Thyra_AddedLinearOpBase.hpp" 00034 #include "Teuchos_ConstNonconstObjectContainer.hpp" 00035 00036 00037 namespace Thyra { 00038 00039 00071 template<class Scalar> 00072 class DefaultAddedLinearOp : virtual public AddedLinearOpBase<Scalar> 00073 { 00074 public: 00075 00078 00085 DefaultAddedLinearOp(); 00086 00092 DefaultAddedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops); 00093 00099 DefaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops); 00100 00118 void initialize(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops); 00119 00139 void initialize(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops); 00140 00147 void uninitialize(); 00148 00150 00153 00155 int numOps() const; 00157 bool opIsConst(const int k) const; 00159 RCP<LinearOpBase<Scalar> > getNonconstOp(const int k); 00161 RCP<const LinearOpBase<Scalar> > getOp(const int k) const; 00162 00164 00167 00171 RCP< const VectorSpaceBase<Scalar> > range() const; 00172 00176 RCP< const VectorSpaceBase<Scalar> > domain() const; 00177 00179 RCP<const LinearOpBase<Scalar> > clone() const; 00180 00182 00185 00189 std::string description() const; 00190 00198 void describe( 00199 Teuchos::FancyOStream &out, 00200 const Teuchos::EVerbosityLevel verbLevel 00201 ) const; 00202 00204 00207 00209 THYRA_DEPRECATED DefaultAddedLinearOp( 00210 const int numOps, 00211 const RCP<const LinearOpBase<Scalar> > Ops[] 00212 ); 00213 00215 THYRA_DEPRECATED DefaultAddedLinearOp( 00216 const int numOps, 00217 const RCP<LinearOpBase<Scalar> > Ops[] 00218 ); 00219 00221 THYRA_DEPRECATED void initialize( 00222 const int numOps_in, 00223 const RCP<LinearOpBase<Scalar> > Ops[] 00224 ) 00225 { 00226 initialize(Teuchos::arrayView(Ops, numOps_in)); 00227 } 00228 00230 THYRA_DEPRECATED void initialize( 00231 const int numOps_in, 00232 const RCP<const LinearOpBase<Scalar> > Ops[] 00233 ) 00234 { 00235 initialize(Teuchos::arrayView(Ops, numOps_in)); 00236 } 00237 00239 00240 protected: 00241 00244 00248 bool opSupportedImpl(EOpTransp M_trans) const; 00249 00251 void applyImpl( 00252 const EOpTransp M_trans, 00253 const MultiVectorBase<Scalar> &X, 00254 const Ptr<MultiVectorBase<Scalar> > &Y, 00255 const Scalar alpha, 00256 const Scalar beta 00257 ) const; 00258 00260 00261 private: 00262 00263 std::vector<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > > Ops_; 00264 00265 void assertInitialized() const; 00266 void validateOps(); 00267 void setupDefaultObjectLabel(); 00268 00269 // Not defined and not to be called 00270 DefaultAddedLinearOp(const DefaultAddedLinearOp&); 00271 DefaultAddedLinearOp& operator=(const DefaultAddedLinearOp&); 00272 00273 }; 00274 00275 00277 template<class Scalar> 00278 inline 00279 RCP<DefaultAddedLinearOp<Scalar> > 00280 defaultAddedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops) 00281 { 00282 return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops)); 00283 } 00284 00285 00287 template<class Scalar> 00288 inline 00289 RCP<DefaultAddedLinearOp<Scalar> > 00290 defaultAddedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops) 00291 { 00292 return Teuchos::rcp(new DefaultAddedLinearOp<Scalar>(Ops)); 00293 } 00294 00295 00300 template<class Scalar> 00301 RCP<LinearOpBase<Scalar> > 00302 nonconstAdd( 00303 const RCP<LinearOpBase<Scalar> > &A, 00304 const RCP<LinearOpBase<Scalar> > &B, 00305 const std::string &label = "" 00306 ); 00307 00308 00313 template<class Scalar> 00314 RCP<const LinearOpBase<Scalar> > 00315 add( 00316 const RCP<const LinearOpBase<Scalar> > &A, 00317 const RCP<const LinearOpBase<Scalar> > &B, 00318 const std::string &label = "" 00319 ); 00320 00321 00326 template<class Scalar> 00327 RCP<LinearOpBase<Scalar> > 00328 nonconstSubtract( 00329 const RCP<LinearOpBase<Scalar> > &A, 00330 const RCP<LinearOpBase<Scalar> > &B, 00331 const std::string &label = "" 00332 ); 00333 00334 00339 template<class Scalar> 00340 RCP<const LinearOpBase<Scalar> > 00341 subtract( 00342 const RCP<const LinearOpBase<Scalar> > &A, 00343 const RCP<const LinearOpBase<Scalar> > &B, 00344 const std::string &label = "" 00345 ); 00346 00347 00348 // ///////////////////////////////// 00349 // Inline members 00350 00351 00352 template<class Scalar> 00353 inline 00354 void DefaultAddedLinearOp<Scalar>::assertInitialized() const 00355 { 00356 #ifdef TEUCHOS_DEBUG 00357 TEST_FOR_EXCEPT( !( numOps() > 0 ) ); 00358 #endif 00359 } 00360 00361 00362 } // end namespace Thyra 00363 00364 00365 #endif // THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
1.7.4