Graph Framework
Loading...
Searching...
No Matches
graph::random_state_node< T, SAFE_MATH > Class Template Referencefinal

Random state. More...

#include <random.hpp>

Inheritance diagram for graph::random_state_node< T, SAFE_MATH >:
graph::leaf_node< T, SAFE_MATH >

Classes

struct  mt_state
 Random state structure. More...
 

Public Member Functions

 random_state_node (const size_t size, const uint32_t seed=0)
 Construct a constant node from a vector.
 
virtual backend::buffer< T > evaluate ()
 Evaluate the results of random_state_node.
 
virtual shared_leaf< T, SAFE_MATHreduce ()
 Reduce the random_state_node.
 
virtual shared_leaf< T, SAFE_MATHdf (shared_leaf< T, SAFE_MATH > x)
 Transform node to derivative.
 
virtual void compile_preamble (std::ostringstream &stream, jit::register_map &registers, jit::visiter_map &visited, jit::register_usage &usage, jit::texture1d_list &textures1d, jit::texture2d_list &textures2d, int &avail_const_mem)
 Compile preamble.
 
virtual shared_leaf< T, SAFE_MATHcompile (std::ostringstream &stream, jit::register_map &registers, jit::register_map &indices, const jit::register_usage &usage)
 Compile the node.
 
virtual void to_latex () const
 Convert the node to latex.
 
virtual shared_leaf< T, SAFE_MATHto_vizgraph (std::stringstream &stream, jit::register_map &registers)
 Convert the node to vizgraph.
 
virtual bool is_all_variables () const
 Test if all the subnodes terminate in variables.
 
virtual shared_leaf< T, SAFE_MATHget_power_exponent () const
 Get the exponent of a power.
 
size_t size ()
 Get the size of the random state vector in bytes.
 
size_t get_size_bytes ()
 Get the size of the random state vector in bytes.
 
mt_statedata ()
 Get the size of the random state vector in bytes.
 
- Public Member Functions inherited from graph::leaf_node< T, SAFE_MATH >
 leaf_node (const std::string s, const size_t count, const bool pseudo)
 Construct a basic node.
 
virtual ~leaf_node ()
 Destructor.
 
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > df (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)=0
 Transform node to derivative.
 
virtual bool is_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)
 Querey if the nodes match.
 
bool is_power_base_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)
 Check if the base of the powers match.
 
virtual void set (const T d)
 Set the value of variable data.
 
virtual void set (const size_t index, const T d)
 Set the value of variable data.
 
virtual void set (const std::vector< T > &d)
 Set the value of variable data.
 
virtual void set (const backend::buffer< T > &d)
 Set the value of variable data.
 
virtual bool is_constant () const
 Test if node is a constant.
 
virtual bool has_constant_zero () const
 Test the constant node has a zero.
 
bool is_normal ()
 Test if the result is normal.
 
virtual bool is_power_like () const
 Test if the node acts like a power of variable.
 
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > get_power_base ()
 Get the base of a power.
 
size_t get_hash () const
 Get the hash for the node.
 
size_t get_complexity () const
 Get the number of nodes in the subgraph.
 
virtual bool has_pseudo () const
 Query if the node contains pseudo variables.
 
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > remove_pseudo ()
 Remove pseudo variable nodes.
 
virtual void endline (std::ostringstream &stream, const jit::register_usage &usage) const final
 End a line in the kernel source.
 

Additional Inherited Members

- Public Types inherited from graph::leaf_node< T, SAFE_MATH >
typedefbase
 Type def to retrieve the backend type.
 
- Static Public Attributes inherited from graph::leaf_node< T, SAFE_MATH >
static thread_local caches_t caches
 A per thread instance of the cache structure.
 
- Protected Attributes inherited from graph::leaf_node< T, SAFE_MATH >
const size_t hash
 Hash for node.
 
const size_t complexity
 Graph complexity.
 
std::map< size_t, std::shared_ptr< leaf_node< T, SAFE_MATH > > > df_cache
 Cache derivative terms.
 
const bool contains_pseudo
 Node contains pseudo variables.
 

Detailed Description

template<jit::float_scalar T, bool SAFE_MATH = false>
class graph::random_state_node< T, SAFE_MATH >

Random state.

Class representing a random_state_node leaf.

Template Parameters
TBase type of the calculation.
SAFE_MATHUse Safe Math operations.

