Go to the documentation of this file.
26 #ifndef TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED
27 #define TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED
36 namespace expressions {
39 template <
typename,
bool>
41 template <
typename,
bool>
43 template <
typename,
typename>
46 template <
typename Array>
50 template <
typename Array,
typename Scalar>
61 template <
typename Array,
bool Alias>
63 :
public std::integral_constant<bool, Alias> {};
65 template <
typename Array,
bool Alias>
75 template <
typename Array,
bool Alias>
85 template <
typename Array,
typename Scalar>
95 template <
typename Array,
typename Scalar>
108 template <
typename Derived>
127 const unsigned int rank =
array_.trange().tiles_range().rank();
132 using TiledArray::operator<<;
134 "The size lower bound of the block is not equal to rank of "
136 <<
"\n array rank = " <<
array_.trange().tiles_range().rank()
140 "The size lower bound of the block is not equal to "
141 "rank of the array.");
148 using TiledArray::operator<<;
150 "The size upper bound of the block is not equal to rank of "
152 <<
"\n array rank = " <<
rank
156 "The size upper bound of the block is not equal to "
157 "rank of the array.");
161 const bool lower_bound_check =
163 array_.trange().tiles_range().lobound_data(),
164 [](std::size_t l, std::size_t r) { return l >= r; });
165 const bool upper_bound_check =
167 array_.trange().tiles_range().upbound_data(),
168 [](std::size_t l, std::size_t r) { return l <= r; });
169 if (!(lower_bound_check && upper_bound_check)) {
171 using TiledArray::operator<<;
173 "The block range is not a sub-block of the array range: "
174 <<
"\n array range = " <<
array_.trange().tiles_range()
179 TA_EXCEPTION(
"The block range is not a sub-block of the array range.");
182 const bool lower_upper_bound_check =
185 [](std::size_t l, std::size_t r) {
return l < r; });
186 if (!lower_upper_bound_check) {
188 using TiledArray::operator<<;
190 "The block lower bound is not less than the upper bound: "
195 TA_EXCEPTION(
"The block lower bound is not less than the upper bound.");
215 template <
typename Index1,
typename Index2,
216 typename = std::enable_if_t<
217 TiledArray::detail::is_integral_range_v<Index1> &&
218 TiledArray::detail::is_integral_range_v<Index2>>>
239 template <
typename PairRange,
240 typename = std::enable_if_t<
241 TiledArray::detail::is_gpair_range_v<PairRange>>>
243 const PairRange& bounds)
249 for (
auto&& bound_d : bounds) {
288 template <
typename Array,
bool Alias>
315 template <
typename Index1,
typename Index2,
316 typename = std::enable_if_t<
317 TiledArray::detail::is_integral_range_v<Index1> &&
318 TiledArray::detail::is_integral_range_v<Index2>>>
320 const Index1& lower_bound,
const Index2& upper_bound)
331 template <
typename PairRange,
332 typename = std::enable_if_t<
333 TiledArray::detail::is_gpair_range_v<PairRange>>>
335 const PairRange& bounds)
353 other.eval_to(*
this);
361 other.eval_to(*
this);
369 template <
typename D>
373 "no_alias() expressions are not allowed on the right-hand side of "
374 "the assignment operator.");
375 other.
derived().eval_to(*
this);
383 template <
typename D>
387 "no_alias() expressions are not allowed on the right-hand side of "
388 "the assignment operator.");
396 template <
typename D>
400 "no_alias() expressions are not allowed on the right-hand side of "
401 "the assignment operator.");
409 template <
typename D>
413 "no_alias() expressions are not allowed on the right-hand side of "
414 "the assignment operator.");
440 template <
typename Array>
470 template <
typename Index1,
typename Index2,
471 typename = std::enable_if_t<
472 TiledArray::detail::is_integral_range_v<Index1> &&
473 TiledArray::detail::is_integral_range_v<Index2>>>
475 const Index1& lower_bound,
const Index2& upper_bound)
486 template <
typename PairRange,
487 typename = std::enable_if_t<
488 TiledArray::detail::is_gpair_range_v<PairRange>>>
490 const PairRange& bounds)
508 template <
typename Array,
typename Scalar>
544 template <
typename Index1,
typename Index2,
545 typename = std::enable_if_t<
546 TiledArray::detail::is_integral_range_v<Index1> &&
547 TiledArray::detail::is_integral_range_v<Index2>>>
550 const Index2& upper_bound)
562 template <
typename PairRange,
563 typename = std::enable_if_t<
564 TiledArray::detail::is_gpair_range_v<PairRange>>>
584 template <
typename Array,
typename Scalar,
bool Alias,
585 typename std::enable_if<
586 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
587 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type, Scalar>
590 expr.array(), expr.annotation(), factor, expr.lower_bound(),
602 template <
typename Array,
typename Scalar,
bool Alias,
603 typename std::enable_if<
604 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
605 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type, Scalar>
608 expr.array(), expr.annotation(), factor, expr.lower_bound(),
620 template <
typename Array,
typename Scalar1,
typename Scalar2,
621 typename std::enable_if<
622 TiledArray::detail::is_numeric_v<Scalar2>>::type* =
nullptr>
626 expr.array(), expr.annotation(), expr.
factor() * factor,
627 expr.lower_bound(), expr.upper_bound());
638 template <
typename Array,
typename Scalar1,
typename Scalar2,
639 typename std::enable_if<
640 TiledArray::detail::is_numeric_v<Scalar1>>::type* =
nullptr>
644 expr.array(), expr.annotation(), expr.
factor() * factor,
645 expr.lower_bound(), expr.upper_bound());
653 template <
typename Array>
654 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type,
655 typename ExprTrait<BlkTsrExpr<Array, true>>::numeric_type>
660 expr.array(), expr.annotation(), -1, expr.lower_bound(),
670 template <
typename Array,
typename Scalar>
674 -expr.
factor(), expr.lower_bound(),
684 template <
typename Array,
bool Alias>
688 expr.array(), expr.annotation(),
conj_op(), expr.lower_bound(),
697 template <
typename Array>
700 expr.lower_bound(), expr.upper_bound());
709 template <
typename Array,
typename Scalar>
713 expr.array(), expr.annotation(),
724 template <
typename Array,
typename Scalar>
728 expr.array(), expr.annotation(),
740 template <
typename Array,
typename Scalar,
741 typename std::enable_if<
742 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
746 conj_op(factor), expr.lower_bound(),
757 template <
typename Array,
typename Scalar,
758 typename std::enable_if<
759 TiledArray::detail::is_numeric_v<Scalar>>::type* =
nullptr>
763 conj_op(factor), expr.lower_bound(),
774 template <
typename Array,
typename Scalar1,
typename Scalar2,
775 typename std::enable_if<
776 TiledArray::detail::is_numeric_v<Scalar2>>::type* =
nullptr>
780 expr.array(), expr.annotation(),
conj_op(expr.
factor().factor() * factor),
781 expr.lower_bound(), expr.upper_bound());
791 template <
typename Array,
typename Scalar1,
typename Scalar2,
792 typename std::enable_if<
793 TiledArray::detail::is_numeric_v<Scalar1>>::type* =
nullptr>
797 expr.array(), expr.annotation(),
conj_op(expr.
factor().factor() * factor),
798 expr.lower_bound(), expr.upper_bound());
806 template <
typename Array>
808 Array,
typename ExprTrait<ConjBlkTsrExpr<Array>>::numeric_type>
812 expr.array(), expr.annotation(), conj_op<numeric_type>(-1),
813 expr.lower_bound(), expr.upper_bound());
822 template <
typename Array,
typename Scalar>
826 expr.array(), expr.annotation(),
conj_op(-expr.
factor().factor()),
827 expr.lower_bound(), expr.upper_bound());
833 #endif // TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED
reference operator+=(const Expr< D > &other)
Expression plus-assignment operator.
BlkTsrExpr(reference array, const std::string &annotation, const Index1 &lower_bound, const Index2 &upper_bound)
Block expression constructor.
BlkTsrExprBase(reference array, const std::string &annotation, const PairRange &bounds)
Block expression constructor.
boost::container::small_vector< T, N > svector
ExprTrait< BlkTsrExpr_ >::engine_type engine_type
Expression engine type.
BlkTsrExprBase_ & operator=(BlkTsrExprBase_ &&)=delete
const auto & lower_bound() const
Lower bound accessor.
scalar_t< Array > scalar_type
Array base scalar type.
ScalAddExpr< Left, Right, typename ExprTrait< AddExpr< Left, Right > >::numeric_type > operator-(const AddExpr< Left, Right > &expr)
Negated addition expression factor.
~ScalBlkTsrExpr()=default
typename TiledArray::detail::numeric_type< T >::type numeric_t
numeric_t<T> is an alias for numeric_type<T>::type
ScalBlkTsrExpr_ & operator=(ScalBlkTsrExpr_ &&)=delete
ExprTrait< ScalBlkTsrExpr_ >::reference reference
The array reference type.
decltype(std::declval< Scalar1 >() *std::declval< Scalar2 >()) mult_t
ScalBlkTsrEngine< Array, Scalar, typename Array::eval_type > engine_type
Expression engine type.
scalar_type factor() const
Scaling factor accessor.
BlkTsrExprBase(const BlkTsrExprBase_ &)=default
BlkTsrExpr(const BlkTsrExpr_ &)=default
BlkTsrExpr(const BlkTsrExpr_ &)=default
BlkTsrExprBase(BlkTsrExprBase_ &&)=default
numeric_t< Array > numeric_type
Array base numeric type.
Array array_type
The Array type.
BlkTsrExpr< Array, false > no_alias() const
Flag this tensor expression for a non-aliasing assignment.
const Array & reference
Array reference type
ExprTrait< Derived >::reference reference
The array reference type.
Array & reference
Array reference type
ScalBlkTsrExpr< Array, Scalar > ScalBlkTsrExpr_
This class type.
BlkTsrExprBase(reference array, const std::string &annotation, const Index1 &lower_bound, const Index2 &upper_bound)
Block expression constructor.
container::svector< std::size_t > lower_bound_
Lower bound of the tile block.
Base class for expression evaluation.
ExprTrait< Derived >::array_type array_type
The array type.
BlkTsrEngine< Array, typename Array::eval_type, Alias > engine_type
Expression engine type.
BlkTsrExpr_ & operator=(BlkTsrExpr_ &&)=delete
std::enable_if< TiledArray::detail::is_numeric_v< Scalar >, ScalAddExpr< Left, Right, Scalar > >::type operator*(const AddExpr< Left, Right > &expr, const Scalar &factor)
Scaled-addition expression factor.
ExprTrait< ScalBlkTsrExpr_ >::array_type array_type
The array type.
reference operator*=(const Expr< D > &other)
Expression multiply-assignment operator.
auto rank(const DistArray< Tile, Policy > &a)
Expr< Derived > Expr_
Unary base class type.
Scalar scalar_type
Tile scalar type.
BlkTsrExprBase_ & operator=(const BlkTsrExprBase_ &)=delete
const auto & upper_bound() const
Upper bound accessor.
ConjAddExpr< Left, Right > conj(const AddExpr< Left, Right > &expr)
Conjugated addition expression factory.
BlkTsrExprBase< Derived > BlkTsrExprBase_
This class type.
scalar_t< Array > scalar_type
Array base scalar type.
#define TA_ASSERT(EXPR,...)
World & get_default_world()
typename TiledArray::detail::scalar_type< T >::type scalar_t
scalar_t<T> is an alias for scalar_type<T>::type
reference array() const
Array accessor.
ExprTrait< BlkTsrExpr_ >::reference reference
The array reference type.
numeric_t< Array > numeric_type
Array base numeric type.
ScalBlkTsrExpr(reference array, const std::string &annotation, const scalar_type factor, const Index1 &lower_bound, const Index2 &upper_bound)
Block expression constructor.
ExprTrait< BlkTsrExpr_ >::reference reference
The array reference type.
DistArray< Tile, Policy > Array
BlkTsrExpr_ & operator=(const BlkTsrExpr_ &)=delete
const Array & reference
Array reference type
Array array_type
The Array type.
BlkTsrExprBase< BlkTsrExpr_ > BlkTsrExprBase_
Block expression base type.
container::svector< std::size_t > upper_bound_
Upper bound of the tile block.
BlkTsrExpr< const Array, true > BlkTsrExpr_
This class type.
Array array_type
The Array type.
Scaled tensor block expression engine.
ConjBlkTsrExpr< array_type > conj() const
Conjugated block tensor expression factory.
ScalBlkTsrExpr< Array, TiledArray::detail::ComplexConjugate< Scalar > > ScalConjBlkTsrExpr
ExprTrait< BlkTsrExpr_ >::array_type array_type
The array type.
BlkTsrExpr(reference array, const std::string &annotation, const PairRange &bounds)
Block expression constructor.
ScalBlkTsrExpr(ScalBlkTsrExpr_ &&)=default
const Array & reference
Array reference type
reference array_
The array that this expression is bound to.
std::string annotation_
The array annotation.
ScalBlkTsrExpr(const ScalBlkTsrExpr_ &)=default
ScalBlkTsrExpr(reference array, const std::string &annotation, const scalar_type factor, const PairRange &bounds)
Block expression constructor.
Scalar scalar_type
Tile scalar type.
BlkTsrExpr(BlkTsrExpr_ &&)=default
BlkTsrExpr(reference array, const std::string &annotation, const PairRange &bounds)
Block expression constructor.
BlkTsrEngine< Array, typename Array::eval_type, Alias > engine_type
Expression engine type.
reference operator=(BlkTsrExpr_ &&other)
Expression assignment operator.
reference operator-=(const Expr< D > &other)
Expression minus-assignment operator.
numeric_t< Array > numeric_type
Array base numeric type.
BlkTsrExpr(BlkTsrExpr_ &&)=default
ScalBlkTsrEngine< Array, Scalar, typename Array::eval_type > engine_type
Expression engine type.
~BlkTsrExprBase()=default
ExprTrait< ScalBlkTsrExpr_ >::engine_type engine_type
Expression engine type.
ComplexConjugate< S > conj_op(const S factor)
ComplexConjugate operator factory function.
const std::string & annotation() const
Tensor annotation accessor.
reference operator=(const BlkTsrExpr_ &other)
Block expression constructor.
Array array_type
The Array type.
ConjBlkTsrExpr< array_type > conj() const
Conjugated block tensor expression factory.
BlkTsrExprBase< ScalBlkTsrExpr_ > BlkTsrExprBase_
Block expresion base type.
ScalBlkTsrExpr_ & operator=(const ScalBlkTsrExpr_ &)=delete
#define TA_USER_ERROR_MESSAGE(m)
BlkTsrExpr(reference array, const std::string &annotation, const Index1 &lower_bound, const Index2 &upper_bound)
Block expression constructor.
BlkTsrExprBase< BlkTsrExpr_ > BlkTsrExprBase_
Block expression base type.
BlkTsrExpr< Array, Alias > BlkTsrExpr_
This class type.
Multiplication expression.
decltype(auto) at(GeneralizedPair &&v, std::size_t idx)
at(pair, i) extracts i-th element from gpair
ExprTrait< BlkTsrExpr_ >::engine_type engine_type
Expression engine type.
TILEDARRAY_FORCE_INLINE R conj(const R r)
Wrapper function for std::conj
Tensor expression engine.
reference operator=(const Expr< D > &other)
Expression assignment operator.
ExprTrait< BlkTsrExpr_ >::array_type array_type
The array type.
ExprTrait< ScalBlkTsrExpr_ >::scalar_type scalar_type
Scalar type.
derived_type & derived()
Cast this object to its derived type.
numeric_t< Array > numeric_type
Array base numeric type.