Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::operation Namespace Reference

Classes

struct  Addition
 Binary element-wise addition of two tensor expressions. More...
 
class  Binary
 Expression template for a binary tensor operation. More...
 
struct  Exponentiation
 Binary element-wise exponentiation of two tensor expressions. More...
 
struct  Multiplication
 Binary element-wise multiplication of two tensor expressions. More...
 
struct  Negation
 Unary element-wise negation of a tensor expression. More...
 
struct  Subtraction
 Binary element-wise subtraction of two tensor expressions. More...
 
class  Unary
 Expression template for a unary tensor aritmetic operation. More...
 

Functions

template<Expression Operand>
constexpr auto operator- (Operand &&operand)
 Element-wise negation of a tensor expression.
 
template<Expression Augend, Expression Addend>
constexpr auto operator+ (Augend &&augend, Addend &&addend)
 Element-wise addition of two tensor expressions.
 
template<Expression Subtrahend, Expression Minuend>
constexpr auto operator- (Subtrahend &&subtrahend, Minuend &&minuend)
 Element-wise subtraction of two tensor expressions.
 
template<Expression Multiplicand, Expression Multiplier>
constexpr auto operator* (Multiplicand &&multiplicand, Multiplier &&multiplier)
 Element-wise multiplication of two tensor expressions.
 
template<Expression Base, Expression Exponent>
constexpr auto operator^ (Base &&base, Exponent &&exponent)
 Element-wise exponentiation of two tensor expressions.
 

Function Documentation

◆ operator*()

template<Expression Multiplicand, Expression Multiplier>
constexpr auto tannic::operation::operator* ( Multiplicand &&  multiplicand,
Multiplier &&  multiplier 
)
constexpr

Element-wise multiplication of two tensor expressions.

Constructs a lazily evaluated Binary<Multiplication, Multiplicand, Multiplier> expression. As with other binary operations, this uses broadcasting and type promotion internally. The computation on the elements is not performed immediately, but is deferred until forward() is called or the expression is assigned to a Tensor object.

Template Parameters
MultiplicandLeft-hand-side operand (expression).
MultiplierRight-hand-side operand (expression).
Parameters
multiplicandFirst operand.
multiplierSecond operand.
Returns
A binary expression representing element-wise multiplication.

◆ operator+()

template<Expression Augend, Expression Addend>
constexpr auto tannic::operation::operator+ ( Augend &&  augend,
Addend &&  addend 
)
constexpr

Element-wise addition of two tensor expressions.

Constructs a lazily evaluated Binary<Addition, Augend, Addend> expression. The result's shape is determined via broadcasting rules, and the resulting data type is the promoted type of the two operands. The computation on the elements is not performed immediately, but is deferred until forward() is called or the expression is assigned to a Tensor object.

Template Parameters
AugendLeft-hand-side operand (expression).
AddendRight-hand-side operand (expression).
Parameters
augendFirst operand.
addendSecond operand.
Returns
A binary expression representing element-wise addition.

◆ operator-() [1/2]

template<Expression Operand>
constexpr auto tannic::operation::operator- ( Operand &&  operand)
constexpr

Element-wise negation of a tensor expression.

Constructs a lazily evaluated Unary<Negation, Operand> expression. This operation does not perform immediate computation; it represents a node in the expression graph and will be evaluated upon calling forward().

Template Parameters
OperandA type satisfying the Expression concept.
Parameters
operandThe input expression to negate.
Returns
A unary expression representing element-wise negation.

◆ operator-() [2/2]

template<Expression Subtrahend, Expression Minuend>
constexpr auto tannic::operation::operator- ( Subtrahend &&  subtrahend,
Minuend &&  minuend 
)
constexpr

Element-wise subtraction of two tensor expressions.

Constructs a lazily evaluated Binary<Subtraction, Subtrahend, Minuend> expression. Shapes are broadcasted from the operands, and the type is promoted accordingly. The computation on the elements is not performed immediately, but is deferred until forward() is called or the expression is assigned to a Tensor object.

Template Parameters
SubtrahendLeft-hand-side operand (expression).
MinuendRight-hand-side operand (expression).
Parameters
subtrahendFirst operand.
minuendSecond operand.
Returns
A binary expression representing element-wise subtraction.

◆ operator^()

template<Expression Base, Expression Exponent>
constexpr auto tannic::operation::operator^ ( Base &&  base,
Exponent &&  exponent 
)
constexpr

Element-wise exponentiation of two tensor expressions.

Constructs a lazily evaluated Binary<Exponentiation, Base, Exponent> expression. Supports broadcasting across dimensions and type promotion between the base and exponent types.

Template Parameters
BaseLeft-hand-side operand (expression).
ExponentRight-hand-side operand (expression).
Parameters
baseThe base tensor expression.
exponentThe exponent tensor expression.
Returns
A binary expression representing element-wise exponentiation.

Example:

auto result = A ^ B;