Constructor & Destructor Documentation

◆ random_state_node()

template<jit::float_scalar T, bool SAFE_MATH = false>
graph::random_state_node< T, SAFE_MATH >::random_state_node ( const size_t  size,
const uint32_t  seed = 0 
)
inline

Construct a constant node from a vector.

Parameters
[in]sizeNumber of random states.
[in]seedInital random seed.

Member Function Documentation

◆ compile()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual shared_leaf< T, SAFE_MATH > graph::random_state_node< T, SAFE_MATH >::compile ( std::ostringstream &  stream,
jit::register_map registers,
jit::register_map indices,
const jit::register_usage usage 
)
inlinevirtual

Compile the node.

Parameters
[in,out]streamString buffer stream.
[in,out]registersList of defined registers.
[in,out]indicesList of defined indices.
[in]usageList of register usage count.
Returns
The current node.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ compile_preamble()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual void graph::random_state_node< T, SAFE_MATH >::compile_preamble ( std::ostringstream &  stream,
jit::register_map registers,
jit::visiter_map visited,
jit::register_usage usage,
jit::texture1d_list textures1d,
jit::texture2d_list textures2d,
int avail_const_mem 
)
inlinevirtual

Compile preamble.

Parameters
[in,out]streamString buffer stream.
[in,out]registersList of defined registers.
[in,out]visitedList of visited nodes.
[in,out]usageList of register usage count.
[in,out]textures1dList of 1D textures.
[in,out]textures2dList of 2D textures.
[in,out]avail_const_memAvailable constant memory.

Reimplemented from graph::leaf_node< T, SAFE_MATH >.

◆ data()

template<jit::float_scalar T, bool SAFE_MATH = false>
mt_state * graph::random_state_node< T, SAFE_MATH >::data ( )
inline

Get the size of the random state vector in bytes.

Returns
The size of the state vector in bytes.

◆ df()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual shared_leaf< T, SAFE_MATH > graph::random_state_node< T, SAFE_MATH >::df ( shared_leaf< T, SAFE_MATH x)
inlinevirtual

Transform node to derivative.

Parameters
[in]xThe variable to take the derivative to.
Returns
The derivative of the node.

◆ evaluate()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual backend::buffer< T > graph::random_state_node< T, SAFE_MATH >::evaluate ( )
inlinevirtual

Evaluate the results of random_state_node.

Returns
The value of random_state.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ get_power_exponent()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual shared_leaf< T, SAFE_MATH > graph::random_state_node< T, SAFE_MATH >::get_power_exponent ( ) const
inlinevirtual

Get the exponent of a power.

Returns
The exponent of a power like node.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ get_size_bytes()

template<jit::float_scalar T, bool SAFE_MATH = false>
size_t graph::random_state_node< T, SAFE_MATH >::get_size_bytes ( )
inline

Get the size of the random state vector in bytes.

Returns
The size of the state vector in bytes.

◆ is_all_variables()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual bool graph::random_state_node< T, SAFE_MATH >::is_all_variables ( ) const
inlinevirtual

Test if all the subnodes terminate in variables.

Returns
True if all the subnodes terminate in variables.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ reduce()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual shared_leaf< T, SAFE_MATH > graph::random_state_node< T, SAFE_MATH >::reduce ( )
inlinevirtual

Reduce the random_state_node.

Returns
Reduced graph from random_state.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ size()

template<jit::float_scalar T, bool SAFE_MATH = false>
size_t graph::random_state_node< T, SAFE_MATH >::size ( )
inline

Get the size of the random state vector in bytes.

Returns
The size of the state vector in bytes.

◆ to_latex()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual void graph::random_state_node< T, SAFE_MATH >::to_latex ( ) const
inlinevirtual

Convert the node to latex.

Implements graph::leaf_node< T, SAFE_MATH >.

◆ to_vizgraph()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual shared_leaf< T, SAFE_MATH > graph::random_state_node< T, SAFE_MATH >::to_vizgraph ( std::stringstream &  stream,
jit::register_map registers 
)
inlinevirtual

Convert the node to vizgraph.

Parameters
[in,out]streamString buffer stream.
[in,out]registersList of defined registers.
Returns
The current node.

Implements graph::leaf_node< T, SAFE_MATH >.


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