Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
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#include "Epetra_Object.h"
48
50
116//=========================================================================
117class EPETRA_LIB_DLL_EXPORT Epetra_IntSerialDenseMatrix : public Epetra_Object {
118
119 public:
120
122
123
130
132
143 Epetra_IntSerialDenseMatrix(int NumRows, int NumCols);
144
146
161 Epetra_IntSerialDenseMatrix(Epetra_DataAccess CV, int* A, int LDA, int NumRows, int NumCols);
162
164
168
172
174
175
188 int Shape(int NumRows, int NumCols);
189
191
204 int Reshape(int NumRows, int NumCols);
206
208
209
211
214 virtual int OneNorm();
215
217 virtual int InfNorm();
218
220
227
229
232 bool operator==(const Epetra_IntSerialDenseMatrix& rhs) const;
233
235
238 { return !(*this == rhs); }
239
241
250 int& operator () (int RowIndex, int ColIndex);
251
253
262 const int& operator () (int RowIndex, int ColIndex) const;
263
265
275 int* operator [] (int ColIndex);
276
278
288 const int* operator [] (int ColIndex) const;
289
291
297 int Random();
298
300 int M() const {return(M_);};
301
303 int N() const {return(N_);};
304
306 const int* A() const {return(A_);};
307
309 int* A() {return(A_);};
310
312 int LDA() const {return(LDA_);};
313
315 Epetra_DataAccess CV() const {return(CV_);};
317
319
320
321 virtual void Print(std::ostream& os) const;
323
325
326
328
345 int MakeViewOf(const Epetra_IntSerialDenseMatrix& Source);
347
348 protected:
349
350 void CopyMat(int* Source, int Source_LDA, int NumRows, int NumCols, int* Target, int Target_LDA);
351 void CleanupData();
352
355 int M_;
356 int N_;
357 int LDA_;
358 int* A_;
359
360};
361
362// inlined definitions of op() and op[]
363//=========================================================================
364inline int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
365#ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
366 if(RowIndex >= M_ || RowIndex < 0)
367 throw ReportError("Row index = " + toString(RowIndex) +
368 " Out of Range 0 - " + toString(M_-1),-1);
369 if(ColIndex >= N_ || ColIndex < 0)
370 throw ReportError("Column index = " + toString(ColIndex) +
371 " Out of Range 0 - " + toString(N_-1),-2);
372#endif
373 return(A_[ColIndex*LDA_ + RowIndex]);
374}
375//=========================================================================
376inline const int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
377#ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
378 if(RowIndex >= M_ || RowIndex < 0)
379 throw ReportError("Row index = " + toString(RowIndex) +
380 " Out of Range 0 - " + toString(M_-1),-1);
381 if(ColIndex >= N_ || ColIndex < 0)
382 throw ReportError("Column index = " + toString(ColIndex) +
383 " Out of Range 0 - " + toString(N_-1),-2);
384#endif
385 return(A_[ColIndex * LDA_ + RowIndex]);
386}
387//=========================================================================
389#ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
390 if(ColIndex >= N_ || ColIndex < 0)
391 throw ReportError("Column index = " + toString(ColIndex) +
392 " Out of Range 0 - " + toString(N_-1),-2);
393#endif
394 return(A_+ ColIndex * LDA_);
395}
396//=========================================================================
397inline const int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) const {
398#ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
399 if(ColIndex >= N_ || ColIndex < 0)
400 throw ReportError("Column index = " + toString(ColIndex) +
401 " Out of Range 0 - " + toString(N_-1),-2);
402#endif
403 return(A_ + ColIndex * LDA_);
404}
405//=========================================================================
406
407#endif /* EPETRA_INTSERIALDENSEMATRIX_H */
Epetra_DataAccess
Epetra_IntSerialDenseMatrix: A class for constructing and using general dense integer matrices.
int LDA() const
Returns the leading dimension of the this matrix.
int M() const
Returns row dimension of system.
int * A()
Returns pointer to the this matrix.
bool operator!=(const Epetra_IntSerialDenseMatrix &rhs) const
Inequality operator.
int * operator[](int ColIndex)
Column access function.
int N() const
Returns column dimension of system.
Epetra_DataAccess CV() const
Returns the data access mode of the this matrix.
const int * A() const
Returns const pointer to the this matrix.
int & operator()(int RowIndex, int ColIndex)
Element access function.
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
std::string toString(const int &x) const
Epetra_Object & operator=(const Epetra_Object &src)