ROL
ROL_MultiVector.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
51 #ifndef ROL_MULTIVECTOR_HPP
52 #define ROL_MULTIVECTOR_HPP
53 
54 #include <vector>
55 
56 #include "ROL_Vector.hpp"
57 #include "Teuchos_ArrayRCP.hpp"
58 #include "Teuchos_SerialDenseMatrix.hpp"
59 
60 namespace ROL {
61 
62 template<class Real>
63 class MultiVector {
64 
65  typedef Vector<Real> V; // Single vector
66  typedef Teuchos::RCP<V> PV; // Pointer to a vector
67  typedef Teuchos::ArrayRCP<PV> APV; // Array of pointers to vectors
68  typedef MultiVector<Real> MV; // Instance of the base class
69  typedef Teuchos::RCP<MV> PMV; // Pointer to an instance of the class
70 
71  public:
72 
73  virtual ~MultiVector() {}
74 
79  virtual PMV clone() const = 0;
80 
85  virtual PMV clone( const int numvecs ) const = 0;
86 
92  virtual PMV deepCopy() const = 0;
93 
94 
100  virtual PMV deepCopy(const std::vector<int> &index) const = 0;
101 
102 
108  virtual PMV shallowCopy(const std::vector<int> &index) = 0;
109 
110 
116  virtual const PMV shallowCopyConst(const std::vector<int> &index) const = 0;
117 
118 
123  virtual ptrdiff_t getLength() const = 0;
124 
125 
130  virtual int getNumberOfVectors() const = 0;
131 
139  virtual void gemm(const Real alpha,
140  const MV& A,
141  const Teuchos::SerialDenseMatrix<int,Real> &B,
142  const Real beta) = 0;
143 
149  virtual void axpy(const Real alpha, const MV& x) = 0;
150 
151 
156  virtual void scale(const Real alpha) = 0;
157 
158 
163  virtual void scale(const std::vector<Real> &alpha) = 0;
164 
165 
169  virtual void set(const MV &A) = 0;
170 
171 
176  virtual void set(const MV &A, const std::vector<int> &index) = 0;
177 
178 
185  virtual void innerProducts(const Real alpha,
186  const MV &A,
187  Teuchos::SerialDenseMatrix<int,Real> &B) const = 0;
188 
189 
195  virtual void dots(const MV &A,
196  std::vector<Real> &b) const = 0;
197 
198 
203  virtual void norms(std::vector<Real> &normvec) const = 0;
204 
205 
208  virtual void zero() = 0;
209 
210 
215  virtual PV getVector(int i) const = 0;
216 
217 };
218 }
219 
220 #endif
virtual PMV shallowCopy(const std::vector< int > &index)=0
Make a shallow copy of this MultiVector.
virtual void scale(const Real alpha)=0
Scale the MultiVector by a single scalar alpha .
virtual void norms(std::vector< Real > &normvec) const =0
Compute the norm of each vector in the MultiVector.
virtual ptrdiff_t getLength() const =0
Get the number of elements of a vector in the MultiVector.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:74
MultiVector< Real > MV
virtual void innerProducts(const Real alpha, const MV &A, Teuchos::SerialDenseMatrix< int, Real > &B) const =0
Compute .
Teuchos::RCP< MV > PMV
virtual void dots(const MV &A, std::vector< Real > &b) const =0
Compute dot products of pairs of vectors.
Vector< Real > V
Teuchos::RCP< V > PV
virtual void axpy(const Real alpha, const MV &x)=0
Perform the axpy operation columnwise on the MultiVector where is this MultiVector.
virtual void zero()=0
Zero each of the vectors in the MultiVector.
Teuchos::ArrayRCP< PV > APV
virtual PMV clone() const =0
Make a new MultiVector of the same dimensions.
virtual PV getVector(int i) const =0
Return a pointer to the ith vector.
virtual int getNumberOfVectors() const =0
Get the number of vectors in the MultiVector.
Provides a container and operations on multiple ROL vectors for use with other Trilinos packages whic...
virtual PMV deepCopy() const =0
Make a deep copy of this MultiVector.
virtual const PMV shallowCopyConst(const std::vector< int > &index) const =0
Make a shallow copy of this MultiVector.
virtual void gemm(const Real alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, Real > &B, const Real beta)=0
Generic BLAS level 3 matrix multiplication .