Epetra_SerialDenseVector.cpp

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright (2001) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ************************************************************************
00028 //@HEADER
00029 
00030 #include "Epetra_SerialDenseVector.h"
00031 //=============================================================================
00032 Epetra_SerialDenseVector::Epetra_SerialDenseVector()
00033   : Epetra_SerialDenseMatrix()
00034 {
00035   SetLabel("Epetra::SerialDenseVector");
00036 }
00037 
00038 //=============================================================================
00039 Epetra_SerialDenseVector::Epetra_SerialDenseVector(int Length)
00040   : Epetra_SerialDenseMatrix(Length, 1)
00041 {
00042   SetLabel("Epetra::SerialDenseVector");
00043 }
00044 
00045 //=============================================================================
00046 Epetra_SerialDenseVector::Epetra_SerialDenseVector(Epetra_DataAccess CV, double *Values, int Length)
00047   : Epetra_SerialDenseMatrix(CV, Values, Length, Length, 1)
00048 {
00049   SetLabel("Epetra::SerialDenseVector");  
00050 }
00051 
00052 //=============================================================================
00053 Epetra_SerialDenseVector::Epetra_SerialDenseVector(const Epetra_SerialDenseVector& Source)
00054   : Epetra_SerialDenseMatrix(Source)
00055 {}
00056 
00057 //=============================================================================
00058 Epetra_SerialDenseVector::~Epetra_SerialDenseVector()
00059 {}
00060 
00061 //=========================================================================
00062 Epetra_SerialDenseVector& Epetra_SerialDenseVector::operator = (const Epetra_SerialDenseVector& Source) {
00063   Epetra_SerialDenseMatrix::operator=(Source); // call this->Epetra_SerialDenseMatrix::operator =
00064   return(*this);
00065 }
00066 
00067 //=========================================================================
00068 int Epetra_SerialDenseVector::Random() {
00069   int errorcode = Epetra_SerialDenseMatrix::Random();
00070   return(errorcode);
00071 }
00072 
00073 //=========================================================================
00074 double  Epetra_SerialDenseVector::Dot(const Epetra_SerialDenseVector & x) const {
00075   
00076 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00077   if (Length()!=x.Length()) 
00078     throw ReportError("Length of this object = " + 
00079           toString(Length()) + " is not equal to length of x = "  + toString(x.Length()), -1);
00080 #endif
00081 
00082   // dot-product of this and x.
00083     
00084   double result = DOT(Length(), Values(), x.Values());
00085   
00086   UpdateFlops(2*Length());
00087 
00088   return(result);
00089 }
00090 
00091 //=========================================================================
00092 double  Epetra_SerialDenseVector::Norm1() const {
00093   
00094   // 1-norm of vector
00095     
00096   double result = ASUM(Length(), Values());
00097   
00098   UpdateFlops(2*Length());
00099 
00100   return(result);
00101 }
00102 
00103 //=========================================================================
00104 double  Epetra_SerialDenseVector::Norm2() const {
00105   
00106   // 2-norm of vector
00107     
00108   double result = NRM2(Length(), Values());
00109   
00110   UpdateFlops(2*Length());
00111 
00112   return(result);
00113 }
00114 //=========================================================================
00115 double  Epetra_SerialDenseVector::NormInf() const {
00116   
00117   // Inf-norm of vector
00118   double result = 0.0;
00119   int j = IAMAX(Length(), Values()); // Location of max (-1) if length zero
00120 
00121   if (j>-1) result = std::abs( (*this)[j]);
00122   
00123   // UpdateFlops(2*Length()); // Technically there are no FLOPS
00124 
00125   return(result);
00126 }
00127 //=========================================================================
00128 void Epetra_SerialDenseVector::Print(ostream& os) const {
00129   if(CV_ == Copy)
00130     os << "Data access mode: Copy" << endl;
00131   else
00132     os << "Data access mode: View" << endl;
00133   if(A_Copied_)
00134     os << "A_Copied: yes" << endl;
00135   else
00136     os << "A_Copied: no" << endl;
00137   os << "Length(M): " << M_ << endl;
00138   if(M_ == 0)
00139     os << "(vector is empty, no values to display)";
00140   else
00141     for(int i = 0; i < M_; i++)
00142       os << (*this)(i) << " ";
00143   os << endl;
00144 }

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