Epetra Package Browser (Single Doxygen Collection) Development
Epetra_LongLongSerialDenseMatrix.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_LONGLONGSERIALDENSEMATRIX_H
00045 #define EPETRA_LONGLONGSERIALDENSEMATRIX_H
00046 
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_Object.h" 
00049 
00050 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
00051 
00053 
00119 //=========================================================================
00120 class EPETRA_LIB_DLL_EXPORT Epetra_LongLongSerialDenseMatrix : public Epetra_Object {
00121 
00122   public:
00123   
00125 
00126 
00127 
00132   Epetra_LongLongSerialDenseMatrix();
00133   
00135 
00146   Epetra_LongLongSerialDenseMatrix(int NumRows, int NumCols);
00147 
00149 
00164   Epetra_LongLongSerialDenseMatrix(Epetra_DataAccess CV, long long* A, int LDA, int NumRows, int NumCols);
00165   
00167 
00170   Epetra_LongLongSerialDenseMatrix(const Epetra_LongLongSerialDenseMatrix& Source);
00171 
00173   virtual ~Epetra_LongLongSerialDenseMatrix ();
00175 
00177 
00178 
00179 
00191   int Shape(int NumRows, int NumCols);
00192   
00194 
00207   int Reshape(int NumRows, int NumCols);
00209   
00211 
00212 
00214 
00217   virtual long long OneNorm();
00218 
00220   virtual long long InfNorm();
00221 
00223 
00229     Epetra_LongLongSerialDenseMatrix& operator = (const Epetra_LongLongSerialDenseMatrix& Source);
00230 
00232 
00235     bool operator==(const Epetra_LongLongSerialDenseMatrix& rhs) const;
00236 
00238 
00240     bool operator!=(const Epetra_LongLongSerialDenseMatrix& rhs) const
00241     { return !(*this == rhs); }
00242 
00244 
00253     long long& operator () (int RowIndex, int ColIndex);
00254 
00256 
00265     const long long& operator () (int RowIndex, int ColIndex) const;
00266 
00268 
00278     long long* operator [] (int ColIndex);
00279 
00281 
00291     const long long* operator [] (int ColIndex) const;
00292 
00294 
00300   int Random();
00301     
00303   int M() const {return(M_);};
00304 
00306   int N() const {return(N_);};
00307 
00309   const long long* A() const {return(A_);};
00310 
00312   long long* A() {return(A_);};
00313 
00315   int LDA() const {return(LDA_);};
00316 
00318   Epetra_DataAccess CV() const {return(CV_);};
00320   
00322 
00323 
00324   virtual void Print(std::ostream& os) const;
00326 
00328 
00329 
00331 
00348   int MakeViewOf(const Epetra_LongLongSerialDenseMatrix& Source);
00350 
00351  protected:
00352 
00353   void CopyMat(long long* Source, int Source_LDA, int NumRows, int NumCols, long long* Target, int Target_LDA);
00354   void CleanupData();
00355 
00356   Epetra_DataAccess CV_;
00357   bool A_Copied_;
00358   int M_;
00359   int N_;
00360   int LDA_;
00361   long long* A_;
00362 
00363 };
00364 
00365 // inlined definitions of op() and op[]
00366 //=========================================================================
00367 inline long long& Epetra_LongLongSerialDenseMatrix::operator () (int RowIndex, int ColIndex) {
00368 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00369   if(RowIndex >= M_ || RowIndex < 0) 
00370     throw ReportError("Row index = " + toString(RowIndex) + 
00371                       " Out of Range 0 - " + toString(M_-1),-1);
00372   if(ColIndex >= N_ || ColIndex < 0) 
00373     throw ReportError("Column index = " + toString(ColIndex) + 
00374                       " Out of Range 0 - " + toString(N_-1),-2);
00375 #endif
00376   return(A_[ColIndex*LDA_ + RowIndex]);
00377 }
00378 //=========================================================================
00379 inline const long long& Epetra_LongLongSerialDenseMatrix::operator () (int RowIndex, int ColIndex) const {
00380 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00381   if(RowIndex >= M_ || RowIndex < 0) 
00382     throw ReportError("Row index = " + toString(RowIndex) + 
00383                       " Out of Range 0 - " + toString(M_-1),-1);
00384   if(ColIndex >= N_ || ColIndex < 0) 
00385     throw ReportError("Column index = " + toString(ColIndex) + 
00386                       " Out of Range 0 - " + toString(N_-1),-2);
00387 #endif
00388   return(A_[ColIndex * LDA_ + RowIndex]);
00389 }
00390 //=========================================================================
00391 inline long long* Epetra_LongLongSerialDenseMatrix::operator [] (int ColIndex) {
00392 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00393   if(ColIndex >= N_ || ColIndex < 0) 
00394     throw ReportError("Column index = " + toString(ColIndex) + 
00395                       " Out of Range 0 - " + toString(N_-1),-2);
00396 #endif
00397   return(A_+ ColIndex * LDA_);
00398 }
00399 //=========================================================================
00400 inline const long long* Epetra_LongLongSerialDenseMatrix::operator [] (int ColIndex) const {
00401 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00402   if(ColIndex >= N_ || ColIndex < 0) 
00403     throw ReportError("Column index = " + toString(ColIndex) + 
00404                       " Out of Range 0 - " + toString(N_-1),-2);
00405 #endif
00406   return(A_ + ColIndex * LDA_);
00407 }
00408 //=========================================================================
00409 
00410 #endif // EPETRA_NO_64BIT_GLOBAL_INDICES
00411 
00412 #endif /* EPETRA_LONGLONGSERIALDENSEMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines