Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::function::Function< Functor, Argument > Class Template Reference

Expression template for mathematical function operations. More...

#include <functions.hpp>

Public Member Functions

constexpr Function (Functor functor, typename Trait< Argument >::Reference argument)
 Constructs a Function 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.
 
auto offset () const
 Returns the offset of the result.
 
Tensor forward () const
 

Public Attributes

Functor functor
 
Trait< Argument >::Reference argument
 

Detailed Description

template<Functional Functor, Expression Argument>
class tannic::function::Function< Functor, Argument >

Expression template for mathematical function operations.

Represents a lazily evaluated unary function that takes a functor as argument and maps it to an argument. The actual computation is deferred until forward() is called.

Template Parameters
FunctorA mathematical functor satisfying the Functional concept
ArgumentAn expression type satisfying the Expression concept

Constructor & Destructor Documentation

◆ Function()

template<Functional Functor, Expression Argument>
constexpr tannic::function::Function< Functor, Argument >::Function ( Functor  functor,
typename Trait< Argument >::Reference  argument 
)
inlineconstexpr

Constructs a Function expression.

Parameters
functorThe functor (e.g., Log, Exp)
argumentThe input tensor expression

Member Function Documentation

◆ dtype()

template<Functional Functor, Expression Argument>
constexpr type tannic::function::Function< Functor, Argument >::dtype ( ) const
inlineconstexpr

Returns the data type of the result.

Returns
The data type of the underlying argument.

Functors in this expression template system are type-preserving — applying them element-wise does not change the scalar type (e.g., applying exp() to a float32 tensor produces float32 output). Therefore, we can directly query and return the argument's dtype.

◆ forward()

template<Functional Functor, Expression Argument>
Tensor tannic::function::Function< Functor, Argument >::forward ( ) const
inline

◆ offset()

template<Functional Functor, Expression Argument>
auto tannic::function::Function< Functor, Argument >::offset ( ) const
inline

Returns the offset of the result.

Returns
The offset (in elements) into the underlying tensor storage.

Since element-wise functors do not change the memory location of the data, the offset is taken directly from the argument.

◆ shape()

template<Functional Functor, Expression Argument>
constexpr Shape const & tannic::function::Function< Functor, Argument >::shape ( ) const
inlineconstexpr

Returns the shape of the result.

Returns
A const reference to the shape of the underlying argument.

The shape is returned as const& to avoid copying the shape object, and because element-wise functors do not alter tensor dimensions.

◆ strides()

template<Functional Functor, Expression Argument>
constexpr Strides const & tannic::function::Function< Functor, Argument >::strides ( ) const
inlineconstexpr

Returns the strides of the result.

Returns
A const reference to the strides of the underlying argument.

Strides describe memory layout, and for pure element-wise operations they remain identical to those of the input tensor. Returning const& avoids copying and preserves the original stride information.

Member Data Documentation

◆ argument

template<Functional Functor, Expression Argument>
Trait<Argument>::Reference tannic::function::Function< Functor, Argument >::argument

◆ functor

template<Functional Functor, Expression Argument>
Functor tannic::function::Function< Functor, Argument >::functor

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