AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AbstractLinAlgPack_MultiVectorMutableDense.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef MULTI_VECTOR_MUTABLE_DENSE_H
43 #define MULTI_VECTOR_MUTABLE_DENSE_H
44 
45 #include "AbstractLinAlgPack_MatrixOpSerial.hpp"
46 #include "AbstractLinAlgPack_MatrixOpGetGMSMutable.hpp"
47 #include "AbstractLinAlgPack_MultiVectorMutable.hpp"
48 #include "DenseLinAlgPack_DMatrixClass.hpp"
49 #include "ReleaseResource.hpp"
50 
51 namespace AbstractLinAlgPack {
52 
84  : public AbstractLinAlgPack::MultiVectorMutable // doxygen needs the full path
85  , public MatrixOpSerial
86  , public MatrixOpGetGMS
87 {
88 public:
89 
91  typedef Teuchos::RCP<
93 
96 
100  const size_type rows = 0
101  ,const size_type cols = 0
102  );
106  DMatrixSlice gms
109  );
113  void initialize(
114  const size_type rows
115  ,const size_type cols
116  );
127  void initialize(
128  DMatrixSlice gms
131  );
132 
134 
137 
148  const DMatrixSlice get_gms() const;
151  BLAS_Cpp::Transp gms_trans() const;
155  const release_resource_ptr_t& gms_release() const;
156 
158 
161 
163  const DMatrixSlice get_gms_view() const;
165  void free_gms_view(const DMatrixSlice* gms_view) const;
166 
168 
171 
175  void commit_gms_view(DMatrixSlice* gms_view);
176 
178 
181 
183  size_type rows() const;
185  size_type cols() const;
186 
188 
191 
193  void zero_out();
195  void Mt_S( value_type alpha );
197  MatrixOp& operator=(const MatrixOp& mwo_rhs);
199  std::ostream& output(std::ostream& out) const;
201  bool Mp_StM(
202  MatrixOp* mwo_lhs, value_type alpha
203  ,BLAS_Cpp::Transp trans_rhs
204  ) const;
206  bool Mp_StM(
207  value_type alpha,const MatrixOp& M_rhs, BLAS_Cpp::Transp trans_rhs
208  );
210  bool syrk(
211  BLAS_Cpp::Transp M_trans, value_type alpha
212  ,value_type beta, MatrixSymOp* sym_lhs
213  ) const;
215  bool Mp_StMtM(
216  MatrixOp* mwo_lhs, value_type alpha
217  ,const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1
218  ,BLAS_Cpp::Transp trans_rhs2
219  ,value_type beta ) const;
221  bool Mp_StMtM(
222  MatrixOp* mwo_lhs, value_type alpha
223  ,BLAS_Cpp::Transp trans_rhs1
224  ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2
225  ,value_type beta ) const;
226 
228 
231 
233  access_by_t access_by() const;
234 
236 
239 
241  vec_mut_ptr_t col(index_type j);
243  vec_mut_ptr_t row(index_type i);
245  vec_mut_ptr_t diag(int k);
247  multi_vec_mut_ptr_t mv_sub_view(const Range1D& row_rng, const Range1D& col_rng);
248 
250 
253 
255  void Vp_StMtV(
256  DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
257  , const DVectorSlice& vs_rhs2, value_type beta) const;
259  void Vp_StMtV(
260  DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
261  , const SpVectorSlice& sv_rhs2, value_type beta) const;
262 
263  // ToDo: Add more overrides as they are needed!
264 
266 
267 protected:
268 
271 
273  void apply_op(
274  EApplyBy apply_by, const RTOpPack::RTOp& primary_op
275  ,const size_t num_multi_vecs, const MultiVector** multi_vecs
276  ,const size_t num_targ_multi_vecs, MultiVectorMutable** targ_multi_vecs
277  ,RTOpPack::ReductTarget* reduct_objs[]
278  ,const index_type primary_first_ele , const index_type primary_sub_dim , const index_type primary_global_offset
279  ,const index_type secondary_first_ele , const index_type secondary_sub_dim
280  ) const;
282  void apply_op(
283  EApplyBy apply_by, const RTOpPack::RTOp& primary_op, const RTOpPack::RTOp& secondary_op
284  ,const size_t num_multi_vecs, const MultiVector** multi_vecs
285  ,const size_t num_targ_multi_vecs, MultiVectorMutable** targ_multi_vecs
286  ,RTOpPack::ReductTarget *reduct_obj
287  ,const index_type primary_first_ele , const index_type primary_sub_dim , const index_type primary_global_offset
288  ,const index_type secondary_first_ele , const index_type secondary_sub_dim
289  ) const;
290 
292 
293 private:
294 
295  // ///////////////////////////////////////
296  // Private data members
297 
298  DMatrixSlice gms_;
299  BLAS_Cpp::Transp gms_trans_;
300  release_resource_ptr_t gms_release_;
301 
302 }; // end class MultiVectorMutableDense
303 
304 // //////////////////////////////////////
305 // Inline members
306 
307 inline
310 {
311  return gms_;
312 }
313 
314 inline
315 const DMatrixSlice
317 {
318  return gms_;
319 }
320 
321 inline
324 {
325  return gms_trans_;
326 }
327 
328 inline
331 {
332  return gms_release_;
333 }
334 
335 } // end namespace AbstractLinAlgPack
336 
337 #endif // MULTI_VECTOR_MUTABLE_DENSE_H
void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector **multi_vecs, const size_t num_targ_multi_vecs, MultiVectorMutable **targ_multi_vecs, RTOpPack::ReductTarget *reduct_objs[], const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset, const index_type secondary_first_ele, const index_type secondary_sub_dim) const
void initialize(const size_type rows, const size_type cols)
Call this->initialize(v,v_release) with an allocated DenseLinAlgPack::DVector object.
void Vp_StMtV(DVectorSlice *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice &vs_rhs2, value_type beta) const
MultiVectorMutable "Adapter" subclass for DenseLinAlgPack::DMatrixSlice or DenseLinAlgPack::DMatrix o...
multi_vec_mut_ptr_t mv_sub_view(const Range1D &row_rng, const Range1D &col_rng)
bool Mp_StM(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs) const
BLAS_Cpp::Transp gms_trans() const
Return if underlying matrix is being viewed as the transpose or non-transposed.
Base class for all matrices implemented in a shared memory address space.
bool Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &mwo_rhs1, BLAS_Cpp::Transp trans_rhs1, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
Interface adding operations specific for a symmetric matrix {abstract}.
DMatrixSlice set_gms()
Return the non-const dense matrix.
const DMatrixSlice get_gms() const
Return a const dense matrix.
Teuchos::RCP< MemMngPack::ReleaseResource > release_resource_ptr_t
Abstract interface that allows the extraction of a const DMatrixSlice view of an abstract matrix...
Base class for all matrices that support basic matrix operations.
Interface for a collection of non-mutable vectors (multi-vector, matrix).
MultiVectorMutableDense(const size_type rows=0, const size_type cols=0)
Calls this->initialize(rows,cols).
Interface for a collection of mutable vectors (multi-vector, matrix).
bool syrk(BLAS_Cpp::Transp M_trans, value_type alpha, value_type beta, MatrixSymOp *sym_lhs) const
Transp
const release_resource_ptr_t & gms_release() const
Return a RCP<> pointer to the object that will release the associated resource.