Graph Framework
|
Class representing data that can change. More...
#include <node.hpp>
Public Member Functions | |
variable_node (const size_t s, const std::string &symbol) | |
Construct a variable node with a size. | |
variable_node (const size_t s, const T d, const std::string &symbol) | |
Construct a variable node from a scalar. | |
variable_node (const std::vector< T > &d, const std::string &symbol) | |
Construct a variable node from a vector. | |
variable_node (const backend::buffer< T > &d, const std::string &symbol) | |
Construct a variable node from backend buffer. | |
virtual backend::buffer< T > | evaluate () |
Evaluate method. | |
virtual shared_leaf< T, SAFE_MATH > | reduce () |
Reduction method. | |
virtual shared_leaf< T, SAFE_MATH > | df (shared_leaf< T, SAFE_MATH > x) |
Transform node to derivative. | |
virtual void | compile_preamble (std::ostringstream &stream, jit::register_map ®isters, 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_MATH > | compile (std::ostringstream &stream, jit::register_map ®isters, jit::register_map &indices, const jit::register_usage &usage) |
Compile the node. | |
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. | |
std::string | get_symbol () const |
Get Symbol. | |
virtual void | to_latex () const |
Convert the node to latex. | |
virtual shared_leaf< T, SAFE_MATH > | to_vizgraph (std::stringstream &stream, jit::register_map ®isters) |
Convert the node to vizgraph. | |
size_t | size () |
Get the size of the variable buffer. | |
T * | data () |
Get a pointer to raw buffer. | |
virtual bool | is_all_variables () const |
Test if node acts like a variable. | |
virtual bool | is_power_like () const |
Test if the node acts like a power of variable. | |
virtual shared_leaf< T, SAFE_MATH > | get_power_base () |
Get the base of a power. | |
virtual shared_leaf< T, SAFE_MATH > | get_power_exponent () const |
Get the exponent of a power. | |
![]() | |
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 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. | |
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 | |
![]() | |
typedef T | base |
Type def to retrieve the backend type. | |
![]() | |
static thread_local caches_t | caches |
A per thread instance of the cache structure. | |
![]() | |
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. | |
Class representing data that can change.
T | Base type of the calculation. |
SAFE_MATH | Use Safe Math operations. |
|
inline |
Construct a variable node with a size.
[in] | s | Size of the data buffer. |
[in] | symbol | Symbol of the variable used in equations. |
|
inline |
Construct a variable node from a scalar.
[in] | s | Size of he data buffer. |
[in] | d | Scalar data to initalize. |
[in] | symbol | Symbol of the variable used in equations. |
|
inline |
Construct a variable node from a vector.
[in] | d | Array buffer. |
[in] | symbol | Symbol of the variable used in equations. |
|
inline |
Construct a variable node from backend buffer.
[in] | d | Backend buffer. |
[in] | symbol | Symbol of the variable used in equations. |
|
inlinevirtual |
Compile the node.
[in,out] | stream | String buffer stream. |
[in,out] | registers | List of defined registers. |
[in,out] | indices | List of defined indices. |
[in] | usage | List of register usage count. |
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Compile preamble.
Some nodes require additions to the preamble however most don't so define a generic method that does nothing.
[in,out] | stream | String buffer stream. |
[in,out] | registers | List of defined registers. |
[in,out] | visited | List of visited nodes. |
[in,out] | usage | List of register usage count. |
[in,out] | textures1d | List of 1D textures. |
[in,out] | textures2d | List of 2D textures. |
[in,out] | avail_const_mem | Available constant memory. |
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inline |
Get a pointer to raw buffer.
|
inlinevirtual |
Transform node to derivative.
[in] | x | The variable to take the derivative to. |
|
inlinevirtual |
Evaluate method.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Get the base of a power.
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Get the exponent of a power.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Test if node acts like a variable.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Test if the node acts like a power of variable.
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Reduction method.
For basic nodes, there's nothing to reduce.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Set the value of variable data.
[in] | d | Vector data to set. |
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Set the value of variable data.
[in] | index | Index to place the value at. |
[in] | d | Scalar data to set. |
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Set the value of variable data.
[in] | d | Vector data to set. |
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Set the value of variable data.
[in] | d | Scalar data to set. |
Reimplemented from graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Convert the node to latex.
Implements graph::leaf_node< T, SAFE_MATH >.
|
inlinevirtual |
Convert the node to vizgraph.
[in,out] | stream | String buffer stream. |
[in,out] | registers | List of defined registers. |
Implements graph::leaf_node< T, SAFE_MATH >.