tensor#

namespace saltro
namespace math
template<int R, int C, int D>
class Tensor3#
#include <tensor.h>

A 3D tensor with compile-time dimensions stored as an array of slices.

This template provides a fixed-size 3D tensor where each “slice” along the third dimension is an R×C Eigen matrix. Indexing follows (i, j, k) where k selects the slice.

Template Parameters:
  • R – Number of rows in each slice

  • C – Number of columns in each slice

  • D – Number of slices (depth)

Public Types

using Slice = Eigen::Matrix<double, R, C>#

Public Functions

inline Tensor3()#

Default constructor; initializes all elements to zero.

inline void setZero()#

Set all elements of the tensor to zero.

inline bool isZero() const#

Check if all elements of the tensor are zero.

Returns:

True if every element is zero, false otherwise.

inline Slice &slice(int k)#

Access a slice (2D matrix) along the third dimension.

Returns a reference to the k-th R×C matrix slice.

Parameters:

k – Slice index (0 ≤ k < D).

Returns:

Mutable reference to the k-th slice.

inline const Slice &slice(int k) const#

Access a slice (2D matrix) along the third dimension (const version).

Parameters:

k – Slice index (0 ≤ k < D).

Returns:

Const reference to the k-th slice.

inline double &operator()(int i, int j, int k)#

Access a single element by 3D index (i, j, k).

Returns a mutable reference to element at row i, column j, slice k.

Parameters:
  • i – Row index (0 ≤ i < R).

  • j – Column index (0 ≤ j < C).

  • k – Slice index (0 ≤ k < D).

Returns:

Mutable reference to the element.

inline const double &operator()(int i, int j, int k) const#

Access a single element by 3D index (const version).

Parameters:
  • i – Row index (0 ≤ i < R).

  • j – Column index (0 ≤ j < C).

  • k – Slice index (0 ≤ k < D).

Returns:

Const reference to the element.

Public Static Functions

static inline Tensor3 Zero()#

Static factory method to create a zero-initialized tensor.

Returns:

A new Tensor3 with all elements set to zero.

Private Members

std::array<Slice, D> data_ = {}#