Epetra Package Browser (Single Doxygen Collection) Development
Epetra_IntSerialDenseMatrix.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2011 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_INTSERIALDENSEMATRIX_H
00045 #define EPETRA_INTSERIALDENSEMATRIX_H
00046 
00047 #include "Epetra_Object.h" 
00048 
00050 
00116 //=========================================================================
00117 class EPETRA_LIB_DLL_EXPORT Epetra_IntSerialDenseMatrix : public Epetra_Object {
00118 
00119   public:
00120   
00122 
00123 
00124 
00129   Epetra_IntSerialDenseMatrix();
00130   
00132 
00143   Epetra_IntSerialDenseMatrix(int NumRows, int NumCols);
00144 
00146 
00161   Epetra_IntSerialDenseMatrix(Epetra_DataAccess CV, int* A, int LDA, int NumRows, int NumCols);
00162   
00164 
00167   Epetra_IntSerialDenseMatrix(const Epetra_IntSerialDenseMatrix& Source);
00168 
00170   virtual ~Epetra_IntSerialDenseMatrix ();
00172 
00174 
00175 
00176 
00188   int Shape(int NumRows, int NumCols);
00189   
00191 
00204   int Reshape(int NumRows, int NumCols);
00206   
00208 
00209 
00211 
00214   virtual int OneNorm();
00215 
00217   virtual int InfNorm();
00218 
00220 
00226     Epetra_IntSerialDenseMatrix& operator = (const Epetra_IntSerialDenseMatrix& Source);
00227 
00229 
00232     bool operator==(const Epetra_IntSerialDenseMatrix& rhs) const;
00233 
00235 
00237     bool operator!=(const Epetra_IntSerialDenseMatrix& rhs) const
00238     { return !(*this == rhs); }
00239 
00241 
00250     int& operator () (int RowIndex, int ColIndex);
00251 
00253 
00262     const int& operator () (int RowIndex, int ColIndex) const;
00263 
00265 
00275     int* operator [] (int ColIndex);
00276 
00278 
00288     const int* operator [] (int ColIndex) const;
00289 
00291 
00297   int Random();
00298     
00300   int M() const {return(M_);};
00301 
00303   int N() const {return(N_);};
00304 
00306   const int* A() const {return(A_);};
00307 
00309   int* A() {return(A_);};
00310 
00312   int LDA() const {return(LDA_);};
00313 
00315   Epetra_DataAccess CV() const {return(CV_);};
00317   
00319 
00320 
00321   virtual void Print(ostream& os) const;
00323 
00325 
00326 
00328 
00345   int MakeViewOf(const Epetra_IntSerialDenseMatrix& Source);
00347 
00348  protected:
00349 
00350   void CopyMat(int* Source, int Source_LDA, int NumRows, int NumCols, int* Target, int Target_LDA);
00351   void CleanupData();
00352 
00353   Epetra_DataAccess CV_;
00354   bool A_Copied_;
00355   int M_;
00356   int N_;
00357   int LDA_;
00358   int* A_;
00359 
00360 };
00361 
00362 // inlined definitions of op() and op[]
00363 //=========================================================================
00364 inline int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
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 const int& Epetra_IntSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
00377 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00378   if(RowIndex >= M_ || RowIndex < 0) 
00379     throw ReportError("Row index = " + toString(RowIndex) + 
00380                       " Out of Range 0 - " + toString(M_-1),-1);
00381   if(ColIndex >= N_ || ColIndex < 0) 
00382     throw ReportError("Column index = " + toString(ColIndex) + 
00383                       " Out of Range 0 - " + toString(N_-1),-2);
00384 #endif
00385   return(A_[ColIndex * LDA_ + RowIndex]);
00386 }
00387 //=========================================================================
00388 inline int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) {
00389 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00390   if(ColIndex >= N_ || ColIndex < 0) 
00391     throw ReportError("Column index = " + toString(ColIndex) + 
00392                       " Out of Range 0 - " + toString(N_-1),-2);
00393 #endif
00394   return(A_+ ColIndex * LDA_);
00395 }
00396 //=========================================================================
00397 inline const int* Epetra_IntSerialDenseMatrix::operator [] (int ColIndex) const {
00398 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00399   if(ColIndex >= N_ || ColIndex < 0) 
00400     throw ReportError("Column index = " + toString(ColIndex) + 
00401                       " Out of Range 0 - " + toString(N_-1),-2);
00402 #endif
00403   return(A_ + ColIndex * LDA_);
00404 }
00405 //=========================================================================
00406 
00407 #endif /* EPETRA_INTSERIALDENSEMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines