Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_Vector.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_VECTOR_H
45 #define EPETRA_VECTOR_H
46 
47 #include "Epetra_ConfigDefs.h"
48 #include "Epetra_MultiVector.h"
49 class Epetra_Map;
50 
52 
141 //=========================================================================
142 class EPETRA_LIB_DLL_EXPORT Epetra_Vector : public Epetra_MultiVector {
143 
144  public:
145 
147 
148 
165  Epetra_Vector(const Epetra_BlockMap& Map, bool zeroOut = true);
166 
168 
169  Epetra_Vector(const Epetra_Vector& Source);
170 
172 
184  Epetra_Vector(Epetra_DataAccess CV, const Epetra_BlockMap& Map, double *V);
185 
187 
201  Epetra_Vector(Epetra_DataAccess CV, const Epetra_MultiVector& Source, int Index);
202 
204  virtual ~Epetra_Vector ();
206 
208 
209 
211 
224 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
225  int ReplaceGlobalValues(int NumEntries, const double * Values, const int * Indices);
226 #endif
227 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
228  int ReplaceGlobalValues(int NumEntries, const double * Values, const long long * Indices);
229 #endif
230 
232 
245  int ReplaceMyValues(int NumEntries, const double * Values, const int * Indices);
246 
248 
261  int SumIntoGlobalValues(int NumEntries, const double * Values, const int * Indices);
262 
264 
277  int SumIntoMyValues(int NumEntries, const double * Values, const int * Indices);
278 
279  // Blockmap Versions
280 
282 
300  int ReplaceGlobalValues(int NumEntries, int BlockOffset, const double * Values, const int * Indices);
301 
303 
321  int ReplaceMyValues(int NumEntries, int BlockOffset, const double * Values, const int * Indices);
322 
324 
342  int SumIntoGlobalValues(int NumEntries, int BlockOffset, const double * Values, const int * Indices);
343 
345 
363  int SumIntoMyValues(int NumEntries, int BlockOffset, const double * Values, const int * Indices);
365 
367 
368 
369  //Let the compiler know we intend to overload the base-class ExtractCopy
370  //function, rather than hide it.
372 
374 
380  int ExtractCopy(double *V) const;
381 
382  //Let the compiler know we intend to overload the base-class ExtractView
383  //function, rather than hide it.
385 
387 
393  int ExtractView(double **V) const;
395 
397 
398 
400 
403  double& operator [] (int index)
404  {
405 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
407  !( 0 <= index && index < this->MyLength() ), -99,
408  "Epetra_Vector::operator[](int): "
409  "The index = " << index << " does not fall in the range"
410  "[0,"<<this->MyLength()<<")"
411  );
412 #endif
413  return Values_[index];
414  }
416 
419  const double& operator [] (int index) const
420  {
421 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
423  !( 0 <= index && index < this->MyLength() ), -99,
424  "Epetra_Vector::operator[](int) const: "
425  "The index = " << index << " does not fall in the range"
426  "[0,"<<this->MyLength()<<")"
427  );
428 #endif
429  return Values_[index];
430  }
432 
434 
435 
436  //Let the compiler know we intend to overload the base-class ResetView
437  //function, rather than hide it.
439 
441 
460  int ResetView(double * Values_in) {EPETRA_CHK_ERR(Epetra_MultiVector::ResetView(&Values_in)); return(0);};
462  private:
463 
464  int ChangeValues(int NumEntries, int BlockOffset, const double * Values, const int * Indices, bool IndicesGlobal, bool SumInto);
465 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
466  int ChangeValues(int NumEntries, int BlockOffset, const double * Values, const long long * Indices, bool IndicesGlobal, bool SumInto);
467 #endif
468 
469  template<typename int_type>
470  int TChangeValues(int NumEntries, int BlockOffset, const double * Values, const int_type * Indices, bool IndicesGlobal, bool SumInto);
471 };
472 
473 #endif /* EPETRA_VECTOR_H */
474 
475 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
476 #ifdef __GNUC__
477 #warning "The Epetra package is deprecated"
478 #endif
479 #endif
480 
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
int ResetView(double *Values_in)
Reset the view of an existing vector to point to new user data.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
#define EPETRA_CHK_ERR(a)
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int ExtractCopy(double *A, int MyLDA) const
Put multi-vector values into user-provided two-dimensional array.
int ResetView(double **ArrayOfPointers)
Reset the view of an existing multivector to point to new user data.
int ExtractView(double **A, int *MyLDA) const
Set user-provided addresses of A and MyLDA.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
#define EPETRA_TEST_FOR_EXCEPTION(throw_exception_test, errCode, msg)
Macro for testing for and throwing and int exception for objects derived from Epetra_Object.
double *& operator[](int i)
Vector access function.
Epetra_DataAccess