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 
00220     bool operator==(const Epetra_IntSerialDenseMatrix& rhs) const;
00221 
00223 
00225     bool operator!=(const Epetra_IntSerialDenseMatrix& rhs) const
00226     { return !(*this == rhs); }
00227 
00229 
00238     int& operator () (int RowIndex, int ColIndex);
00239 
00241 
00250     const int& operator () (int RowIndex, int ColIndex) const;
00251 
00253 
00263     int* operator [] (int ColIndex);
00264 
00266 
00276     const int* operator [] (int ColIndex) const;
00277 
00279 
00285   int Random();
00286     
00288   int M() const {return(M_);};
00289 
00291   int N() const {return(N_);};
00292 
00294   const int* A() const {return(A_);};
00295 
00297   int* A() {return(A_);};
00298 
00300   int LDA() const {return(LDA_);};
00301 
00303   Epetra_DataAccess CV() const {return(CV_);};
00305   
00307 
00308 
00309   virtual void Print(ostream& os) const;
00311 
00313 
00314 
00316 
00333   int MakeViewOf(const Epetra_IntSerialDenseMatrix& Source);
00335 
00336  protected:
00337 
00338   void CopyMat(int* Source, int Source_LDA, int NumRows, int NumCols, int* Target, int Target_LDA);
00339   void CleanupData();
00340 
00341   Epetra_DataAccess CV_;
00342   bool A_Copied_;
00343   int M_;
00344   int N_;
00345   int LDA_;
00346   int* A_;
00347 
00348 };
00349 
00350 // inlined definitions of op() and op[]
00351 //=========================================================================
00352 inline int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
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 const int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
00365 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00366   if(RowIndex >= M_ || RowIndex < 0) 
00367     throw ReportError("Row index = " + toString(RowIndex) + 
00368                       " Out of Range 0 - " + toString(M_-1),-1);
00369   if(ColIndex >= N_ || ColIndex < 0) 
00370     throw ReportError("Column index = " + toString(ColIndex) + 
00371                       " Out of Range 0 - " + toString(N_-1),-2);
00372 #endif
00373   return(A_[ColIndex * LDA_ + RowIndex]);
00374 }
00375 //=========================================================================
00376 inline int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) {
00377 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00378   if(ColIndex >= N_ || ColIndex < 0) 
00379     throw ReportError("Column index = " + toString(ColIndex) + 
00380                       " Out of Range 0 - " + toString(N_-1),-2);
00381 #endif
00382   return(A_+ ColIndex * LDA_);
00383 }
00384 //=========================================================================
00385 inline const int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) const {
00386 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00387   if(ColIndex >= N_ || ColIndex < 0) 
00388     throw ReportError("Column index = " + toString(ColIndex) + 
00389                       " Out of Range 0 - " + toString(N_-1),-2);
00390 #endif
00391   return(A_ + ColIndex * LDA_);
00392 }
00393 //=========================================================================
00394 
00395 #endif /* EPETRA_INTSERIALDENSEMATRIX_H */

Generated on Wed May 12 21:41:05 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7