clone#

Header: <pressio/ops.hpp>

API#

namespace pressio { namespace ops{

template<class T>
T clone(const T & operand);

}} // end namespace pressio::ops

Description#

  • Creates and returns a new instance of T by making a new allocation and copying all values from operand into it.

    • It is an exact but independent clone of operand.

  • T must be:

    • an Eigen vector or matrix object

    • a Kokkos view

    • a Teuchos vector

    • or a Tpetra vector or multi-vector

    • or a Tpetra block vector or multi-vector

Notes#

  • This is a blocking operation, i.e. the kernel completes before returning.

  • This kernel has value semantics, even for types that, by default, have view semantics like Kokkos, Tpetra or TpetraBlock. This means the following: let auto result = clone(operand), then any operation applied to operand after calling clone will NOT have any impact on result. And any operation applied to result will not have any impact on operand.

  • For types that have value semantics, for example Eigen::Matrix<...>, this kernel can be implemented by calling the copy constructor and returning the copy

  • For Kokkos, Tpetra, or TpetraBlock data types, which by default have view semantics (i.e. a copy is a shallow copy), the operation can be implemented by first making a new object with extents identical to operand, followed by a deep copy, and then return the result.

  • See the ops homepage for a table of booleans to use when checking that T has the correct type.