50 #ifndef ROL_MULTIVECTOR_DEFAULT_HPP 51 #define ROL_MULTIVECTOR_DEFAULT_HPP 61 typedef Teuchos::RCP<V>
PV;
62 typedef Teuchos::ArrayRCP<PV>
APV;
64 typedef Teuchos::RCP<MV>
PMV;
75 return ( equalWidth | equalLength );
83 length_(mvec[0]->dimension()) {}
98 x[i] =
mvec_[i]->clone();
107 for(
int i=0;i<numvecs;++i) {
108 x[i] =
mvec_[0]->clone();
120 x[i] =
mvec_[i]->clone();
121 x[i]->set(*
mvec_[i]);
128 int n = index.size();
130 for(
int i=0;i<n;++i) {
132 x[i] =
mvec_[j]->clone();
133 x[i]->set(*
mvec_[j]);
140 int n = index.size();
142 for(
int i=0;i<n;++i) {
151 int n = index.size();
153 for(
int i=0;i<n;++i) {
170 void axpy(
const Real alpha,
const MV& x) {
180 const Teuchos::SerialDenseMatrix<int,Real> &B,
186 for(
int i=0;i<B.numRows();++i) {
187 for(
int j=0;j<B.numCols();++j) {
197 mvec_[i]->scale(alpha);
203 void scale(
const std::vector<Real> &alpha) {
205 TEUCHOS_TEST_FOR_EXCEPTION( static_cast<int>(alpha.size()) !=
numVectors_,
206 std::invalid_argument,
207 "Error: alpha must have the same length as the number of vectors.");
210 mvec_[i]->scale(alpha[i]);
215 void set(
const MV &A) {
222 mvec_[i]->set(*(A.getVector(i)));
229 void set(
const MV &A,
const std::vector<int> &index) {
235 int n = index.size();
237 for(
int i=0;i<n;++i) {
240 mvec_[k]->set(*A.getVector(i));
249 Teuchos::SerialDenseMatrix<int,Real> &B)
const {
264 std::vector<Real> &b)
const {
267 std::invalid_argument,
268 "Error: MultiVectors must have the same dimensions.");
276 void norms(std::vector<Real> &normvec)
const {
278 int min = numVectors_ < static_cast<int>(normvec.size()) ?
numVectors_ : normvec.size();
280 for(
int i=0;i<min;++i) {
281 normvec[i] =
mvec_[i]->norm();
296 std::invalid_argument,
297 "Error: index out of bounds");
void scale(const std::vector< Real > &alpha)
Scale each vector in the MultiVector by a different alpha .
const PMV shallowCopyConst(const std::vector< int > &index) const
Make a shallow copy of this MultiVector.
PMV shallowCopy(const std::vector< int > &index)
Make a shallow copy of this MultiVector.
void axpy(const Real alpha, const MV &x)
Perform the axpy operation columnwise on the MultiVector where is this MultiVector.
virtual ptrdiff_t getLength() const =0
Get the number of elements of a vector in the MultiVector.
MultiVectorDefault(APV mvec)
void scale(const Real alpha)
Scale the MultiVector by a single scalar alpha .
PMV deepCopy() const
Make a deep copy of this MultiVector.
Defines the linear algebra or vector space interface.
ptrdiff_t getLength() const
Get the number of elements of a vector in the MultiVector.
void dots(const MV &A, std::vector< Real > &b) const
Compute dot products of pairs of vectors.
void innerProducts(const Real alpha, const MV &A, Teuchos::SerialDenseMatrix< int, Real > &B) const
Compute .
virtual bool dimensionMismatch(const MV &A) const
MultiVectorDefault(PV vec)
void zero()
Zero each of the vectors in the MultiVector.
int getNumberOfVectors() const
Get the number of vectors in the MultiVector.
PMV deepCopy(const std::vector< int > &index) const
Make a deep copy of this MultiVector.
Default implementation of the ROL::MultiVector container class.
Teuchos::ArrayRCP< PV > APV
void norms(std::vector< Real > &normvec) const
Compute the norm of each vector in the MultiVector.
PMV clone(const int numvecs) const
Make a new MultiVector of specified "width".
Teuchos::ArrayRCP< PV > APV
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...
void gemm(const Real alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, Real > &B, const Real beta)
Generic BLAS level 3 matrix multiplication
PMV clone() const
Make a new MultiVector of the same dimensions.
PV getVector(int i) const
Return a pointer to the ith vector.