Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_LongLongSerialDenseMatrix.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_LONGLONGSERIALDENSEMATRIX_H
45 #define EPETRA_LONGLONGSERIALDENSEMATRIX_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_ConfigDefs.h"
56 #include "Epetra_Object.h"
57 
58 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
59 
61 
127 //=========================================================================
128 class EPETRA_LIB_DLL_EXPORT Epetra_LongLongSerialDenseMatrix : public Epetra_Object {
129 
130  public:
131 
133 
134 
141 
143 
154  Epetra_LongLongSerialDenseMatrix(int NumRows, int NumCols);
155 
157 
172  Epetra_LongLongSerialDenseMatrix(Epetra_DataAccess CV, long long* A, int LDA, int NumRows, int NumCols);
173 
175 
179 
183 
185 
186 
199  int Shape(int NumRows, int NumCols);
200 
202 
215  int Reshape(int NumRows, int NumCols);
217 
219 
220 
222 
225  virtual long long OneNorm();
226 
228  virtual long long InfNorm();
229 
231 
238 
240 
243  bool operator==(const Epetra_LongLongSerialDenseMatrix& rhs) const;
244 
246 
249  { return !(*this == rhs); }
250 
252 
261  long long& operator () (int RowIndex, int ColIndex);
262 
264 
273  const long long& operator () (int RowIndex, int ColIndex) const;
274 
276 
286  long long* operator [] (int ColIndex);
287 
289 
299  const long long* operator [] (int ColIndex) const;
300 
302 
308  int Random();
309 
311  int M() const {return(M_);};
312 
314  int N() const {return(N_);};
315 
317  const long long* A() const {return(A_);};
318 
320  long long* A() {return(A_);};
321 
323  int LDA() const {return(LDA_);};
324 
326  Epetra_DataAccess CV() const {return(CV_);};
328 
330 
331  virtual void Print(std::ostream& os) const;
334 
336 
337 
339 
356  int MakeViewOf(const Epetra_LongLongSerialDenseMatrix& Source);
358 
359  protected:
360 
361  void CopyMat(long long* Source, int Source_LDA, int NumRows, int NumCols, long long* Target, int Target_LDA);
362  void CleanupData();
363 
365  bool A_Copied_;
366  int M_;
367  int N_;
368  int LDA_;
369  long long* A_;
370 
371 };
372 
373 // inlined definitions of op() and op[]
374 //=========================================================================
375 inline long long& Epetra_LongLongSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
376 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
377  if(RowIndex >= M_ || RowIndex < 0)
378  throw ReportError("Row index = " + toString(RowIndex) +
379  " Out of Range 0 - " + toString(M_-1),-1);
380  if(ColIndex >= N_ || ColIndex < 0)
381  throw ReportError("Column index = " + toString(ColIndex) +
382  " Out of Range 0 - " + toString(N_-1),-2);
383 #endif
384  return(A_[ColIndex*LDA_ + RowIndex]);
385 }
386 //=========================================================================
387 inline const long long& Epetra_LongLongSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
388 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
389  if(RowIndex >= M_ || RowIndex < 0)
390  throw ReportError("Row index = " + toString(RowIndex) +
391  " Out of Range 0 - " + toString(M_-1),-1);
392  if(ColIndex >= N_ || ColIndex < 0)
393  throw ReportError("Column index = " + toString(ColIndex) +
394  " Out of Range 0 - " + toString(N_-1),-2);
395 #endif
396  return(A_[ColIndex * LDA_ + RowIndex]);
397 }
398 //=========================================================================
399 inline long long* Epetra_LongLongSerialDenseMatrix::operator [] (int ColIndex) {
400 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
401  if(ColIndex >= N_ || ColIndex < 0)
402  throw ReportError("Column index = " + toString(ColIndex) +
403  " Out of Range 0 - " + toString(N_-1),-2);
404 #endif
405  return(A_+ ColIndex * LDA_);
406 }
407 //=========================================================================
408 inline const long long* Epetra_LongLongSerialDenseMatrix::operator [] (int ColIndex) const {
409 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
410  if(ColIndex >= N_ || ColIndex < 0)
411  throw ReportError("Column index = " + toString(ColIndex) +
412  " Out of Range 0 - " + toString(N_-1),-2);
413 #endif
414  return(A_ + ColIndex * LDA_);
415 }
416 //=========================================================================
417 
418 #endif // EPETRA_NO_64BIT_GLOBAL_INDICES
419 
420 #endif /* EPETRA_LONGLONGSERIALDENSEMATRIX_H */
long long * A()
Returns pointer to the this matrix.
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
int N() const
Returns column dimension of system.
const long long * A() const
Returns const pointer to the this matrix.
bool operator!=(const Epetra_LongLongSerialDenseMatrix &rhs) const
Inequality operator.
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_DataAccess CV() const
Returns the data access mode of the this matrix.
long long * operator[](int ColIndex)
Column access function.
long long & operator()(int RowIndex, int ColIndex)
Element access function.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
int M() const
Returns row dimension of system.
Epetra_DataAccess
bool operator==(BigUInt< n > const &a, BigUInt< n > const &b)
int LDA() const
Returns the leading dimension of the this matrix.
Epetra_LongLongSerialDenseMatrix: A class for constructing and using general dense integer matrices...