Skip to content

Commit

Permalink
optimize Tensor(Boxtensor) converting ctor for the case where BoxTens…
Browse files Browse the repository at this point in the history
…or is forward iterable only (such as TA::TensorInterface)
  • Loading branch information
evaleev committed Sep 24, 2024
1 parent af41dd9 commit 9bac603
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion btas/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ namespace btas {
/// copy constructor
/// It will accept Tensors and TensorViews
template <class _Tensor, class = typename std::enable_if<is_boxtensor<_Tensor>::value>::type>
Tensor(const _Tensor& x) : range_(x.range().lobound(), x.range().upbound()), storage_(x.cbegin(), x.cend()) {}
Tensor(const _Tensor& x) : range_(x.range().lobound(), x.range().upbound()){
auto size = range_.area();
array_adaptor<storage_type>::resize(storage_, size);
std::copy(x.cbegin(), x.cend(), storage_.begin());
}

/// copy constructor
/// @note this makes a shallow copy of @п х if `storage_type` has shallow-copy semantics; if need a deep copy
Expand Down

0 comments on commit 9bac603

Please sign in to comment.