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 #include "Epetra_Object.h"
49 
51 
94 //=========================================================================
95 class EPETRA_LIB_DLL_EXPORT Epetra_SerialDenseVector : public Epetra_SerialDenseMatrix{
96 
97  public:
98 
100 
101 
108 
110 
119  Epetra_SerialDenseVector(int Length);
120 
122 
132  Epetra_SerialDenseVector(Epetra_DataAccess CV, double* Values, int Length);
133 
135 
137 
138 
140  virtual ~Epetra_SerialDenseVector ();
142 
144 
145 
147 
157  int Size(int Length_in) {return(Epetra_SerialDenseMatrix::Shape(Length_in, 1));};
158 
160 
171  int Resize(int Length_in) {return(Epetra_SerialDenseMatrix::Reshape(Length_in, 1));};
172 
174 
176 
177 
185 
186  //let the compiler know we intend to overload the base-class function
187  //operator() rather than hide it.
188  using Epetra_SerialDenseMatrix::operator();
189 
191 
197  double& operator () (int Index);
198 
200 
206  const double& operator () (int Index) const;
207 
209 
215  double& operator [] (int Index);
216 
218 
224  const double& operator [] (int Index) const;
225 
227 
229 
230 
237  int Random();
238 
240 
245  double Dot(const Epetra_SerialDenseVector & x) const;
246 
248 
251  double Norm1() const;
252 
254 
258  double Norm2() const;
259 
261 
264  double NormInf() const;
265 
267 
269 
270  int Length() const {return(M_);};
272 
274  double* Values() const {return(A_);};
275 
277  Epetra_DataAccess CV() const {return(CV_);};
278 
280 
282 
283  virtual void Print(std::ostream& os) const;
286 };
287 
288 // inlined definitions of op() and op[]
289 //=========================================================================
290 inline double& Epetra_SerialDenseVector::operator() (int Index) {
291 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
292  if (Index >= M_ || Index < 0)
293  throw ReportError("Index = " +toString(Index) + " Out of Range 0 - " + toString(M_-1), -1);
294 #endif
295  return(A_[Index]);
296 }
297 //=========================================================================
298 inline const double& Epetra_SerialDenseVector::operator() (int Index) const {
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 double& Epetra_SerialDenseVector::operator [] (int Index) {
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 const double& Epetra_SerialDenseVector::operator [] (int Index) const {
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 
323 #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.