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

Class representing a branch node. More...

#include <node.hpp>

Inheritance diagram for graph::branch_node< T, SAFE_MATH >:
graph::leaf_node< T, false >

Public Member Functions

 branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s)
 Assigns the left and right branches.
 branch_node (shared_leaf< T, SAFE_MATH > l, shared_leaf< T, SAFE_MATH > r, const std::string s, const size_t count, const bool pseudo)
 Assigns the left and right branches.
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, jit::preamble_map &pre_funcs, int &avail_const_mem)
 Compile preamble.
shared_leaf< T, SAFE_MATH > get_left () const
 Get the left branch.
shared_leaf< T, SAFE_MATH > get_right () const
 Get the right branch.
virtual bool is_all_variables () const
 Test if node acts like a variable.
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > get_power_exponent () const
 Get the exponent of a power.
Public Member Functions inherited from graph::leaf_node< T, false >
 leaf_node (const std::string s, const size_t count, const bool pseudo)
 Construct a basic node.
virtual ~leaf_node ()
 Destructor.
virtual backend::buffer< T > evaluate ()=0
 Evaluate method.
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > reduce ()
 Reduction method.
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > df (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)
 Transform node to derivative.
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > compile (std::ostringstream &stream, jit::register_map &registers, const jit::register_map &thread_mem, const jit::register_usage &usage)=0
 Compile the node.
virtual bool is_match (std::shared_ptr< leaf_node< T, SAFE_MATH > > x)
 Query 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 to_latex () const
 Convert the node to latex.
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > to_vizgraph (std::stringstream &stream, jit::register_map &registers)=0
 Convert the node to vizgraph.
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 char end=';') const
 End a line in the kernel source.

Protected Attributes

shared_leaf< T, SAFE_MATH > left
 Left branch of the tree.
shared_leaf< T, SAFE_MATH > right
 Right branch of the tree.
Protected Attributes inherited from graph::leaf_node< T, false >
const size_t hash
 Hash for node.
const size_t complexity
 Graph complexity.
std::unordered_map< size_t, std::shared_ptr< leaf_node< T, SAFE_MATH > > > df_cache
 Cache derivative terms.
const bool contains_pseudo
 Node contains pseudo variables.

Additional Inherited Members

Public Types inherited from graph::leaf_node< T, false >
typedef T base
 Type def to retrieve the backend type.
Static Public Attributes inherited from graph::leaf_node< T, false >
static caches_t caches
 A per thread instance of the cache structure.

Detailed Description

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

Class representing a branch node.

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

This ensures that the base leaf type has the common type between the two template arguments.

Constructor & Destructor Documentation

◆ branch_node() [1/2]

template<jit::float_scalar T, bool SAFE_MATH = false>
graph::branch_node< T, SAFE_MATH >::branch_node ( shared_leaf< T, SAFE_MATH > l,
shared_leaf< T, SAFE_MATH > r,
const std::string s )
inline

Assigns the left and right branches.

Parameters
[in]lLeft branch.
[in]rRight branch.
[in]sNode string to hash.

◆ branch_node() [2/2]

template<jit::float_scalar T, bool SAFE_MATH = false>
graph::branch_node< T, SAFE_MATH >::branch_node ( shared_leaf< T, SAFE_MATH > l,
shared_leaf< T, SAFE_MATH > r,
const std::string s,
const size_t count,
const bool pseudo )
inline

Assigns the left and right branches.

Parameters
[in]lLeft branch.
[in]rRight branch.
[in]sNode string to hash.
[in]countNumber of nodes in the subgraph.
[in]pseudoNode contains pseudo variable.

Member Function Documentation

◆ compile_preamble()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual void graph::branch_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,
jit::preamble_map & pre_funcs,
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]pre_funcsSet of preamble functions.
[in,out]avail_const_memAvailable constant memory.

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

Reimplemented in graph::piecewise_2D_node< T, SAFE_MATH >, graph::triple_node< T, SAFE_MATH >, and graph::triple_node< T, false >.

◆ get_left()

template<jit::float_scalar T, bool SAFE_MATH = false>
shared_leaf< T, SAFE_MATH > graph::branch_node< T, SAFE_MATH >::get_left ( ) const
inline

Get the left branch.

Returns
The left argument.

◆ get_power_exponent()

template<jit::float_scalar T, bool SAFE_MATH = false>
virtual std::shared_ptr< leaf_node< T, SAFE_MATH > > graph::branch_node< T, SAFE_MATH >::get_power_exponent ( ) const
inlinevirtual

◆ get_right()

template<jit::float_scalar T, bool SAFE_MATH = false>
shared_leaf< T, SAFE_MATH > graph::branch_node< T, SAFE_MATH >::get_right ( ) const
inline

Get the right branch.

Returns
The right argument.

◆ is_all_variables()

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

Test if node acts like a variable.

Returns
True if the node acts like a variable.

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

Reimplemented in graph::piecewise_2D_node< T, SAFE_MATH >, graph::pow_node< T, SAFE_MATH >, graph::triple_node< T, SAFE_MATH >, and graph::triple_node< T, false >.


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