26 #ifndef TILEDARRAY_TENSOR_TENSOR_VIEW_H__INCLUDED 27 #define TILEDARRAY_TENSOR_TENSOR_VIEW_H__INCLUDED 35 template <
typename>
class aligned_allocator;
43 template <
typename,
typename>
class Tensor;
46 template <
typename,
typename>
49 template <
typename T,
typename Index>
51 template <
typename T,
typename Index>
53 const Index&,
const Index&);
56 const std::initializer_list<std::size_t>&,
57 const std::initializer_list<std::size_t>&);
60 const std::initializer_list<std::size_t>&,
61 const std::initializer_list<std::size_t>&);
78 template <
typename T,
typename R>
84 typedef typename std::remove_const<T>::type
86 typedef typename std::add_lvalue_reference<T>::type
88 typedef typename std::add_lvalue_reference<typename std::add_const<T>::type>::type
90 typedef typename std::add_pointer<T>::type
92 typedef typename std::add_pointer<typename std::add_const<T>::type>::type
105 template <
typename X>
108 template <
typename,
typename>
111 template <
typename U,
typename Index>
113 U*
const,
const Index&,
const Index&);
115 template <
typename U,
typename Index>
117 U*
const,
const Index&,
const Index&);
119 template <
typename U>
122 const std::initializer_list<std::size_t>&,
123 const std::initializer_list<std::size_t>&);
125 template <
typename U>
128 const std::initializer_list<std::size_t>&,
129 const std::initializer_list<std::size_t>&);
148 template <
typename U,
149 typename std::enable_if<std::is_convertible<
153 range_(other.range_), data_(other.data_)
160 template <
typename U,
161 typename std::enable_if<std::is_convertible<
165 range_(
std::move(other.range_)), data_(other.data_)
167 other.data_ =
nullptr;
190 template <
typename T1,
191 typename std::enable_if<detail::is_tensor<T1>::value>::type* =
nullptr>
196 const numeric_t<T1> arg)
197 { result = arg; }, *
this, other);
224 return data_[range_.ordinal(index)];
233 return data_[range_.ordinal(index)];
241 template<
typename... Index>
244 return data_[range_.ordinal(idx...)];
251 template<
typename... Index>
254 return data_[range_.ordinal(idx...)];
260 constexpr
bool empty()
const {
return false; }
266 range_.swap(other.range_);
276 template <
typename Index>
278 range_.inplace_shift(bound_shift);
287 template <
typename Index>
302 template <
typename Right,
typename Op,
303 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
317 template <
typename Right,
typename Op,
318 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
335 template <
typename Right,
typename Op,
336 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
349 template <
typename Op>
363 template <
typename Op>
374 template <
typename Op>
388 template <
typename Scalar,
389 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
392 {
return a * factor; });
402 template <
typename Scalar,
403 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
406 {
return a * factor; }, perm);
414 template <
typename Scalar,
415 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
429 template <
typename Right,
430 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
433 const numeric_t<Right> r)
444 template <
typename Right,
445 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
448 const numeric_t<Right> r)
460 template <
typename Right,
typename Scalar,
461 typename std::enable_if<is_tensor<Right>::value &&
465 const numeric_t<Right> r)
478 template <
typename Right,
typename Scalar,
479 typename std::enable_if<is_tensor<Right>::value &&
485 const numeric_t<Right> r)
496 {
return a + value; });
507 {
return a + value; }, perm);
515 template <
typename Right,
516 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
519 const numeric_t<Right> r)
530 template <
typename Right,
typename Scalar,
531 typename std::enable_if<is_tensor<Right>::value &&
535 const numeric_t<Right> r)
536 { (l += r) *= factor; });
555 template <
typename Right,
556 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
559 const numeric_t<Right> r)
570 template <
typename Right,
571 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
574 const numeric_t<Right> r)
586 template <
typename Right,
typename Scalar,
587 typename std::enable_if<is_tensor<Right>::value &&
591 const numeric_t<Right> r)
604 template <
typename Right,
typename Scalar,
605 typename std::enable_if<is_tensor<Right>::value &&
611 const numeric_t<Right> r)
630 return add(-value, perm);
638 template <
typename Right,
639 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
642 const numeric_t<Right> r)
653 template <
typename Right,
typename Scalar,
654 typename std::enable_if<is_tensor<Right>::value &&
658 const numeric_t<Right> r)
659 { (l -= r) *= factor; });
677 template <
typename Right,
678 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
681 const numeric_t<Right> r)
692 template <
typename Right,
693 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
696 const numeric_t<Right> r)
708 template <
typename Right,
typename Scalar,
709 typename std::enable_if<is_tensor<Right>::value &&
713 const numeric_t<Right> r)
726 template <
typename Right,
typename Scalar,
727 typename std::enable_if<is_tensor<Right>::value &&
733 const numeric_t<Right> r)
742 template <
typename Right,
743 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
746 const numeric_t<Right> r)
757 template <
typename Right,
typename Scalar,
758 typename std::enable_if<is_tensor<Right>::value &&
762 const numeric_t<Right> r)
763 { (l *= r) *= factor; });
804 template <
typename Scalar,
805 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
826 template <
typename Scalar,
827 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
844 template <
typename Scalar,
845 typename std::enable_if<detail::is_numeric<Scalar>::value>::type* =
nullptr>
864 template <
typename ReduceOp,
typename JoinOp>
886 template <
typename Right,
typename ReduceOp,
typename JoinOp,
887 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
975 template <
typename Right,
976 typename std::enable_if<is_tensor<Right>::value>::type* =
nullptr>
979 const numeric_t<Right> r)
991 #endif // TILEDARRAY_TENSOR_TENSOR_VIEW_H__INCLUDED result_tensor neg() const
Create a negated copy of this tensor.
numeric_type reduce(ReduceOp &&reduce_op, JoinOp &&join_op, const numeric_type identity) const
Unary reduction operation.
result_tensor conj(const Permutation &perm) const
Create a complex conjugated and permuted copy of this tensor.
result_tensor unary(Op &&op) const
Use a unary, element wise operation to construct a new tensor.
TensorInterface_ & inplace_binary(const Right &right, Op &&op)
Use a binary, element wise operation to modify this tensor.
void inplace_tensor_op(Op &&op, TR &result, const Ts &... tensors)
In-place tensor operations with contiguous data.
result_tensor subt(const Right &right, const numeric_type factor) const
Scale and subtract this and right to construct a new tensor.
TensorInterface_ & mult_to(const Right &right)
Multiply this tensor by right.
TensorInterface_ & shift_to(const Index &bound_shift)
Shift the lower and upper bound of this tensor.
scalar_type squared_norm() const
Square of vector 2-norm.
~TensorInterface()=default
result_tensor binary(const Right &right, Op &&op, const Permutation &perm) const
Use a binary, element wise operation to construct a new, permuted tensor.
reference operator()(const Index &... idx)
Element accessor.
An N-dimensional tensor object.
result_tensor shift(const Index &bound_shift) const
Shift the lower and upper bound of this range.
std::add_lvalue_reference< T >::type reference
Element reference type.
void swap(Bitset< B > &b0, Bitset< B > &b1)
TensorInterface_ & operator=(const TensorInterface_ &)=delete
result_tensor mult(const Right &right, const Permutation &perm) const
Multiply this by right to create a new, permuted tensor.
result_tensor neg(const Permutation &perm) const
Create a negated and permuted copy of this tensor.
result_tensor binary(const Right &right, Op &&op) const
Use a binary, element wise operation to construct a new tensor.
result_tensor subt(const numeric_type value) const
Subtract a constant from a copy of this tensor.
std::add_pointer< T >::type pointer
Element pointer type.
constexpr bool empty() const
Check for empty view.
TILEDARRAY_FORCE_INLINE R norm(const R r)
Wrapper function for std::norm
TensorInterface(TensorInterface< U, R > &&other)
Type conversion move constructor.
result_tensor conj() const
Create a complex conjugated copy of this tensor.
detail::numeric_type< value_type >::type numeric_type
the numeric type that supports T
Type trait for extracting the numeric type of tensors and arrays.
TensorInterface_ & subt_to(const numeric_type value)
Subtract a constant from this tensor.
numeric_type sum() const
Sum of elements.
KroneckerDeltaTile< _N >::numeric_type max(const KroneckerDeltaTile< _N > &arg)
auto abs(const ComplexConjugate< T > &a)
TensorInterface_ & mult_to(const Right &right, const Scalar factor)
Scale and multiply this tensor by right.
Type trait for extracting the scalar type of tensors and arrays.
result_tensor add(const Right &right, const Scalar factor, const Permutation &perm) const
Scale and add this and other to construct a new, permuted tensor.
reference operator[](const size_type index)
Element subscript accessor.
TensorInterface_ & subt_to(const Right &right)
Subtract right from this tensor.
numeric_type dot(const Right &other) const
Vector dot product.
result_tensor add(const Right &right) const
Add this and other to construct a new tensors.
std::add_lvalue_reference< typename std::add_const< T >::type >::type const_reference
Element reference type.
TensorInterface_ & inplace_unary(Op &&op)
Use a unary, element wise operation to modify this tensor.
Tensor< T, Eigen::aligned_allocator< T > > result_tensor
Tensor type used as the return type from arithmetic operations.
void swap(TensorInterface_ &other)
Swap tensor views.
result_tensor add(const Right &right, const Permutation &perm) const
Add this and other to construct a new, permuted tensor.
TensorInterface(range_type &&range, pointer data)
Construct a new view of tensor.
result_tensor conj(const Scalar factor) const
Create a complex conjugated and scaled copy of this tensor.
std::ptrdiff_t difference_type
Difference type.
TensorInterface_ & neg_to()
Negate elements of this tensor.
result_tensor subt(const Right &right, const Permutation &perm) const
Subtract this and right to construct a new, permuted tensor.
result_tensor scale(const Scalar factor, const Permutation &perm) const
Construct a scaled and permuted copy of this tensor.
TensorInterface_ & scale_to(const Scalar factor)
Scale this tensor.
result_tensor add(const numeric_type value) const
Add a constant to a copy of this tensor.
T identity()
identity for group of objects of type T
TensorInterface(const range_type &range, pointer data)
Construct a new view of tensor.
numeric_type product() const
Product of elements.
TensorInterface()=delete
Compiler generated functions.
numeric_type min() const
Minimum element.
const_reference operator()(const Index &... idx) const
Element accessor.
std::remove_const< T >::type value_type
Array element type.
void reduce_op(ReduceOp &&reduce_op, JoinOp &&join_op, const Result &identity, const std::size_t n, Result &result, const Args *const ... args)
result_tensor scale(const Scalar factor) const
Construct a scaled copy of this tensor.
const_reference operator[](const size_type index) const
Element subscript accessor.
Tensor interface for external data.
result_tensor subt(const Right &right, const Scalar factor, const Permutation &perm) const
Scale and subtract this and right to construct a new, permuted tensor.
result_tensor conj(const Scalar factor, const Permutation &perm) const
Create a complex conjugated, scaled, and permuted copy of this tensor.
R range_type
Tensor range type.
void remap(detail::TensorInterface< T, Range > &, T *const, const Index &, const Index &)
result_tensor mult(const Right &right) const
Multiply this by right to create a new tensor.
TensorInterface_ & conj_to()
Complex conjugate this tensor.
std::add_pointer< typename std::add_const< T >::type >::type const_pointer
Element pointer type.
TensorInterface_ & subt_to(const Right &right, const Scalar factor)
Subtract right from and scale this tensor.
Permutation of a sequence of objects indexed by base-0 indices.
TensorInterface(const TensorInterface< U, R > &other)
Type conversion copy constructor.
ComplexConjugate< S > conj_op(const S factor)
ComplexConjugate operator factory function.
const range_type & range() const
Tensor range object accessor.
TensorInterface_ & add_to(const Right &right, const Scalar factor)
Add other to this tensor, and scale the result.
numeric_type reduce(const Right &other, ReduceOp &&reduce_op, JoinOp &&join_op, const numeric_type identity) const
Binary reduction operation.
range_type::size_type size_type
size type
size_type size() const
Tensor dimension size accessor.
result_tensor unary(Op &&op, const Permutation &perm) const
Use a unary, element wise operation to construct a new, permuted tensor.
result_tensor subt(const numeric_type value, const Permutation &perm) const
Subtract a constant from a permuted copy of this tensor.
detail::scalar_type< value_type >::type scalar_type
the scalar type that supports T
TensorInterface_ & operator=(const T1 &other)
TensorInterface_ & add_to(const numeric_type value)
Add a constant to this tensor.
Scalar tensor_reduce(ReduceOp &&reduce_op, JoinOp &&join_op, Scalar identity, const T1 &tensor1, const Ts &... tensors)
Reduction operation for contiguous tensors.
result_tensor add(const Right &right, const Scalar factor) const
Scale and add this and other to construct a new tensor.
TensorInterface< T, R > TensorInterface_
This class type.
numeric_type max() const
Maximum element.
TensorInterface_ & conj_to(const Scalar factor)
Complex conjugate and scale this tensor.
result_tensor mult(const Right &right, const Scalar factor) const
Scale and multiply this by right to create a new tensor.
TensorInterface_ & add_to(const Right &right)
Add other to this tensor.
KroneckerDeltaTile< _N >::numeric_type min(const KroneckerDeltaTile< _N > &arg)
numeric_type abs_max() const
Absolute maximum element.
numeric_type abs_min() const
Absolute minimum element.
pointer data() const
Data pointer accessor.
result_tensor subt(const Right &right) const
Subtract this and right to construct a new tensor.
result_tensor add(const numeric_type value, const Permutation &perm) const
Add a constant to a permuted copy of this tensor.
numeric_type norm() const
Vector 2-norm.
result_tensor mult(const Right &right, const Scalar factor, const Permutation &perm) const
Scale and multiply this by right to create a new, permuted tensor.