26 #ifndef TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED 27 #define TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED 33 namespace expressions {
36 template <
typename,
bool>
class TsrExpr;
37 template <
typename,
bool>
class BlkTsrExpr;
38 template <
typename,
typename>
class ScalBlkTsrExpr;
40 template <
typename Array>
44 template <
typename Array,
typename Scalar>
54 template <
typename Array,
bool Alias>
56 public std::integral_constant<bool, Alias> { };
58 template <
typename Array,
bool Alias>
68 template <
typename Array,
bool Alias>
78 template <
typename Array,
typename Scalar>
88 template <
typename Array,
typename Scalar>
101 template <
typename Derived>
119 const unsigned int rank =
array_.trange().tiles_range().rank();
122 if(TiledArray::get_default_world().rank() == 0) {
124 "The size lower bound of the block is not equal to rank of " \
126 <<
"\n array rank = " <<
array_.trange().tiles_range().rank() \
129 TA_EXCEPTION(
"The size lower bound of the block is not equal to " \
130 "rank of the array.");
136 if(TiledArray::get_default_world().rank() == 0) {
138 "The size upper bound of the block is not equal to rank of " \
140 <<
"\n array rank = " << rank \
143 TA_EXCEPTION(
"The size upper bound of the block is not equal to " \
144 "rank of the array.");
148 const bool lower_bound_check =
150 array_.trange().tiles_range().lobound_data(),
151 [] (std::size_t l, std::size_t r) {
return l >= r; });
152 const bool upper_bound_check =
154 array_.trange().tiles_range().upbound_data(),
155 [] (std::size_t l, std::size_t r) {
return l <= r; });
156 if(! (lower_bound_check && upper_bound_check)) {
157 if(TiledArray::get_default_world().rank() == 0) {
159 "The block range is not a sub-block of the array range: " \
160 <<
"\n array range = " <<
array_.trange().tiles_range() \
164 TA_EXCEPTION(
"The block range is not a sub-block of the array range.");
167 const bool lower_upper_bound_check =
170 [] (std::size_t l, std::size_t r) {
return l < r; });
171 if(! lower_upper_bound_check) {
172 if(TiledArray::get_default_world().rank() == 0) {
174 "The block lower bound is not less than the upper bound: " \
179 TA_EXCEPTION(
"The block lower bound is not less than the upper bound.");
199 template <
typename Index>
238 template <
typename Array,
bool Alias>
239 class BlkTsrExpr :
public BlkTsrExprBase<BlkTsrExpr<Array, Alias> > {
264 template <
typename Index>
282 other.eval_to(*
this);
290 template <
typename D>
293 "no_alias() expressions are not allowed on the right-hand side of " 294 "the assignment operator.");
303 template <
typename D>
306 "no_alias() expressions are not allowed on the right-hand side of " 307 "the assignment operator.");
315 template <
typename D>
318 "no_alias() expressions are not allowed on the right-hand side of " 319 "the assignment operator.");
327 template <
typename D>
330 "no_alias() expressions are not allowed on the right-hand side of " 331 "the assignment operator.");
359 template <
typename Array>
390 template <
typename Index>
412 template <
typename Array,
typename Scalar>
413 class ScalBlkTsrExpr :
public BlkTsrExprBase<ScalBlkTsrExpr<Array, Scalar> > {
450 template <
typename Index>
472 template <
typename Array,
typename Scalar,
bool Alias,
473 typename std::enable_if<
476 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type, Scalar>
479 expr.array(), expr.vars(), factor, expr.lower_bound(),
491 template <
typename Array,
typename Scalar,
bool Alias,
492 typename std::enable_if<
495 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type, Scalar>
498 expr.array(), expr.vars(), factor, expr.lower_bound(),
510 template <
typename Array,
typename Scalar1,
typename Scalar2,
511 typename std::enable_if<
514 inline ScalBlkTsrExpr<Array, mult_t<Scalar1, Scalar2> >
517 expr.vars(), expr.factor() * factor, expr.lower_bound(),
529 template <
typename Array,
typename Scalar1,
typename Scalar2,
530 typename std::enable_if<
533 inline ScalBlkTsrExpr<Array, mult_t<Scalar2, Scalar1> >
536 expr.vars(), expr.factor() * factor, expr.lower_bound(),
545 template <
typename Array>
546 inline ScalBlkTsrExpr<typename std::remove_const<Array>::type,
547 typename ExprTrait<BlkTsrExpr<Array, true> >::numeric_type>
552 numeric_type>(expr.array(), expr.vars(), -1, expr.lower_bound(),
562 template <
typename Array,
typename Scalar>
563 inline ScalBlkTsrExpr<Array, Scalar>
566 -expr.factor(), expr.lower_bound(), expr.upper_bound());
576 template <
typename Array,
bool Alias>
577 inline ConjBlkTsrExpr<typename std::remove_const<Array>::type>
580 expr.array(), expr.vars(),
conj_op(), expr.lower_bound(),
589 template <
typename Array>
590 inline BlkTsrExpr<const Array, true>
602 template <
typename Array,
typename Scalar>
603 inline ScalConjBlkTsrExpr<Array, Scalar>
607 expr.lower_bound(), expr.upper_bound());
616 template <
typename Array,
typename Scalar>
617 inline ScalBlkTsrExpr<Array, Scalar>
631 template <
typename Array,
typename Scalar,
632 typename std::enable_if<
635 inline ScalConjBlkTsrExpr<Array, Scalar>
648 template <
typename Array,
typename Scalar,
649 typename std::enable_if<
652 inline ScalConjBlkTsrExpr<Array, Scalar>
665 template <
typename Array,
typename Scalar1,
typename Scalar2,
666 typename std::enable_if<
669 inline ScalConjBlkTsrExpr<Array, mult_t<Scalar1, Scalar2> >
683 template <
typename Array,
typename Scalar1,
typename Scalar2,
684 typename std::enable_if<
687 inline ScalConjBlkTsrExpr<Array, mult_t<Scalar2, Scalar1> >
699 template <
typename Array>
701 typename ExprTrait<ConjBlkTsrExpr<Array> >::numeric_type>
715 template <
typename Array,
typename Scalar>
716 inline ScalConjBlkTsrExpr<Array, Scalar>
727 #endif // TILEDARRAY_EXPRESSIONS_BLK_TSR_EXPR_H__INCLUDED
const Array & reference
Array reference type
ExprTrait< BlkTsrExpr_ >::array_type array_type
The array type.
Scaled tensor block expression engine.
BlkTsrExprBase(const BlkTsrExprBase_ &)=default
ExprTrait< BlkTsrExpr_ >::engine_type engine_type
Expression engine type.
ExprTrait< BlkTsrExpr_ >::reference reference
The array reference type.
numeric_t< Array > numeric_type
Array base numeric type.
numeric_t< Array > numeric_type
Array base numeric type.
ConjBlkTsrExpr< array_type > conj() const
Conjugated block tensor expression factory.
~BlkTsrExprBase()=default
const std::vector< std::size_t > & upper_bound() const
Upper bound accessor.
ConjBlkTsrExpr< array_type > conj() const
Conjugated block tensor expression factory.
Tensor expression engine.
~ScalBlkTsrExpr()=default
BlkTsrExprBase< ScalBlkTsrExpr_ > BlkTsrExprBase_
Block expresion base type.
ExprTrait< ScalBlkTsrExpr_ >::reference reference
The array reference type.
scalar_t< Array > scalar_type
Array base scalar type.
scalar_type factor() const
Scaling factor accessor.
std::enable_if< TiledArray::detail::is_numeric< Scalar >::value, ScalAddExpr< Left, Right, Scalar > >::type operator*(const AddExpr< Left, Right > &expr, const Scalar &factor)
Scaled-addition expression factor.
Scalar scalar_type
Tile scalar type.
BlkTsrExprBase(reference array, const std::string &vars, const Index &lower_bound, const Index &upper_bound)
Block expression constructor.
BlkTsrEngine< Array, typename Array::eval_type, Alias > engine_type
Expression engine type.
Array & reference
Array reference type
decltype(std::declval< Scalar1 >() *std::declval< Scalar2 >()) mult_t
ExprTrait< ScalBlkTsrExpr_ >::engine_type engine_type
Expression engine type.
BlkTsrEngine< Array, typename Array::eval_type, Alias > engine_type
Expression engine type.
Multiplication expression.
typename TiledArray::detail::numeric_type< T >::type numeric_t
BlkTsrExpr(reference array, const std::string &vars, const Index &lower_bound, const Index &upper_bound)
Block expression constructor.
std::string vars_
The tensor variable list.
Scalar scalar_type
Tile scalar type.
numeric_t< Array > numeric_type
Array base numeric type.
ExprTrait< BlkTsrExpr_ >::reference reference
The array reference type.
ExprTrait< Derived >::array_type array_type
The array type.
const Array & reference
Array reference type
ScalBlkTsrExpr_ & operator=(const ScalBlkTsrExpr_ &)=delete
constexpr std::size_t size(T(&)[N])
Array size accessor.
std::vector< std::size_t > upper_bound_
Upper bound of the tile block.
ExprTrait< Derived >::reference reference
The array reference type.
BlkTsrExpr< Array, Alias > BlkTsrExpr_
This class type.
ExprTrait< ScalBlkTsrExpr_ >::scalar_type scalar_type
Scalar type.
const std::vector< std::size_t > & lower_bound() const
Lower bound accessor.
const Array & reference
Array reference type
Array array_type
The Array type.
ScalBlkTsrExpr(reference array, const std::string &vars, const scalar_type factor, const Index &lower_bound, const Index &upper_bound)
Block expression constructor.
reference operator=(const Expr< D > &other)
Expression assignment operator.
scalar_t< Array > scalar_type
Array base scalar type.
BlkTsrExpr(reference array, const std::string &vars, const Index &lower_bound, const Index &upper_bound)
Block expression constructor.
reference operator+=(const Expr< D > &other)
Expression plus-assignment operator.
reference operator*=(const Expr< D > &other)
Expression multiply-assignment operator.
typename TiledArray::detail::scalar_type< T >::type scalar_t
ExprTrait< BlkTsrExpr_ >::engine_type engine_type
Expression engine type.
BlkTsrExpr< const Array, true > BlkTsrExpr_
This class type.
BlkTsrExpr< Array, false > no_alias() const
Flag this tensor expression for a non-aliasing assignment.
Base class for expression evaluation.
derived_type & derived()
Cast this object to it's derived type.
ConjAddExpr< Left, Right > conj(const AddExpr< Left, Right > &expr)
Conjugated addition expression factory.
void eval_to(TsrExpr< A, Alias > &tsr) const
Evaluate this object and assign it to tsr.
reference operator=(BlkTsrExpr_ &&other)
Expression assignment operator.
ScalAddExpr< Left, Right, typename ExprTrait< AddExpr< Left, Right > >::numeric_type > operator-(const AddExpr< Left, Right > &expr)
Negated addition expression factor.
reference array_
The array that this expression.
std::vector< std::size_t > lower_bound_
Lower bound of the tile block.
BlkTsrExprBase< BlkTsrExpr_ > BlkTsrExprBase_
Block expression base type.
TILEDARRAY_FORCE_INLINE R conj(const R r)
Wrapper function for std::conj
reference operator-=(const Expr< D > &other)
Expression minus-assignment operator.
ExprTrait< BlkTsrExpr_ >::array_type array_type
The array type.
reference operator=(const BlkTsrExpr_ &other)
Expression assignment operator.
ExprTrait< ScalBlkTsrExpr_ >::array_type array_type
The array type.
ScalBlkTsrExpr< Array, TiledArray::detail::ComplexConjugate< Scalar > > ScalConjBlkTsrExpr
ComplexConjugate< S > conj_op(const S factor)
ComplexConjugate operator factory function.
const std::string & vars() const
Tensor variable string accessor.
reference array() const
Array accessor.
ScalBlkTsrEngine< Array, Scalar, typename Array::eval_type > engine_type
Expression engine type.
Array array_type
The Array type.
BlkTsrExprBase< BlkTsrExpr_ > BlkTsrExprBase_
Block expression base type.
ScalBlkTsrExpr< Array, Scalar > ScalBlkTsrExpr_
This class type.
Array array_type
The Array type.
numeric_t< Array > numeric_type
Array base numeric type.
BlkTsrExprBase< Derived > BlkTsrExprBase_
This class type.
Expr< Derived > Expr_
Unary base class type.
ScalBlkTsrEngine< Array, Scalar, typename Array::eval_type > engine_type
Expression engine type.
#define TA_USER_ERROR_MESSAGE(m)
Array array_type
The Array type.
ScalBlkTsrExpr< Array, TiledArray::detail::ComplexConjugate< void > > ConjBlkTsrExpr
DistArray< Tile, Policy > Array
BlkTsrExprBase_ & operator=(const BlkTsrExprBase_ &)=delete