src/DataObjects/Tensors/RowDescriptor.hpp
src/DataObjects/Tensors/RowDescriptor.hpp
Describes the temporal meaning of a tensor’s row axis. More…
Classes
| Name | |
|---|---|
| class | RowDescriptor Describes the row structure of a tensor. |
Types
| Name | |
|---|---|
| enum class | RowType { TimeFrameIndex, Interval, Ordinal} Describes what the “row axis” (typically axis 0) of a tensor represents. |
Detailed Description
Describes the temporal meaning of a tensor’s row axis.
A tensor’s row axis (axis 0) can represent time-indexed samples (via TimeIndexStorage), time intervals (e.g., trials), or plain ordinal indices with no time semantics. RowDescriptor captures this as a discriminated variant with factory constructors and type-specific accessors.
Types Documentation
enum RowType
| Enumerator | Value | Description |
|---|---|---|
| TimeFrameIndex | Each row is a single TimeFrameIndex. | |
| Interval | Each row is a TimeFrameInterval. | |
| Ordinal | Rows have no temporal meaning (plain 0..N-1). |
Describes what the “row axis” (typically axis 0) of a tensor represents.
A tensor’s rows can represent:
- TimeFrameIndex: Each row corresponds to a single time point (indexed via TimeIndexStorage)
- Interval: Each row corresponds to a time interval (e.g., a trial)
- Ordinal: Rows have no temporal meaning — plain 0..N-1 indexing
Source code
#ifndef ROW_DESCRIPTOR_HPP
#define ROW_DESCRIPTOR_HPP
#include "TimeFrame/TimeFrameIndex.hpp" // TimeFrameIndex
#include "TimeFrame/TimeIndexStorage.hpp"// TimeIndexStorage
#include "TimeFrame/interval_data.hpp" // TimeFrameInterval
#include <cstddef>// size_t
#include <memory> // std::shared_ptr
#include <span> // std::span
#include <variant>// std::variant
#include <vector> // std::vector
class TimeFrame;
enum class RowType {
TimeFrameIndex,
Interval,
Ordinal
};
class RowDescriptor {
public:
using RowLabel = std::variant<std::monostate, std::size_t, TimeFrameIndex, TimeFrameInterval>;
// ========== Factory methods ==========
static RowDescriptor ordinal(std::size_t count);
static RowDescriptor fromTimeIndices(
std::shared_ptr<TimeIndexStorage> storage,
std::shared_ptr<TimeFrame> time_frame);
static RowDescriptor fromIntervals(
std::vector<TimeFrameInterval> intervals,
std::shared_ptr<TimeFrame> time_frame);
// ========== Queries ==========
[[nodiscard]] RowType type() const noexcept { return _type; }
[[nodiscard]] std::size_t count() const noexcept;
// ========== Type-specific access ==========
[[nodiscard]] TimeIndexStorage const & timeStorage() const;
[[nodiscard]] std::shared_ptr<TimeIndexStorage> timeStoragePtr() const;
[[nodiscard]] std::span<TimeFrameInterval const> intervals() const;
[[nodiscard]] std::shared_ptr<TimeFrame> timeFrame() const noexcept;
// ========== Row-level labeling ==========
[[nodiscard]] RowLabel labelAt(std::size_t row) const;
// ========== Mutation ==========
void setOrdinalCount(std::size_t new_count);
void appendInterval(TimeFrameInterval interval);
void insertInterval(std::size_t index, TimeFrameInterval interval);
// ========== Comparison ==========
bool operator==(RowDescriptor const & other) const;
bool operator!=(RowDescriptor const & other) const { return !(*this == other); }
private:
RowDescriptor() = default;
RowType _type{RowType::Ordinal};
std::size_t _ordinal_count{0};
std::shared_ptr<TimeIndexStorage> _time_storage;
std::vector<TimeFrameInterval> _intervals;
std::shared_ptr<TimeFrame> _time_frame;
};
#endif// ROW_DESCRIPTOR_HPPUpdated on 2026-11-13 at 20:25:43 +0000