109 template <
typename VectorType>
127 static_assert(std::is_convertible_v<real_type, value_type>,
128 "The real_type of the current VectorType is not "
129 "convertible to the value_type.");
148 Teuchos::RCP<VectorType>
154 Teuchos::RCP<const VectorType>
172 set(
const ROL::Vector<value_type> &rol_vector);
178 plus(
const ROL::Vector<value_type> &rol_vector);
197 dot(
const ROL::Vector<value_type> &rol_vector)
const;
214 Teuchos::RCP<ROL::Vector<value_type>>
222 Teuchos::RCP<ROL::Vector<value_type>>
229 applyUnary(
const ROL::Elementwise::UnaryFunction<value_type> &f);
236 applyBinary(
const ROL::Elementwise::BinaryFunction<value_type> &f,
237 const ROL::Vector<value_type> &rol_vector);
244 reduce(
const ROL::Elementwise::ReductionOp<value_type> &r)
const;
250 print(std::ostream &outStream)
const;
258 template <
typename VectorType>
260 const Teuchos::RCP<VectorType> &vector_ptr)
261 : vector_ptr(vector_ptr)
266 template <
typename VectorType>
267 Teuchos::RCP<VectorType>
275 template <
typename VectorType>
276 Teuchos::RCP<const VectorType>
284 template <
typename VectorType>
288 const VectorAdaptor &vector_adaptor =
289 Teuchos::dyn_cast<const VectorAdaptor>(rol_vector);
291 (*vector_ptr) = *(vector_adaptor.getVector());
296 template <
typename VectorType>
300 Assert(this->dimension() == rol_vector.dimension(),
303 const VectorAdaptor &vector_adaptor =
304 Teuchos::dyn_cast<const VectorAdaptor>(rol_vector);
306 *vector_ptr += *(vector_adaptor.getVector());
311 template <
typename VectorType>
314 const ROL::Vector<value_type> &rol_vector)
316 Assert(this->dimension() == rol_vector.dimension(),
319 const VectorAdaptor &vector_adaptor =
320 Teuchos::dyn_cast<const VectorAdaptor>(rol_vector);
322 vector_ptr->add(alpha, *(vector_adaptor.getVector()));
327 template <
typename VectorType>
331 Assert(vector_ptr->size() < std::numeric_limits<int>::max(),
332 ExcMessage(
"The size of the vector being used is greater than "
333 "largest value of type int."));
334 return static_cast<int>(vector_ptr->size());
339 template <
typename VectorType>
343 (*vector_ptr) *= alpha;
348 template <
typename VectorType>
349 typename VectorType::value_type
351 const ROL::Vector<value_type> &rol_vector)
const
353 Assert(this->dimension() == rol_vector.dimension(),
356 const VectorAdaptor &vector_adaptor =
357 Teuchos::dyn_cast<const VectorAdaptor>(rol_vector);
359 return (*vector_ptr) * (*vector_adaptor.getVector());
364 template <
typename VectorType>
365 typename VectorType::value_type
368 return vector_ptr->l2_norm();
373 template <
typename VectorType>
374 Teuchos::RCP<ROL::Vector<typename VectorType::value_type>>
377 Teuchos::RCP<VectorType> vec_ptr = Teuchos::rcp(
new VectorType);
378 (*vec_ptr) = (*vector_ptr);
380 return Teuchos::rcp(
new VectorAdaptor(vec_ptr));
385 template <
typename VectorType>
386 Teuchos::RCP<ROL::Vector<typename VectorType::value_type>>
389 Teuchos::RCP<VectorType> vec_ptr = Teuchos::rcp(
new VectorType);
392 vec_ptr->reinit(*vector_ptr,
false);
394 if (vector_ptr->locally_owned_elements().is_element(i))
395 vec_ptr->operator[](i) = 1.;
397 if (vec_ptr->has_ghost_elements())
399 vec_ptr->update_ghost_values();
406 Teuchos::RCP<VectorAdaptor>
e = Teuchos::rcp(
new VectorAdaptor(vec_ptr));
413 template <
typename VectorType>
416 const ROL::Elementwise::UnaryFunction<value_type> &f)
418 const typename VectorType::iterator vend = vector_ptr->end();
420 for (
typename VectorType::iterator iterator = vector_ptr->begin();
423 *iterator = f.apply(*iterator);
425 if (vector_ptr->has_ghost_elements())
427 vector_ptr->update_ghost_values();
437 template <
typename VectorType>
440 const ROL::Elementwise::BinaryFunction<value_type> &f,
441 const ROL::Vector<value_type> &rol_vector)
443 Assert(this->dimension() == rol_vector.dimension(),
446 const VectorAdaptor &vector_adaptor =
447 Teuchos::dyn_cast<const VectorAdaptor>(rol_vector);
449 const VectorType &given_rol_vector = *(vector_adaptor.getVector());
451 const typename VectorType::iterator vend = vector_ptr->end();
452 const typename VectorType::const_iterator rolend = given_rol_vector.end();
454 typename VectorType::const_iterator r_iterator = given_rol_vector.begin();
455 for (
typename VectorType::iterator l_iterator = vector_ptr->begin();
456 l_iterator != vend && r_iterator != rolend;
457 l_iterator++, r_iterator++)
458 *l_iterator = f.apply(*l_iterator, *r_iterator);
460 if (vector_ptr->has_ghost_elements())
462 vector_ptr->update_ghost_values();
472 template <
typename VectorType>
473 typename VectorType::value_type
475 const ROL::Elementwise::ReductionOp<value_type> &r)
const
477 typename VectorType::value_type result = r.initialValue();
479 const typename VectorType::iterator vend = vector_ptr->end();
481 for (
typename VectorType::iterator iterator = vector_ptr->begin();
484 r.reduce(*iterator, result);
492 template <
typename VectorType>
496 vector_ptr->print(outStream);