Epetra Package Browser (Single Doxygen Collection) Development
Epetra_SerialDenseVector.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_SERIALDENSEVECTOR_H
00045 #define EPETRA_SERIALDENSEVECTOR_H
00046 
00047 #include "Epetra_Object.h" 
00048 #include "Epetra_SerialDenseMatrix.h"
00049 
00051 
00094 //=========================================================================
00095 class EPETRA_LIB_DLL_EXPORT Epetra_SerialDenseVector : public Epetra_SerialDenseMatrix{
00096 
00097   public:
00098   
00100 
00101 
00102 
00107   Epetra_SerialDenseVector();
00108   
00110 
00119   Epetra_SerialDenseVector(int Length);
00120 
00122 
00132   Epetra_SerialDenseVector(Epetra_DataAccess CV, double* Values, int Length);
00133   
00135   
00136   Epetra_SerialDenseVector(const Epetra_SerialDenseVector& Source);
00137   
00138 
00140   virtual ~Epetra_SerialDenseVector ();
00142 
00144 
00145 
00147 
00157   int Size(int Length_in) {return(Epetra_SerialDenseMatrix::Shape(Length_in, 1));};
00158   
00160 
00171   int Resize(int Length_in) {return(Epetra_SerialDenseMatrix::Reshape(Length_in, 1));};
00172 
00174 
00176 
00177 
00178 
00184     Epetra_SerialDenseVector& operator = (const Epetra_SerialDenseVector& Source);
00185 
00186     //let the compiler know we intend to overload the base-class function
00187     //operator() rather than hide it.
00188     using Epetra_SerialDenseMatrix::operator();
00189 
00191 
00197     double& operator () (int Index);
00198 
00200 
00206     const double& operator () (int Index) const;
00207 
00209 
00215     double& operator [] (int Index);
00216 
00218 
00224     const double& operator [] (int Index) const;
00225 
00227 
00229 
00230 
00231 
00237   int Random();
00238     
00240 
00245   double Dot(const Epetra_SerialDenseVector & x) const;
00246 
00248 
00251   double Norm1() const;
00252 
00254 
00258   double Norm2() const;
00259 
00261 
00264   double NormInf() const;
00265 
00267 
00269 
00270 
00271   int Length() const {return(M_);};
00272 
00274   double* Values() const {return(A_);};
00275 
00277   Epetra_DataAccess CV() const {return(CV_);};
00278 
00280 
00282 
00283 
00284   virtual void Print(std::ostream& os) const;
00286 };
00287 
00288 // inlined definitions of op() and op[]
00289 //=========================================================================
00290 inline double& Epetra_SerialDenseVector::operator() (int Index)  {
00291 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00292   if (Index >= M_ || Index < 0) 
00293     throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
00294 #endif
00295   return(A_[Index]);
00296 }
00297 //=========================================================================
00298 inline const double& Epetra_SerialDenseVector::operator() (int Index) const  {
00299 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00300   if (Index >= M_ || Index < 0) 
00301     throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
00302 #endif
00303    return(A_[Index]);
00304 }
00305 //=========================================================================
00306 inline double& Epetra_SerialDenseVector::operator [] (int Index)  {
00307 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00308   if (Index >= M_ || Index < 0) 
00309     throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
00310 #endif
00311    return(A_[Index]);
00312 }
00313 //=========================================================================
00314 inline const double& Epetra_SerialDenseVector::operator [] (int Index) const  {
00315 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00316   if (Index >= M_ || Index < 0) 
00317     throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
00318 #endif
00319    return(A_[Index]);
00320 }
00321 //=========================================================================
00322 
00323 #endif /* EPETRA_SERIALDENSEVECTOR_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines