Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_SerialDenseVector.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_SERIALDENSEVECTOR_H
45 #define EPETRA_SERIALDENSEVECTOR_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 #include "Epetra_Object.h"
57 
59 
102 //=========================================================================
103 class EPETRA_LIB_DLL_EXPORT Epetra_SerialDenseVector : public Epetra_SerialDenseMatrix{
104 
105  public:
106 
108 
109 
116 
118 
127  Epetra_SerialDenseVector(int Length);
128 
130 
140  Epetra_SerialDenseVector(Epetra_DataAccess CV, double* Values, int Length);
141 
143 
145 
146 
148  virtual ~Epetra_SerialDenseVector ();
150 
152 
153 
155 
165  int Size(int Length_in) {return(Epetra_SerialDenseMatrix::Shape(Length_in, 1));};
166 
168 
179  int Resize(int Length_in) {return(Epetra_SerialDenseMatrix::Reshape(Length_in, 1));};
180 
182 
184 
185 
193 
194  //let the compiler know we intend to overload the base-class function
195  //operator() rather than hide it.
196  using Epetra_SerialDenseMatrix::operator();
197 
199 
205  double& operator () (int Index);
206 
208 
214  const double& operator () (int Index) const;
215 
217 
223  double& operator [] (int Index);
224 
226 
232  const double& operator [] (int Index) const;
233 
235 
237 
238 
245  int Random();
246 
248 
253  double Dot(const Epetra_SerialDenseVector & x) const;
254 
256 
259  double Norm1() const;
260 
262 
266  double Norm2() const;
267 
269 
272  double NormInf() const;
273 
275 
277 
278  int Length() const {return(M_);};
280 
282  double* Values() const {return(A_);};
283 
285  Epetra_DataAccess CV() const {return(CV_);};
286 
288 
290 
291  virtual void Print(std::ostream& os) const;
294 };
295 
296 // inlined definitions of op() and op[]
297 //=========================================================================
298 inline double& Epetra_SerialDenseVector::operator() (int Index) {
299 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
300  if (Index >= M_ || Index < 0)
301  throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
302 #endif
303  return(A_[Index]);
304 }
305 //=========================================================================
306 inline const double& Epetra_SerialDenseVector::operator() (int Index) const {
307 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
308  if (Index >= M_ || Index < 0)
309  throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
310 #endif
311  return(A_[Index]);
312 }
313 //=========================================================================
314 inline double& Epetra_SerialDenseVector::operator [] (int Index) {
315 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
316  if (Index >= M_ || Index < 0)
317  throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
318 #endif
319  return(A_[Index]);
320 }
321 //=========================================================================
322 inline const double& Epetra_SerialDenseVector::operator [] (int Index) const {
323 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
324  if (Index >= M_ || Index < 0)
325  throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
326 #endif
327  return(A_[Index]);
328 }
329 //=========================================================================
330 
331 #endif /* EPETRA_SERIALDENSEVECTOR_H */
virtual double NormInf() const
Computes the Infinity-Norm of the this matrix.
double & operator()(int Index)
Element access function.
int Size(int Length_in)
Set length of a Epetra_SerialDenseVector object; init values to zero.
int Random()
Set matrix values to random numbers.
double * operator[](int ColIndex)
Column access function.
double & operator[](int Index)
Element access function.
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
int Resize(int Length_in)
Resize a Epetra_SerialDenseVector object.
Epetra_SerialDenseVector: A class for constructing and using dense vectors.
std::string toString(const int &x) const
double & operator()(int RowIndex, int ColIndex)
Element access function.
Epetra_SerialDenseMatrix & operator=(const Epetra_SerialDenseMatrix &Source)
Value copy from one matrix to another.
int Reshape(int NumRows, int NumCols)
Reshape a Epetra_SerialDenseMatrix object.
virtual void Print(std::ostream &os) const
Print service methods; defines behavior of ostream &lt;&lt; operator.
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
double * Values() const
Returns pointer to the values in vector.
Epetra_DataAccess
int Shape(int NumRows, int NumCols)
Set dimensions of a Epetra_SerialDenseMatrix object; init values to zero.
Epetra_DataAccess CV() const
Returns the data access mode of the this vector.