Tannic
A C++ Tensor Library
Loading...
Searching...
No Matches
tannic::expression::Realification< Source > Class Template Reference

Creates a real-valued view of complex tensor data. More...

#include <complex.hpp>

Public Member Functions

constexpr Realification (Trait< Source >::Reference source)
 
constexpr type dtype () const
 Returns the real dtype of the view.
 
constexpr Shape const & shape () const
 Returns the shape of the real view.
 
constexpr Strides const & strides () const
 Returns the strides of the real view.
 
std::ptrdiff_t offset () const
 
Tensor forward () const
 

Public Attributes

Trait< Source >::Reference source
 

Detailed Description

template<Expression Source>
class tannic::expression::Realification< Source >

Creates a real-valued view of complex tensor data.

Template Parameters
SourceComplex tensor type

Transformation Rules:

  • type: complex64 → float32, complex128 → float64
  • Shape: [...,N] → [...,N,2] (adds dimension for components)
  • Memory: Maintains same storage with adjusted strides

Requirements:

  • Input must be complex64 or complex128
  • Must have stride 1 in last dimension (contiguous complex pairs)

Example:

// complex64 input with shape [2]
Tensor cplx = {1+2i, 3+4i};
// float32 output with shape [2,2]
Tensor real_view = realify(cplx);
// real_view = [[1, 2], // real, imag components
// [3, 4]]
A multidimensional, strided tensor data structure.
Definition: tensor.hpp:105
constexpr auto realify(Complex &&complex)
Creates a real-valued view of complex tensor data.
Definition: complex.hpp:486

Constructor & Destructor Documentation

◆ Realification()

template<Expression Source>
constexpr tannic::expression::Realification< Source >::Realification ( Trait< Source >::Reference  source)
inlineconstexpr

Member Function Documentation

◆ dtype()

template<Expression Source>
constexpr type tannic::expression::Realification< Source >::dtype ( ) const
inlineconstexpr

Returns the real dtype of the view.

Returns
float32 if source was complex64, float64 if complex128

Transformation Rule:

complex64 → float32
complex128 → float64

◆ forward()

template<Expression Source>
Tensor Realification::forward

◆ offset()

template<Expression Source>
std::ptrdiff_t tannic::expression::Realification< Source >::offset ( ) const
inline

◆ shape()

template<Expression Source>
constexpr Shape const & tannic::expression::Realification< Source >::shape ( ) const
inlineconstexpr

Returns the shape of the real view.

Returns
Shape with last dimension expanded to 2

Transformation Rule:

[...,N] → [...,N,2]

Example:

Tensor cplx({2}); // [a+bi, c+di]
auto real = realify(cplx);
real.shape(); // Returns [2,2]

◆ strides()

template<Expression Source>
constexpr Strides const & tannic::expression::Realification< Source >::strides ( ) const
inlineconstexpr

Returns the strides of the real view.

Returns
Strides adjusted for component access

Transformation Rules:

  • Last stride becomes 1 (contiguous components)
  • Penultimate stride doubles (distance between complex numbers)

Member Data Documentation

◆ source

template<Expression Source>
Trait<Source>::Reference tannic::expression::Realification< Source >::source

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