|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects
Version of the Day
|
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 "AbstractLinAlgPack_VectorSpace.hpp" 00043 #include "AbstractLinAlgPack_VectorSpaceSubSpace.hpp" 00044 #include "AbstractLinAlgPack_VectorSpaceFactory.hpp" 00045 #include "AbstractLinAlgPack_VectorMutable.hpp" 00046 #include "AbstractLinAlgPack_MultiVectorMutable.hpp" 00047 #include "AbstractLinAlgPack_InnerProductDot.hpp" 00048 #include "AbstractLinAlgPack_GenPermMatrixSlice.hpp" 00049 #include "Teuchos_Assert.hpp" 00050 00051 namespace AbstractLinAlgPack { 00052 00053 // Constructors / initializers 00054 00055 VectorSpace::VectorSpace( const inner_prod_ptr_t& inner_prod ) 00056 { 00057 this->inner_prod(inner_prod); 00058 } 00059 00060 void VectorSpace::inner_prod( const inner_prod_ptr_t& inner_prod ) 00061 { 00062 if(inner_prod.get()) { 00063 inner_prod_ = inner_prod; 00064 } else { 00065 inner_prod_ = Teuchos::rcp(new InnerProductDot()); 00066 } 00067 } 00068 00069 const VectorSpace::inner_prod_ptr_t 00070 VectorSpace::inner_prod() const 00071 { 00072 return inner_prod_; 00073 } 00074 00075 // Virtual functions with default implementations 00076 00077 bool VectorSpace::is_in_core() const 00078 { 00079 return false; 00080 } 00081 00082 VectorSpace::space_fcty_ptr_t 00083 VectorSpace::small_vec_spc_fcty() const 00084 { 00085 return Teuchos::null; 00086 } 00087 00088 VectorSpace::vec_mut_ptr_t 00089 VectorSpace::create_member(const value_type& alpha) const 00090 { 00091 namespace mmp = MemMngPack; 00092 vec_mut_ptr_t vec = this->create_member(); 00093 *vec = alpha; 00094 return vec; 00095 } 00096 00097 VectorSpace::multi_vec_mut_ptr_t 00098 VectorSpace::create_members(size_type num_vecs) const 00099 { 00100 return Teuchos::null; 00101 } 00102 00103 VectorSpace::space_ptr_t 00104 VectorSpace::sub_space(const Range1D& rng_in) const 00105 { 00106 namespace mmp = MemMngPack; 00107 const index_type dim = this->dim(); 00108 const Range1D rng = rng_in.full_range() ? Range1D(1,dim) : rng_in; 00109 #ifdef TEUCHOS_DEBUG 00110 TEUCHOS_TEST_FOR_EXCEPTION( 00111 rng.ubound() > dim, std::out_of_range 00112 ,"VectorSpace::sub_space(rng): Error, rng = ["<<rng.lbound()<<","<<rng.ubound()<<"] " 00113 "is not in the range [1,this->dim()] = [1,"<<dim<<"]" ); 00114 #endif 00115 if( rng.lbound() == 1 && rng.ubound() == dim ) 00116 return space_ptr_t( this, false ); 00117 return Teuchos::rcp( 00118 new VectorSpaceSubSpace( 00119 Teuchos::rcp( this, false ) 00120 ,rng ) ); 00121 } 00122 00123 VectorSpace::space_ptr_t 00124 VectorSpace::space( 00125 const GenPermMatrixSlice &P 00126 ,BLAS_Cpp::Transp P_trans 00127 ) const 00128 { 00129 const index_type 00130 dim = BLAS_Cpp::rows( P.rows(), P.cols(), P_trans ); 00131 space_fcty_ptr_t vec_spc_fcty = this->small_vec_spc_fcty(); 00132 if(vec_spc_fcty.get()) 00133 return vec_spc_fcty->create_vec_spc(dim); 00134 return Teuchos::null; 00135 } 00136 00137 // Overridden from AbstractFactory<> 00138 00139 VectorSpace::obj_ptr_t VectorSpace::create() const 00140 { 00141 return this->create_member(); 00142 } 00143 00144 } // end namespace AbstractLinAlgPack
1.7.6.1