Epetra Package Browser (Single Doxygen Collection) Development
Epetra_SerialDenseVector.cpp
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 #include "Epetra_SerialDenseVector.h"
00044 //=============================================================================
00045 Epetra_SerialDenseVector::Epetra_SerialDenseVector()
00046   : Epetra_SerialDenseMatrix()
00047 {
00048   SetLabel("Epetra::SerialDenseVector");
00049 }
00050 
00051 //=============================================================================
00052 Epetra_SerialDenseVector::Epetra_SerialDenseVector(int length)
00053   : Epetra_SerialDenseMatrix(length, 1)
00054 {
00055   SetLabel("Epetra::SerialDenseVector");
00056 }
00057 
00058 //=============================================================================
00059 Epetra_SerialDenseVector::Epetra_SerialDenseVector(Epetra_DataAccess CV_in, double *values, int length)
00060   : Epetra_SerialDenseMatrix(CV_in, values, length, length, 1)
00061 {
00062   SetLabel("Epetra::SerialDenseVector");  
00063 }
00064 
00065 //=============================================================================
00066 Epetra_SerialDenseVector::Epetra_SerialDenseVector(const Epetra_SerialDenseVector& Source)
00067   : Epetra_SerialDenseMatrix(Source)
00068 {}
00069 
00070 //=============================================================================
00071 Epetra_SerialDenseVector::~Epetra_SerialDenseVector()
00072 {}
00073 
00074 //=========================================================================
00075 Epetra_SerialDenseVector& Epetra_SerialDenseVector::operator = (const Epetra_SerialDenseVector& Source) {
00076   Epetra_SerialDenseMatrix::operator=(Source); // call this->Epetra_SerialDenseMatrix::operator =
00077   return(*this);
00078 }
00079 
00080 //=========================================================================
00081 int Epetra_SerialDenseVector::Random() {
00082   int errorcode = Epetra_SerialDenseMatrix::Random();
00083   return(errorcode);
00084 }
00085 
00086 //=========================================================================
00087 double  Epetra_SerialDenseVector::Dot(const Epetra_SerialDenseVector & x) const {
00088   
00089 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00090   if (Length()!=x.Length()) 
00091     throw ReportError("Length of this object = " + 
00092           toString(Length()) + " is not equal to length of x = "  + toString(x.Length()), -1);
00093 #endif
00094 
00095   // dot-product of this and x.
00096     
00097   double result = DOT(Length(), Values(), x.Values());
00098   
00099   UpdateFlops(2*Length());
00100 
00101   return(result);
00102 }
00103 
00104 //=========================================================================
00105 double  Epetra_SerialDenseVector::Norm1() const {
00106   
00107   // 1-norm of vector
00108     
00109   double result = ASUM(Length(), Values());
00110   
00111   UpdateFlops(2*Length());
00112 
00113   return(result);
00114 }
00115 
00116 //=========================================================================
00117 double  Epetra_SerialDenseVector::Norm2() const {
00118   
00119   // 2-norm of vector
00120     
00121   double result = NRM2(Length(), Values());
00122   
00123   UpdateFlops(2*Length());
00124 
00125   return(result);
00126 }
00127 //=========================================================================
00128 double  Epetra_SerialDenseVector::NormInf() const {
00129   
00130   // Inf-norm of vector
00131   double result = 0.0;
00132   int j = IAMAX(Length(), Values()); // Location of max (-1) if length zero
00133 
00134   if (j>-1) result = std::abs( (*this)[j]);
00135   
00136   // UpdateFlops(2*Length()); // Technically there are no FLOPS
00137 
00138   return(result);
00139 }
00140 //=========================================================================
00141 void Epetra_SerialDenseVector::Print(ostream& os) const {
00142   if(CV_ == Copy)
00143     os << "Data access mode: Copy" << endl;
00144   else
00145     os << "Data access mode: View" << endl;
00146   if(A_Copied_)
00147     os << "A_Copied: yes" << endl;
00148   else
00149     os << "A_Copied: no" << endl;
00150   os << "Length(M): " << M_ << endl;
00151   if(M_ == 0)
00152     os << "(vector is empty, no values to display)";
00153   else
00154     for(int i = 0; i < M_; i++)
00155       os << (*this)(i) << " ";
00156   os << endl;
00157 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines