Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::operation::Unary< Operation, Operand > Class Template Reference

Expression template for a unary tensor aritmetic operation. More...

#include <operations.hpp>

Public Member Functions

constexpr Unary (Operation operation, Trait< Operand >::Reference operand)
 Constructs a Unary expression.
 
constexpr type dtype () const
 Returns the data type of the result.
 
constexpr Shape const & shape () const
 Returns the shape of the result.
 
constexpr Strides const & strides () const
 Returns the strides of the result.
 
std::ptrdiff_t offset () const
 Returns the offset of the expression.
 
Tensor forward () const
 Evaluates the unary expression and returns a Tensor.
 

Public Attributes

Operation operation
 
Trait< Operand >::Reference operand
 

Detailed Description

template<class Operation, Expression Operand>
class tannic::operation::Unary< Operation, Operand >

Expression template for a unary tensor aritmetic operation.

Represents a lazily evaluated unary operation applied to a single tensor-like operand. This template enables deferred execution and composability at compile time.

Template Parameters
OperationA stateless operation implementing void forward(Tensor const&, Tensor&).
OperandAn expression type satisfying the Expression concept.

Constructor & Destructor Documentation

◆ Unary()

template<class Operation , Expression Operand>
constexpr tannic::operation::Unary< Operation, Operand >::Unary ( Operation  operation,
Trait< Operand >::Reference  operand 
)
inlineconstexpr

Constructs a Unary expression.

Parameters
operationOperation functor (e.g., Negation).
operandOperand expression.

Member Function Documentation

◆ dtype()

template<class Operation , Expression Operand>
constexpr type tannic::operation::Unary< Operation, Operand >::dtype ( ) const
inlineconstexpr

Returns the data type of the result.

Since the unary operation acts element-wise and does not change type, this returns the same type as the operand.

Returns
Data type of the operand.

◆ forward()

template<class Operation , Expression Operand>
Tensor tannic::operation::Unary< Operation, Operand >::forward

Evaluates the unary expression and returns a Tensor.

Returns
Resulting Tensor after applying the unary operation.

◆ offset()

template<class Operation , Expression Operand>
std::ptrdiff_t tannic::operation::Unary< Operation, Operand >::offset ( ) const
inline

Returns the offset of the expression.

Returns
Always returns operand offset.

◆ shape()

template<class Operation , Expression Operand>
constexpr Shape const & tannic::operation::Unary< Operation, Operand >::shape ( ) const
inlineconstexpr

Returns the shape of the result.

The output of a unary operation has the exact same shape as the operand.

Returns
Shape of the operand.

◆ strides()

template<class Operation , Expression Operand>
constexpr Strides const & tannic::operation::Unary< Operation, Operand >::strides ( ) const
inlineconstexpr

Returns the strides of the result.

The output tensor has the same memory layout as the operand, so the strides are forwarded directly.

Returns
Strides of the operand.

Member Data Documentation

◆ operand

template<class Operation , Expression Operand>
Trait<Operand>::Reference tannic::operation::Unary< Operation, Operand >::operand

◆ operation

template<class Operation , Expression Operand>
Operation tannic::operation::Unary< Operation, Operand >::operation

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