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

Utilities for index normalization and slicing ranges in the Tannic Tensor Library. More...

#include <cassert>
#include "concepts.hpp"
#include "exceptions.hpp"
Include dependency graph for indexing.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tannic::indexing::Range
 Represents a half-open interval [start, stop) for slicing. More...
 

Namespaces

namespace  tannic
 
namespace  tannic::indexing
 

Typedefs

using tannic::range = indexing::Range
 Convenience alias for tannic::indexing::Range.
 

Functions

template<Integral Index, Integral Size>
constexpr Index tannic::indexing::normalize (Index index, Size bound)
 Normalize a possibly-negative index into the valid range [0, bound).
 
template<Integral Size>
constexpr Range tannic::indexing::normalize (Range range, Size size)
 Normalize a slicing range into valid [start, stop) indices.
 

Detailed Description

Utilities for index normalization and slicing ranges in the Tannic Tensor Library.

Author
Eric Hermosis
Date
2025

This header defines helper structures and functions for working with tensor indices and slices. The utilities are inspired by Python's negative indexing and range semantics, providing a consistent and safe interface for normalizing indices into valid positive ranges within tensor dimensions.