Path Tracer
Public Member Functions | Public Attributes | Friends | List of all members
ptracey::sampled_wave< T > Class Template Reference

a wave sample representing a continuous wave in discreet form More...

#include <wave.hpp>

Public Member Functions

 sampled_wave (T val, unsigned int size)
 a constant value constructor More...
 
 sampled_wave (const std::vector< T > &vals)
 directly construct from given values. More...
 
max () const
 gives the maximum value among sampled points
 
min () const
 gives the minimum value among sampled points
 
bool has_nans () const
 check if sampled power values contain nan value.
 
bool has_zeros () const
 check if sampled power values contain 0 value.
 
bool is_black () const
 check if sampled power values contain only 0 value.
 
sampled_waveoperator= (const sampled_wave &s)
 assign a sample wave to this wave if it does not contain nan values
 
sampled_wave apply (unsigned int index, T value, const std::function< T(T, T)> &fn) const
 
sampled_wave apply (T value, const std::function< T(T, T)> &fn) const
 
sampled_wave apply (const sampled_wave &s, const std::function< T(T, T)> &fn) const
 apply a function to same sized wave samples More...
 
sampled_waveoperator+= (const sampled_wave &s) const
 
sampled_waveoperator+= (const T &s) const
 
sampled_wave operator+ (const sampled_wave &s) const
 add two same sized sampled waves
 
sampled_wave operator+ (const T &s) const
 add given power value to all of the elements of the sampled wave.
 
sampled_waveoperator-= (const sampled_wave &s) const
 
sampled_waveoperator-= (const T &s) const
 
sampled_wave operator- (const sampled_wave &s) const
 subtract two same sized sampled waves
 
sampled_wave operator- (const T &s) const
 subtract power value from this wave More...
 
sampled_waveoperator*= (const sampled_wave &s) const
 
sampled_waveoperator*= (const T &s) const
 
sampled_wave operator* (const sampled_wave &s) const
 multiply two same sized sampled waves
 
sampled_wave operator* (const T &s) const
 multiply given power value to all of the elements of the sampled wave.
 
sampled_waveoperator/= (const sampled_wave &s)
 
sampled_waveoperator/= (const T &s) const
 
sampled_wave operator/ (const sampled_wave &s) const
 divide two same sized sampled waves
 
sampled_wave operator/ (const T &s) const
 divide power value from this wave More...
 
T & operator[] (uint i)
 access to power value at given index. Mostly used for setting a new value for the given index; More...
 
operator[] (uint i) const
 access to power value at given index. Mostly used for reading the value of the given index; More...
 
bool operator== (const sampled_wave &cs) const
 check if given sampled wave has same power with this one. More...
 
bool operator!= (const sampled_wave &cs) const
 check if given sampled_wave is not equal to this or not
 
reduce (const std::function< T(T, T)> &fn, T counter_value) const
 reduce power values of this wave to a single value using given function More...
 
sum () const
 reduce sampled wave by summation
 
product () const
 reduce sampled wave by multiplication
 
Real average () const
 find the average value of this wave
 
uint size () const
 find the number of samples inside this wave
 
sampled_wave clamp (T low=0.0, T high=FLT_MAX)
 clamp power values of this wave to given range We also check if the resulting wave has nan values. More...
 
sampled_wave interpolate (Real low=0.0, Real high=FLT_MAX)
 

Public Attributes

std::vector< T > values
 holds observed power values of the wave
 

Friends

sampled_wave operator+ (const T &s, const sampled_wave &ss)
 
sampled_wave operator- (const T &s, const sampled_wave &ss)
 subtract every element of given sampled_wave from the value
 
sampled_wave operator* (const T &s, const sampled_wave &ss)
 
sampled_wave operator/ (const T &s, const sampled_wave &ss)
 divide power value from this wave More...
 

Detailed Description

template<class T>
class ptracey::sampled_wave< T >

a wave sample representing a continuous wave in discreet form

Constructor & Destructor Documentation

◆ sampled_wave() [1/2]

template<class T >
ptracey::sampled_wave< T >::sampled_wave ( val,
unsigned int  size 
)
inline

a constant value constructor

We give the number of samples and a constant value in order to initialize the sampled wave with a single value like 0, or 420

Parameters
sizedetermines the number of samples of the wave
valthe constant power value.

◆ sampled_wave() [2/2]

template<class T >
ptracey::sampled_wave< T >::sampled_wave ( const std::vector< T > &  vals)
inline

directly construct from given values.

We construct the wave directly from samples. We only check for nan values.

Parameters
valsa vector of values

Member Function Documentation

◆ apply() [1/3]

