|
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_LINEAR_OP_DECL_HPP 00030 #define THYRA_LINEAR_OP_DECL_HPP 00031 00032 #include "Thyra_OperatorVectorTypes.hpp" 00033 #include "Teuchos_Describable.hpp" 00034 #include "Teuchos_ExpandScalarTypeMacros.hpp" 00035 #include "Teuchos_PromotionTraits.hpp" 00036 00037 00038 namespace Thyra { 00039 00040 00177 template<class Scalar> 00178 class LinearOpBase : virtual public Teuchos::Describable { 00179 public: 00180 00183 00199 virtual RCP< const VectorSpaceBase<Scalar> > range() const = 0; 00200 00216 virtual RCP< const VectorSpaceBase<Scalar> > domain() const = 0; 00217 00229 bool opSupported(EOpTransp M_trans) const 00230 { 00231 return opSupportedImpl(M_trans); 00232 } 00233 00279 void apply( 00280 const EOpTransp M_trans, 00281 const MultiVectorBase<Scalar> &X, 00282 const Ptr<MultiVectorBase<Scalar> > &Y, 00283 const Scalar alpha, 00284 const Scalar beta 00285 ) const 00286 { 00287 applyImpl(M_trans, X, Y, alpha, beta); 00288 } 00289 00302 virtual RCP<const LinearOpBase<Scalar> > clone() const; 00303 00305 00308 00310 THYRA_DEPRECATED bool applySupports( const EConj conj ) const; 00311 00313 THYRA_DEPRECATED void apply( 00314 const EConj conj, 00315 const MultiVectorBase<Scalar> &X, 00316 MultiVectorBase<Scalar> *Y, 00317 const Scalar alpha = static_cast<Scalar>(1.0), 00318 const Scalar beta = static_cast<Scalar>(0.0) 00319 ) const; 00320 00322 THYRA_DEPRECATED bool applyTransposeSupports( const EConj conj ) const; 00323 00325 THYRA_DEPRECATED void applyTranspose( 00326 const EConj conj, 00327 const MultiVectorBase<Scalar> &X, 00328 MultiVectorBase<Scalar> *Y, 00329 const Scalar alpha = static_cast<Scalar>(1.0), 00330 const Scalar beta = static_cast<Scalar>(0.0) 00331 ) const; 00332 00334 00335 protected: 00336 00339 00341 virtual bool opSupportedImpl(EOpTransp M_trans) const = 0; 00342 00344 virtual void applyImpl( 00345 const EOpTransp M_trans, 00346 const MultiVectorBase<Scalar> &X, 00347 const Ptr<MultiVectorBase<Scalar> > &Y, 00348 const Scalar alpha, 00349 const Scalar beta 00350 ) const = 0; 00351 00353 00354 private: 00355 00356 // Not defined and not to be called 00357 LinearOpBase<Scalar>& 00358 operator=(const LinearOpBase<Scalar>&); 00359 00360 }; 00361 00362 00368 template<class Scalar> 00369 bool isFullyUninitialized( const LinearOpBase<Scalar> &M ); 00370 00371 00377 template<class Scalar> 00378 bool isPartiallyInitialized( const LinearOpBase<Scalar> &M ); 00379 00380 00386 template<class Scalar> 00387 bool isFullyInitialized( const LinearOpBase<Scalar> &M ); 00388 00389 00394 template<class Scalar> 00395 inline 00396 bool opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans ); 00397 00398 00403 template<class Scalar> 00404 void apply( 00405 const LinearOpBase<Scalar> &M, 00406 const EOpTransp M_trans, 00407 const MultiVectorBase<Scalar> &X, 00408 const Ptr<MultiVectorBase<Scalar> > &Y, 00409 const Scalar alpha = static_cast<Scalar>(1.0), 00410 const Scalar beta = static_cast<Scalar>(0.0) 00411 ); 00412 00413 00420 inline 00421 void apply( 00422 const LinearOpBase<double> &M, 00423 const EOpTransp M_trans, 00424 const MultiVectorBase<double> &X, 00425 const Ptr<MultiVectorBase<double> > &Y, 00426 const double alpha = 1.0, 00427 const double beta = 0.0 00428 ); 00429 00430 00431 // Deprecated 00432 00433 00435 template<class Scalar> 00436 inline 00437 THYRA_DEPRECATED void apply( 00438 const LinearOpBase<Scalar> &M, 00439 const EConj conj, 00440 const MultiVectorBase<Scalar> &X, 00441 MultiVectorBase<Scalar> *Y, 00442 const Scalar alpha = static_cast<Scalar>(1.0), 00443 const Scalar beta = static_cast<Scalar>(0.0) 00444 ); 00445 00446 00448 template<class Scalar> 00449 inline 00450 THYRA_DEPRECATED void applyTranspose( 00451 const LinearOpBase<Scalar> &M, 00452 const EConj conj, 00453 const MultiVectorBase<Scalar> &X, 00454 MultiVectorBase<Scalar> *Y, 00455 const Scalar alpha = static_cast<Scalar>(1.0), 00456 const Scalar beta = static_cast<Scalar>(0.0) 00457 ); 00458 00459 00461 template<class Scalar> 00462 THYRA_DEPRECATED void apply( 00463 const LinearOpBase<Scalar> &M, 00464 const EOpTransp M_trans, 00465 const MultiVectorBase<Scalar> &X, 00466 MultiVectorBase<Scalar> *Y, 00467 const Scalar alpha = static_cast<Scalar>(1.0), 00468 const Scalar beta = static_cast<Scalar>(0.0) 00469 ); 00470 00471 00472 } // end namespace Thyra 00473 00474 00475 // 00476 // Inline and other Template Implementations 00477 // 00478 00479 00480 template<class Scalar> 00481 inline 00482 bool Thyra::isFullyUninitialized( const LinearOpBase<Scalar> &M ) 00483 { 00484 return ( is_null(M.range()) || is_null(M.domain()) ); 00485 } 00486 00487 00488 template<class Scalar> 00489 bool Thyra::isPartiallyInitialized( const LinearOpBase<Scalar> &M ) 00490 { 00491 return 00492 ( 00493 ( !is_null(M.range()) && !is_null(M.domain()) ) 00494 && 00495 ( 00496 !opSupported(M,NOTRANS) && !opSupported(M,CONJ) 00497 && !opSupported(M,TRANS) && !opSupported(M,CONJTRANS) 00498 ) 00499 ); 00500 } 00501 00502 00503 template<class Scalar> 00504 bool Thyra::isFullyInitialized( const LinearOpBase<Scalar> &M ) 00505 { 00506 return 00507 ( 00508 ( !is_null(M.range()) && !is_null(M.domain()) ) 00509 && 00510 ( 00511 opSupported(M,NOTRANS) || opSupported(M,CONJ) 00512 || opSupported(M,TRANS) || opSupported(M,CONJTRANS) 00513 ) 00514 ); 00515 } 00516 00517 00518 template<class Scalar> 00519 inline 00520 bool Thyra::opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans ) 00521 { 00522 return M.opSupported(M_trans); 00523 } 00524 00525 00526 inline 00527 void Thyra::apply( 00528 const LinearOpBase<double> &M, 00529 const EOpTransp M_trans, 00530 const MultiVectorBase<double> &X, 00531 const Ptr<MultiVectorBase<double> > &Y, 00532 const double alpha, 00533 const double beta 00534 ) 00535 { 00536 apply<double>(M, M_trans, X, Y, alpha, beta); 00537 } 00538 00539 00540 // Deprecated 00541 00542 00543 template<class Scalar> 00544 inline 00545 void Thyra::apply( 00546 const LinearOpBase<Scalar> &M, 00547 const EConj conj, 00548 const MultiVectorBase<Scalar> &X, 00549 MultiVectorBase<Scalar> *Y, 00550 const Scalar alpha, 00551 const Scalar beta 00552 ) 00553 { 00554 M.apply(conj, X, Y, alpha, beta); 00555 } 00556 00557 00558 template<class Scalar> 00559 inline 00560 void Thyra::applyTranspose( 00561 const LinearOpBase<Scalar> &M, 00562 const EConj conj, 00563 const MultiVectorBase<Scalar> &X, 00564 MultiVectorBase<Scalar> *Y, 00565 const Scalar alpha, 00566 const Scalar beta 00567 ) 00568 { 00569 M.applyTranspose(conj, X, Y, alpha, beta); 00570 } 00571 00572 00573 template<class Scalar> 00574 inline 00575 void Thyra::apply( 00576 const LinearOpBase<Scalar> &M, 00577 const EOpTransp M_trans, 00578 const MultiVectorBase<Scalar> &X, 00579 MultiVectorBase<Scalar> *Y, 00580 const Scalar alpha, 00581 const Scalar beta 00582 ) 00583 { 00584 apply(M, M_trans, X, Teuchos::ptr(Y), alpha, beta); 00585 } 00586 00587 00588 #endif // THYRA_LINEAR_OP_DECL_HPP
1.7.4