MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_GenPermMatrixSlice.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 GEN_PERM_MATRIX_SLICE_H
43 #define GEN_PERM_MATRIX_SLICE_H
44 
46 
47 namespace AbstractLinAlgPack {
48 
66 public:
67 
70 
73 
76 
81  typedef ptrdiff_t difference_type;
82 
84 
87 
90 
109 
151  void initialize(
154  ,index_type nz
155  ,difference_type row_off
156  ,difference_type col_off
158  ,const index_type row_i[]
159  ,const index_type col_j[]
160  ,bool test_setup = false
161  );
162 
188  void initialize_and_sort(
191  ,index_type nz
192  ,difference_type row_off
193  ,difference_type col_off
195  ,index_type row_i[]
196  ,index_type col_j[]
197  ,bool test_setup = false
198  );
199 
205  void bind( const GenPermMatrixSlice& gpms );
206 
208  index_type rows() const;
210  index_type cols() const;
212  index_type nz() const;
214  EOrderedBy ordered_by() const;
216  bool is_identity() const;
217 
234  index_type lookup_row_i(index_type col_j) const;
235 
252  index_type lookup_col_j(index_type row_i) const;
253 
256 
276  const_iterator begin() const;
277 
279  const_iterator end() const;
280 
282 
307  , EOrderedBy ordered_by ) const;
308 
309 private:
310 
311  // //////////////////////////////
312  // Private data members
313 
322 
323  // //////////////////////////////
324  // Private static data members
325 
326  // ToDo: We could allocate a class-wide array, initialize
327  // it to [1,2,3 ...] and then use it for the iterators
328  // when is_idenity() == true! This would make implementing
329  // a lot of code a lot easier if we don't care about a little
330  // inefficiency! We could just allocate a large chunk
331  // of memory by default (or client could do this for us)
332  // and then construct it when needed. If a client ever
333  // requested an iterator when not enough storage was avalible
334  // then we would throw an exception.
335 
336  // //////////////////////////////
337  // Private member functions
338 
339  // Validate the input data (not the ordering!)
340  static void validate_input_data(
343  ,index_type nz
344  ,difference_type row_off
345  ,difference_type col_off
347  ,const index_type row_i[]
348  ,const index_type col_j[]
349  ,std::ostringstream &omsg
350  );
351 
353  void validate_not_identity() const;
354 
357 
358 }; // end class GenPermMatrixSlice
359 
360 // //////////////////////////////////////////////////////////
361 // Inline members for GenPermMatrixSlice
362 
363 inline
365 {
366  initialize(rows,cols,type);
367 }
368 
369 inline
371 {
372  return rows_;
373 }
374 
375 inline
377 {
378  return cols_;
379 }
380 
381 inline
383 {
384  return nz_;
385 }
386 
387 inline
389 {
390  return nz_ > 0 && row_i_ == NULL;
391 }
392 
393 inline
395 {
396  return ordered_by_;
397 }
398 
399 } // end namespace AbstractLinAlgPack
400 
401 #endif // GEN_PERM_MATRIX_SLICE_H
GenPermMatrixSlice()
Construct to an uninitialzied, unsized matrix.
GenPermMatrixSliceIteratorPack::EOrderedBy EOrderedBy
GenPermMatrixSlice & operator=(const GenPermMatrixSlice &)
not defined and not to be called
void initialize(index_type rows, index_type cols, EIdentityOrZero type)
Initialize an identity or zero permutation.
size_type rows(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return rows of a possible transposed matrix.
const_iterator end() const
Return the end of this->const_iterator_begin().
void bind(const GenPermMatrixSlice &gpms)
Bind the view of another GenPermMatrixSlice object.
. One-based subregion index range class.
This is a full random access iterator for accessing row and colunmn indices.
static void validate_input_data(index_type rows, index_type cols, index_type nz, difference_type row_off, difference_type col_off, EOrderedBy ordered_by, const index_type row_i[], const index_type col_j[], std::ostringstream &omsg)
const GenPermMatrixSlice create_submatrix(const Range1D &rng, EOrderedBy ordered_by) const
Create a submatrix by row, by column.
const_iterator begin() const
Return a random access iterator for accessing which row and column that each nonzero 1...
size_type cols(size_type rows, size_type cols, BLAS_Cpp::Transp _trans)
Return columns of a possible transposed matrix.
index_type lookup_row_i(index_type col_j) const
Lookup the ith row index for the nonzero entry in the jth column if it exists.
void initialize_and_sort(index_type rows, index_type cols, index_type nz, difference_type row_off, difference_type col_off, EOrderedBy ordered_by, index_type row_i[], index_type col_j[], bool test_setup=false)
Initialize and sort.
index_type lookup_col_j(index_type row_i) const
Lookup the jth column index for the nonzero entry in the ith row if it exists.
Concrete matrix type to represent general permutation (mapping) matrices.
GenPermMatrixSliceIteratorPack::row_col_iterator< const index_type > const_iterator