template<class T >
sampled_wave ptracey::sampled_wave< T >::apply ( const sampled_wave< T > &  s,
const std::function< T(T, T)> &  fn 
) const
inline

apply a function to same sized wave samples

Parameters
fnfunction to be applied to power values
Returns
a new wave

◆ apply() [2/3]

template<class T >
sampled_wave ptracey::sampled_wave< T >::apply ( value,
const std::function< T(T, T)> &  fn 
) const
inline
  \brief apply a function to all power values.

  \param fn function to be applied to power values
  \return a new wave

TODO:

Todo:
for basic arithmetic operations it might be enough to check for minimum and maximum power values for the given function.

◆ apply() [3/3]

template<class T >
sampled_wave ptracey::sampled_wave< T >::apply ( unsigned int  index,
value,
const std::function< T(T, T)> &  fn 
) const
inline
\brief apply a function to a single power value.

We check whether the operation produces a negative value

as well.

\param index index of the power value among values

vector

Parameters
fnfunction to be applied to the power value at index.
Returns
a new wave where the desired element is changed.

TODO

Todo:
This operation is probably very costly for large samples.

◆ clamp()

template<class T >
sampled_wave ptracey::sampled_wave< T >::clamp ( low = 0.0,
high = FLT_MAX 
)
inline

clamp power values of this wave to given range We also check if the resulting wave has nan values.

Parameters
lowlow end of the range
highhigh end of the range
Returns
sampled_wave with values between the range [low, high]

◆ operator*=() [1/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator*= ( const sampled_wave< T > &  s) const
inline
\brief multiply and assign values of given sampled

wave

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using *= operator.

◆ operator*=() [2/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator*= ( const T &  s) const
inline
\brief multiply and the given power value to this

wave.

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using *= operator.

◆ operator+=() [1/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator+= ( const sampled_wave< T > &  s) const
inline
\brief add and assign values of given sampled wave

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using += operator.

◆ operator+=() [2/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator+= ( const T &  s) const
inline
\brief add and the given power value to this wave.

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using += operator.

◆ operator-()

template<class T >
sampled_wave ptracey::sampled_wave< T >::operator- ( const T &  s) const
inline

subtract power value from this wave

We check whether the new value is producing negative power values.

◆ operator-=() [1/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator-= ( const sampled_wave< T > &  s) const
inline
\brief subtract and assign values of given sampled wave

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using -= operator.

◆ operator-=() [2/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator-= ( const T &  s) const
inline
\brief subtract and the given power value to this

wave.

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using -= operator.

◆ operator/()

template<class T >
sampled_wave ptracey::sampled_wave< T >::operator/ ( const T &  s) const
inline

divide power value from this wave

Parameters
svalue to divide We check if s is 0 then perform the division.

◆ operator/=() [1/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator/= ( const sampled_wave< T > &  s)
inline
\brief divide and assign values of given sampled wave

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using /= operator.

◆ operator/=() [2/2]

template<class T >
sampled_wave& ptracey::sampled_wave< T >::operator/= ( const T &  s) const
inline
\brief divide and the given power value to this

wave.

TODO

Todo:
this pointer changes value after this operation. This is probably not the intention of the user if she is using /= operator.

◆ operator==()

template<class T >
bool ptracey::sampled_wave< T >::operator== ( const sampled_wave< T > &  cs) const
inline

check if given sampled wave has same power with this one.

Parameters
cscomparison wave

◆ operator[]() [1/2]

template<class T >
T& ptracey::sampled_wave< T >::operator[] ( uint  i)
inline

access to power value at given index. Mostly used for setting a new value for the given index;

Returns
a reference

◆ operator[]() [2/2]

template<class T >
T ptracey::sampled_wave< T >::operator[] ( uint  i) const
inline

access to power value at given index. Mostly used for reading the value of the given index;

Returns
a value

◆ reduce()

template<class T >
T ptracey::sampled_wave< T >::reduce ( const std::function< T(T, T)> &  fn,
counter_value 
) const
inline

reduce power values of this wave to a single value using given function

Parameters
fnfunction that is applied during reduction
counter_valueinitial value assigned to aggregating variable

Friends And Related Function Documentation

◆ operator*

template<class T >
sampled_wave operator* ( const T &  s,
const sampled_wave< T > &  ss 
)
friend

◆ operator+

template<class T >
sampled_wave operator+ ( const T &  s,
const sampled_wave< T > &  ss 
)
friend

◆ operator/

template<class T >
sampled_wave operator/ ( const T &  s,
const sampled_wave< T > &  ss 
)
friend

divide power value from this wave

Parameters
svalue to divide
sswave to divide.

We check if s is 0, then divide 1 by s. Then we perform a mutliplication of the resulting value with the ss.


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