AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
AbstractLinAlgPack_VectorMutableDense.hpp
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 #ifndef VECTOR_WITH_OP_MUTABLE_DENSE_H
00043 #define VECTOR_WITH_OP_MUTABLE_DENSE_H
00044 
00045 #include "AbstractLinAlgPack_VectorSpaceSerial.hpp"
00046 #include "AbstractLinAlgPack_VectorMutable.hpp"
00047 #include "AbstractLinAlgPack_VectorApplyOpSerialBase.hpp"
00048 #include "DenseLinAlgPack_DVectorClass.hpp"
00049 #include "Teuchos_RCP.hpp"
00050 #include "ReleaseResource.hpp"
00051 
00052 namespace AbstractLinAlgPack {
00053 
00084 class VectorMutableDense
00085   : virtual public VectorMutable
00086   , virtual private VectorApplyOpSerialBase
00087 {
00088 public:
00089 
00091   typedef Teuchos::RCP<
00092     MemMngPack::ReleaseResource>  release_resource_ptr_t;
00093 
00096 
00099   VectorMutableDense(
00100     const size_type                    dim = 0
00101     );
00104   VectorMutableDense(
00105     DVectorSlice                        v
00106     ,const release_resource_ptr_t&     v_release
00107     );
00111   void initialize(
00112     const size_type                    dim
00113     );
00116   void initialize(
00117     DVectorSlice                        v
00118     ,const release_resource_ptr_t&     v_release
00119     );
00120 
00122 
00125   
00136   DVectorSlice set_vec();
00139   const DVectorSlice get_vec() const;
00143   const release_resource_ptr_t& vec_release() const;
00144 
00146 
00149 
00151   const VectorSpace& space() const;
00153   void apply_op(
00154     const RTOpPack::RTOp& op
00155     ,const size_t num_vecs, const Vector* vecs[]
00156     ,const size_t num_targ_vecs, VectorMutable* targ_vecs[]
00157     ,RTOpPack::ReductTarget *reduct_obj
00158     ,const index_type first_ele, const index_type sub_dim, const index_type global_offset
00159     ) const;
00161   index_type dim() const;
00163   value_type get_ele(index_type i) const;
00165   void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const;
00167   void free_sub_vector( RTOpPack::SubVector* sub_vec ) const;
00168 
00170 
00173 
00175   VectorMutable& operator=(value_type alpha);
00177   VectorMutable& operator=(const Vector& v);
00179   VectorMutable& operator=(const VectorMutable& v);
00181   void set_ele( index_type i, value_type val );
00183   vec_mut_ptr_t sub_view( const Range1D& rng );
00185   void get_sub_vector( const Range1D& rng, RTOpPack::MutableSubVector* sub_vec );
00187   void commit_sub_vector( RTOpPack::MutableSubVector* sub_vec );
00189   void set_sub_vector( const RTOpPack::SparseSubVector& sub_vec );
00191   void Vp_StMtV(
00192     value_type                       alpha
00193     ,const GenPermMatrixSlice        &P
00194     ,BLAS_Cpp::Transp                P_trans
00195     ,const Vector                    &x
00196     ,value_type                      beta
00197     );
00198 
00200 
00202   VectorMutableDense* operator&()
00203   {
00204     return this;
00205   }
00206 private:
00207 
00208   // ///////////////////////////////////////
00209   // Private data members
00210   
00211   DVectorSlice              v_;
00212   release_resource_ptr_t    v_release_;
00213   VectorSpaceSerial         space_;
00214 
00215   // Not defined and not to be called
00216   //VectorMutableDense(const VectorMutableDense&);
00217   VectorMutableDense& operator=(const VectorMutableDense&);
00218 
00219 }; // end class VectorMutableDense
00220 
00221 // //////////////////////////////////////
00222 // Inline members
00223 
00224 inline
00225 DVectorSlice
00226 VectorMutableDense::set_vec()
00227 {
00228   this->has_changed();
00229   return v_;
00230 }
00231 
00232 inline
00233 const DVectorSlice
00234 VectorMutableDense::get_vec() const
00235 {
00236   return v_;
00237 }
00238 
00239 inline
00240 const VectorMutableDense::release_resource_ptr_t&
00241 VectorMutableDense::vec_release() const
00242 {
00243   return v_release_;
00244 }
00245 
00246 } // end namespace AbstractLinAlgPack
00247 
00248 #endif // VECTOR_WITH_OP_MUTABLE_DENSE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends