MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_MatrixSparseCOORSerial.hpp
Go to the documentation of this file.
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 MATRIX_SPARSE_COOR_SERIAL_H
43 #define MATRIX_SPARSE_COOR_SERIAL_H
44 
49 #include "ReleaseResource.hpp"
50 
51 namespace AbstractLinAlgPack {
52 
58  : virtual public AbstractLinAlgPack::MatrixOp
59  , virtual public MatrixLoadSparseElements
60  , virtual public MatrixExtractSparseElements
61 {
62 public:
63 
66 
68  typedef Teuchos::RCP<
76  {
77  public:
83  )
84  :val_(val)
85  ,row_i_(row_i)
86  ,col_j_(col_j)
87  ,owns_mem_(true)
88  {}
89  // Calls delete on buffers if <tt>this->owns_memory() == true</tt>
92  bool resource_is_bound() const;
94  void release_ownership() { owns_mem_ = false; }
95  value_type* val() { return val_; }
96  index_type* row_i() { return row_i_; }
97  index_type* col_j() { return col_j_; }
98  private:
102  bool owns_mem_;
103  // not defined and not to be called
107  }; // end class ReleaseValRowColArrays
108 
110 
113 
117 
168  void set_buffers(
169  size_type max_nz
170  ,value_type *val
171  ,index_type *row_i
172  ,index_type *col_j
174  ,size_type rows = 0
175  ,size_type cols = 0
176  ,size_type nz = 0
177  ,bool check_input = false
178  );
179 
188  void set_uninitialized();
189 
191 
194 
196  value_type* val();
198  const value_type* val() const;
200  index_type* row_i();
202  const index_type* row_i() const;
204  index_type* col_j();
206  const index_type* col_j() const;
209 
211 
214 
216  size_type rows() const;
218  size_type cols() const;
220  size_type nz() const;
221 
223 
226 
228  const VectorSpace& space_cols() const;
230  const VectorSpace& space_rows() const;
232  MatrixOp& operator=(const MatrixOp& M);
234  std::ostream& output(std::ostream& out) const;
236  void Vp_StMtV(
237  VectorMutable* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
238  , const Vector& v_rhs2, value_type beta) const;
239 
240  // ToDo: Add more method overrides as they are needed!
241 
243 
246 
248  void reinitialize(
250  ,size_type cols
251  ,size_type max_nz
252  ,EAssumeElementUniqueness element_uniqueness
253  );
254  void reset_to_load_values();
257  size_type max_nz_load
258  ,value_type **val
259  ,index_type **row_i
260  ,index_type **col_j
261  );
264  size_type nz_commit
265  ,value_type **val
266  ,index_type **row_i
267  ,index_type **col_j
268  );
270  void finish_construction( bool test_setup );
271 
273 
276 
279  EElementUniqueness element_uniqueness
280  ,const index_type inv_row_perm[]
281  ,const index_type inv_col_perm[]
282  ,const Range1D &row_rng
283  ,const Range1D &col_rng
284  ,index_type dl
285  ,index_type du
286  ) const;
289  EElementUniqueness element_uniqueness
290  ,const index_type inv_row_perm[]
291  ,const index_type inv_col_perm[]
292  ,const Range1D &row_rng
293  ,const Range1D &col_rng
294  ,index_type dl
295  ,index_type du
296  ,value_type alpha
297  ,const index_type len_Aval
298  ,value_type Aval[]
299  ,const index_type len_Aij
300  ,index_type Arow[]
301  ,index_type Acol[]
302  ,const index_type row_offset
303  ,const index_type col_offset
304  ) const;
305 
307 
308 private:
309 
310  // //////////////////////////////
311  // Private types
312 
313  // //////////////////////////////
314  // Public types
315 
325 
326  bool self_allocate_; // True if this allocates the memory
327 
330 
332  bool reload_val_only_; // cashed
334 
335  // //////////////////////////////
336  // Private member functions
337 
338  void make_storage_unique();
339 
340  // static
342 
343 }; // end class MatrixSparseCOORSerial
344 
345 // //////////////////////////////////
346 // Inline members
347 
348 inline
350 {
352  return val_;
353 }
354 
355 inline
357 {
358  return val_;
359 }
360 
361 inline
363 {
365  return row_i_;
366 }
367 
368 inline
370 {
371  return row_i_;
372 }
373 
374 inline
376 {
378  return col_j_;
379 }
380 
381 inline
383 {
384  return col_j_;
385 }
386 
387 inline
390 {
392 }
393 
394 } // end namespace AbstractLinAlgPack
395 
396 #endif // MATRIX_SPARSE_COOR_SERIAL_H
397 
void reset_to_load_values()
Reinitialize internal counter to load new nonzero values.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
void commit_load_nonzeros_buffers(size_type nz_commit, value_type **val, index_type **row_i, index_type **col_j)
ReleaseValRowColArrays & operator=(const ReleaseValRowColArrays &)
Mix-in interface for loading nonzero elements into a sparse matrix data structure.
Interface for extracting nonzero elements from a banded subregion of a permuted sparse matrix in one ...
Teuchos::RCP< MemMngPack::ReleaseResource > release_resource_ptr_t
void Vp_StMtV(VectorMutable *vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const
. One-based subregion index range class.
void set_buffers(size_type max_nz, value_type *val, index_type *row_i, index_type *col_j, const release_resource_ptr_t &release_resource, size_type rows=0, size_type cols=0, size_type nz=0, bool check_input=false)
Give memory to use to store nonzero elements.
Abstract interface for objects that represent a space for mutable coordinate vectors.
void coor_extract_nonzeros(EElementUniqueness element_uniqueness, const index_type inv_row_perm[], const index_type inv_col_perm[], const Range1D &row_rng, const Range1D &col_rng, index_type dl, index_type du, value_type alpha, const index_type len_Aval, value_type Aval[], const index_type len_Aij, index_type Arow[], index_type Acol[], const index_type row_offset, const index_type col_offset) const
Abstract interface for releasing an object when it is not needed anymore {abstract}.
std::ostream * out
const LAPACK_C_Decl::f_int & M
void get_load_nonzeros_buffers(size_type max_nz_load, value_type **val, index_type **row_i, index_type **col_j)
ReleaseValRowColArrays(value_type *val, index_type *row_i, index_type *col_j)
Gives pointers to buffers to delete[].
Base class for all matrices that support basic matrix operations.
Abstract interface for mutable coordinate vectors {abstract}.
void set_uninitialized()
Release all owned memory and make uninitialized.
Subclass for serial vector space objects that create VectorMutableDense vector and MultiVectorMutable...
Transp
TRANS.
void reinitialize(size_type rows, size_type cols, size_type max_nz, EAssumeElementUniqueness element_uniqueness)
index_type count_nonzeros(EElementUniqueness element_uniqueness, const index_type inv_row_perm[], const index_type inv_col_perm[], const Range1D &row_rng, const Range1D &col_rng, index_type dl, index_type du) const