Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_IntSerialDenseMatrix.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_INTSERIALDENSEMATRIX_H
45 #define EPETRA_INTSERIALDENSEMATRIX_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 #include "Epetra_Object.h"
56 
58 
124 //=========================================================================
125 class EPETRA_LIB_DLL_EXPORT Epetra_IntSerialDenseMatrix : public Epetra_Object {
126 
127  public:
128 
130 
131 
138 
140 
151  Epetra_IntSerialDenseMatrix(int NumRows, int NumCols);
152 
154 
169  Epetra_IntSerialDenseMatrix(Epetra_DataAccess CV, int* A, int LDA, int NumRows, int NumCols);
170 
172 
176 
178  virtual ~Epetra_IntSerialDenseMatrix ();
180 
182 
183 
196  int Shape(int NumRows, int NumCols);
197 
199 
212  int Reshape(int NumRows, int NumCols);
214 
216 
217 
219 
222  virtual int OneNorm();
223 
225  virtual int InfNorm();
226 
228 
235 
237 
240  bool operator==(const Epetra_IntSerialDenseMatrix& rhs) const;
241 
243 
246  { return !(*this == rhs); }
247 
249 
258  int& operator () (int RowIndex, int ColIndex);
259 
261 
270  const int& operator () (int RowIndex, int ColIndex) const;
271 
273 
283  int* operator [] (int ColIndex);
284 
286 
296  const int* operator [] (int ColIndex) const;
297 
299 
305  int Random();
306 
308  int M() const {return(M_);};
309 
311  int N() const {return(N_);};
312 
314  const int* A() const {return(A_);};
315 
317  int* A() {return(A_);};
318 
320  int LDA() const {return(LDA_);};
321 
323  Epetra_DataAccess CV() const {return(CV_);};
325 
327 
328  virtual void Print(std::ostream& os) const;
331 
333 
334 
336 
353  int MakeViewOf(const Epetra_IntSerialDenseMatrix& Source);
355 
356  protected:
357 
358  void CopyMat(int* Source, int Source_LDA, int NumRows, int NumCols, int* Target, int Target_LDA);
359  void CleanupData();
360 
362  bool A_Copied_;
363  int M_;
364  int N_;
365  int LDA_;
366  int* A_;
367 
368 };
369 
370 // inlined definitions of op() and op[]
371 //=========================================================================
372 inline int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
373 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
374  if(RowIndex >= M_ || RowIndex < 0)
375  throw ReportError("Row index = " + toString(RowIndex) +
376  " Out of Range 0 - " + toString(M_-1),-1);
377  if(ColIndex >= N_ || ColIndex < 0)
378  throw ReportError("Column index = " + toString(ColIndex) +
379  " Out of Range 0 - " + toString(N_-1),-2);
380 #endif
381  return(A_[ColIndex*LDA_ + RowIndex]);
382 }
383 //=========================================================================
384 inline const int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
385 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
386  if(RowIndex >= M_ || RowIndex < 0)
387  throw ReportError("Row index = " + toString(RowIndex) +
388  " Out of Range 0 - " + toString(M_-1),-1);
389  if(ColIndex >= N_ || ColIndex < 0)
390  throw ReportError("Column index = " + toString(ColIndex) +
391  " Out of Range 0 - " + toString(N_-1),-2);
392 #endif
393  return(A_[ColIndex * LDA_ + RowIndex]);
394 }
395 //=========================================================================
396 inline int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) {
397 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
398  if(ColIndex >= N_ || ColIndex < 0)
399  throw ReportError("Column index = " + toString(ColIndex) +
400  " Out of Range 0 - " + toString(N_-1),-2);
401 #endif
402  return(A_+ ColIndex * LDA_);
403 }
404 //=========================================================================
405 inline const int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) const {
406 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
407  if(ColIndex >= N_ || ColIndex < 0)
408  throw ReportError("Column index = " + toString(ColIndex) +
409  " Out of Range 0 - " + toString(N_-1),-2);
410 #endif
411  return(A_ + ColIndex * LDA_);
412 }
413 //=========================================================================
414 
415 #endif /* EPETRA_INTSERIALDENSEMATRIX_H */
int & operator()(int RowIndex, int ColIndex)
Element access function.
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
int N() const
Returns column dimension of system.
Epetra_DataAccess CV() const
Returns the data access mode of the this matrix.
int LDA() const
Returns the leading dimension of the this matrix.
int * operator[](int ColIndex)
Column access function.
const int * A() const
Returns const pointer to the this matrix.
bool operator!=(const Epetra_IntSerialDenseMatrix &rhs) const
Inequality operator.
int * A()
Returns pointer to the this matrix.
int M() const
Returns row dimension of system.
std::string toString(const int &x) const
Epetra_Object & operator=(const Epetra_Object &src)
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:65
Epetra_IntSerialDenseMatrix: A class for constructing and using general dense integer matrices...
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
Epetra_DataAccess
bool operator==(BigUInt< n > const &a, BigUInt< n > const &b)