Skip to content

Commit

Permalink
Merge pull request #179 from ValeevGroup/evaleev/fix/tensor-convertin…
Browse files Browse the repository at this point in the history
…g-ctor-optimized-for-forward-iterables

optimize `Tensor(Boxtensor)` converting ctor ...
  • Loading branch information
evaleev authored Sep 24, 2024
2 parents af41dd9 + 9bac603 commit 4b3757c
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 4b3757c

Please sign in to comment.