Epetra_IntSerialDenseMatrix.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_INTSERIALDENSEMATRIX_H
00033 #define EPETRA_INTSERIALDENSEMATRIX_H
00034 
00035 #include "Epetra_Object.h" 
00036 
00038 
00104 //=========================================================================
00105 class Epetra_IntSerialDenseMatrix : public Epetra_Object {
00106 
00107   public:
00108   
00110 
00111 
00112 
00117   Epetra_IntSerialDenseMatrix();
00118   
00120 
00131   Epetra_IntSerialDenseMatrix(int NumRows, int NumCols);
00132 
00134 
00149   Epetra_IntSerialDenseMatrix(Epetra_DataAccess CV, int* A, int LDA, int NumRows, int NumCols);
00150   
00152 
00155   Epetra_IntSerialDenseMatrix(const Epetra_IntSerialDenseMatrix& Source);
00156 
00158   virtual ~Epetra_IntSerialDenseMatrix ();
00160 
00162 
00163 
00164 
00176   int Shape(int NumRows, int NumCols);
00177   
00179 
00192   int Reshape(int NumRows, int NumCols);
00194   
00196 
00197 
00199 
00202   virtual int OneNorm();
00203 
00205   virtual int InfNorm();
00206 
00208 
00214     Epetra_IntSerialDenseMatrix& operator = (const Epetra_IntSerialDenseMatrix& Source);
00215 
00217 
00226     int& operator () (int RowIndex, int ColIndex);
00227 
00229 
00238     const int& operator () (int RowIndex, int ColIndex) const;
00239 
00241 
00251     int* operator [] (int ColIndex);
00252 
00254 
00264     const int* operator [] (int ColIndex) const;
00265 
00267 
00273   int Random();
00274     
00276   int M() const {return(M_);};
00277 
00279   int N() const {return(N_);};
00280 
00282   const int* A() const {return(A_);};
00283 
00285   int* A() {return(A_);};
00286 
00288   int LDA() const {return(LDA_);};
00289 
00291   Epetra_DataAccess CV() const {return(CV_);};
00293   
00295 
00296 
00297   virtual void Print(ostream& os) const;
00299 
00301 
00302 
00304 
00321   int MakeViewOf(const Epetra_IntSerialDenseMatrix& Source);
00323 
00324  protected:
00325 
00326   void CopyMat(int* Source, int Source_LDA, int NumRows, int NumCols, int* Target, int Target_LDA);
00327   void CleanupData();
00328 
00329   Epetra_DataAccess CV_;
00330   bool A_Copied_;
00331   int M_;
00332   int N_;
00333   int LDA_;
00334   int* A_;
00335 
00336 };
00337 
00338 // inlined definitions of op() and op[]
00339 //=========================================================================
00340 inline int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
00341 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00342   if(RowIndex >= M_ || RowIndex < 0) 
00343     throw ReportError("Row index = " + toString(RowIndex) + 
00344                       " Out of Range 0 - " + toString(M_-1),-1);
00345   if(ColIndex >= N_ || ColIndex < 0) 
00346     throw ReportError("Column index = " + toString(ColIndex) + 
00347                       " Out of Range 0 - " + toString(N_-1),-2);
00348 #endif
00349   return(A_[ColIndex*LDA_ + RowIndex]);
00350 }
00351 //=========================================================================
00352 inline const int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
00353 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00354   if(RowIndex >= M_ || RowIndex < 0) 
00355     throw ReportError("Row index = " + toString(RowIndex) + 
00356                       " Out of Range 0 - " + toString(M_-1),-1);
00357   if(ColIndex >= N_ || ColIndex < 0) 
00358     throw ReportError("Column index = " + toString(ColIndex) + 
00359                       " Out of Range 0 - " + toString(N_-1),-2);
00360 #endif
00361   return(A_[ColIndex * LDA_ + RowIndex]);
00362 }
00363 //=========================================================================
00364 inline int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) {
00365 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00366   if(ColIndex >= N_ || ColIndex < 0) 
00367     throw ReportError("Column index = " + toString(ColIndex) + 
00368                       " Out of Range 0 - " + toString(N_-1),-2);
00369 #endif
00370   return(A_+ ColIndex * LDA_);
00371 }
00372 //=========================================================================
00373 inline const int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) const {
00374 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00375   if(ColIndex >= N_ || ColIndex < 0) 
00376     throw ReportError("Column index = " + toString(ColIndex) + 
00377                       " Out of Range 0 - " + toString(N_-1),-2);
00378 #endif
00379   return(A_ + ColIndex * LDA_);
00380 }
00381 //=========================================================================
00382 
00383 #endif /* EPETRA_INTSERIALDENSEMATRIX_H */

Generated on Thu Sep 18 12:37:57 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1