TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable > Class Template Reference

Documentation

template<typename Result, typename Left, typename Right, bool LeftConsumable, bool RightConsumable>
class TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >

Tile multiplication operation.

This class implements element-wise multiplication of two tiles, optionally followed by a permutation of the result, that can be customized to arbitrary binary operation types. Thus this is essentially the binary std::transform with std::multiplies as the default binary op; the binary op is lowered automatically when applied to nested tensors.

Template Parameters
ResultThe result tile type
LeftThe left-hand argument type
RightThe right-hand argument type
LeftConsumableIf true, the left-hand tile is a temporary and may be consumed
RightConsumableIf true, the right-hand tile is a temporary and may be consumed
Note
Input tiles can be consumed only if their type matches the result type.

Definition at line 57 of file mult.h.

Public Types

typedef Mult< Result, Left, Right, LeftConsumable, RightConsumable > Mult_
 
typedef Left left_type
 Left-hand argument base type. More...
 
typedef Right right_type
 Right-hand argument base type. More...
 
typedef Result result_type
 The result tile type. More...
 
using left_value_type = typename left_type::value_type
 
using right_value_type = typename right_type::value_type
 
using result_value_type = typename result_type::value_type
 
using element_op_type = result_value_type(const left_value_type &, const right_value_type &)
 

Public Member Functions

 Mult ()=default
 
template<typename ElementOp , typename = std::enable_if_t< !std::is_same_v<std::remove_reference_t<ElementOp>, Mult_> && std::is_invocable_r_v< result_value_type, std::remove_reference_t<ElementOp>, const left_value_type&, const right_value_type&>>>
 Mult (ElementOp &&op)
 
template<typename L , typename R , typename Perm , typename = std::enable_if_t<TiledArray::detail::is_permutation_v<Perm>>>
result_type operator() (L &&left, R &&right, const Perm &perm) const
 Multiply-and-permute operator. More...
 
template<typename L , typename R >
result_type operator() (L &&left, R &&right) const
 Multiply operator. More...
 
template<typename R >
result_type consume_left (left_type &left, R &&right) const
 Multiply right to left. More...
 
template<typename L >
result_type consume_right (L &&left, right_type &right) const
 Multiply left to right. More...
 

Static Public Attributes

static constexpr bool left_is_consumable
 Indicates whether it is possible to consume the left tile. More...
 
static constexpr bool right_is_consumable
 Indicates whether it is possible to consume the right tile. More...
 

Member Typedef Documentation

◆ element_op_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
using TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::element_op_type = result_value_type(const left_value_type&, const right_value_type&)

Definition at line 67 of file mult.h.

◆ left_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
typedef Left TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::left_type

Left-hand argument base type.

Definition at line 60 of file mult.h.

◆ left_value_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
using TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::left_value_type = typename left_type::value_type

Definition at line 64 of file mult.h.

◆ Mult_

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
typedef Mult<Result, Left, Right, LeftConsumable, RightConsumable> TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::Mult_

Definition at line 59 of file mult.h.

◆ result_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
typedef Result TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::result_type

The result tile type.

Definition at line 62 of file mult.h.

◆ result_value_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
using TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::result_value_type = typename result_type::value_type

Definition at line 66 of file mult.h.

◆ right_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
typedef Right TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::right_type

Right-hand argument base type.

Definition at line 61 of file mult.h.

◆ right_value_type

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
using TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::right_value_type = typename right_type::value_type

Definition at line 65 of file mult.h.

Constructor & Destructor Documentation

◆ Mult() [1/2]

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::Mult ( )
default

The default constructor uses default op (std::multiplies) for the element-wise operation. This is valid for both plain and nested tensors. (times op is lowered naturally)

◆ Mult() [2/2]

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
template<typename ElementOp , typename = std::enable_if_t< !std::is_same_v<std::remove_reference_t<ElementOp>, Mult_> && std::is_invocable_r_v< result_value_type, std::remove_reference_t<ElementOp>, const left_value_type&, const right_value_type&>>>
TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::Mult ( ElementOp &&  op)
inlineexplicit

Construct using custom element-wise op

Template Parameters
ElementOpa callable with signature element_op_type
Parameters
op

Definition at line 182 of file mult.h.

Member Function Documentation

◆ consume_left()

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
template<typename R >
result_type TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::consume_left ( left_type left,
R &&  right 
) const
inline

Multiply right to left.

Multiply the right tile to the left.

Template Parameters
RThe right-hand tile argument type
Parameters
leftThe left-hand tile argument
rightThe right-hand tile argument
Returns
The product of left and right.

Definition at line 222 of file mult.h.

◆ consume_right()

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
template<typename L >
result_type TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::consume_right ( L &&  left,
right_type right 
) const
inline

Multiply left to right.

Multiply the left tile to the right.

Template Parameters
LThe left-hand tile argument type
Parameters
leftThe left-hand tile argument
rightThe right-hand tile argument
Returns
The product of left and right.

Definition at line 240 of file mult.h.

◆ operator()() [1/2]

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
template<typename L , typename R >
result_type TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::operator() ( L &&  left,
R &&  right 
) const
inline

Multiply operator.

Compute the product of two tiles.

Template Parameters
LThe left-hand tile argument type
RThe right-hand tile argument type
Parameters
leftThe left-hand tile argument
rightThe right-hand tile argument
Returns
The scaled product of left and right.

Definition at line 209 of file mult.h.

◆ operator()() [2/2]

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
template<typename L , typename R , typename Perm , typename = std::enable_if_t<TiledArray::detail::is_permutation_v<Perm>>>
result_type TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::operator() ( L &&  left,
R &&  right,
const Perm &  perm 
) const
inline

Multiply-and-permute operator.

Compute the product of two tiles and permute the result.

Template Parameters
LThe left-hand tile argument type
RThe right-hand tile argument type
Parameters
leftThe left-hand tile argument
rightThe right-hand tile argument
permThe permutation applied to the result tile
Returns
The permuted and scaled product of left and right.

Definition at line 196 of file mult.h.

Member Data Documentation

◆ left_is_consumable

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
constexpr bool TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::left_is_consumable
staticconstexpr
Initial value:
=
LeftConsumable && std::is_same<result_type, left_type>::value

Indicates whether it is possible to consume the left tile.

Definition at line 71 of file mult.h.

◆ right_is_consumable

template<typename Result , typename Left , typename Right , bool LeftConsumable, bool RightConsumable>
constexpr bool TiledArray::detail::Mult< Result, Left, Right, LeftConsumable, RightConsumable >::right_is_consumable
staticconstexpr
Initial value:
=
RightConsumable && std::is_same<result_type, right_type>::value

Indicates whether it is possible to consume the right tile.

Definition at line 74 of file mult.h.


The documentation for this class was generated from the following file: