Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
reductions.hpp File Reference

Defines reduction operations for tensor expressions. More...

#include <array>
#include <cassert>
#include "concepts.hpp"
#include "types.hpp"
#include "traits.hpp"
#include "shape.hpp"
#include "tensor.hpp"
#include "indexing.hpp"
#include "exceptions.hpp"
Include dependency graph for reductions.hpp:

Go to the source code of this file.

Classes

class  tannic::expression::Reduction< Reducer, Operand >
 Lazy reduction expression. More...
 
struct  tannic::expression::Argmax
 Finds the indices of maximum values along an axis. More...
 
struct  tannic::expression::Argmin
 Finds the indexes of minimum values along an axis. More...
 
struct  tannic::expression::Argsum
 Sums tensor values along an axis. More...
 
struct  tannic::expression::Argmean
 Computes the mean along an axis. More...
 

Namespaces

namespace  tannic
 
namespace  tannic::expression
 

Functions

template<Expression Source>
constexpr auto tannic::expression::argmax (Source &&source, int axis, bool keepdim=false)
 Creates an Argmax reduction.
 
template<Expression Source>
constexpr auto tannic::expression::argmin (Source &&source, int axis, bool keepdim=false)
 Creates an Argmin reduction.
 
template<Expression Source>
constexpr auto tannic::expression::sum (Source &&source, int axis, bool keepdim=false)
 Creates a sum reduction.
 
template<Expression Source>
constexpr auto tannic::expression::mean (Source &&source, int axis, bool keepdim=false)
 Creates a mean reduction.
 

Detailed Description

Defines reduction operations for tensor expressions.

Author
Eric Hermosis
Date
2025

This header provides reduction operations for tensor-like objects, implemented as expression templates. Currently supports:

  • argmax: Index of maximum value along axis optionally keeping the original rank.
  • argmin: Index of minimum value along axis optionally keeping the original rank.
  • sum: Sum of the values along axis optionally keeping the original rank.
  • mean: Mean of the values along axis optionally keeping the original rank.

All reductions are lazy-evaluated and maintain proper shape/dtype transformations. Part of the Tannic Tensor Library.