Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ExternalRandomVariable Class Reference

#include <qle/ad/external_randomvariable_ops.hpp>

+ Collaboration diagram for ExternalRandomVariable:

Public Member Functions

 ExternalRandomVariable ()
 
 ExternalRandomVariable (std::size_t id)
 
 ExternalRandomVariable (double v)
 
 ExternalRandomVariable (const std::size_t randomVariableOpCode, const std::vector< const ExternalRandomVariable * > &args)
 
void clear ()
 
bool initialised () const
 
void declareAsOutput () const
 
std::size_t id () const
 

Static Public Attributes

static std::function< void(ExternalRandomVariable &)> deleter
 

Private Attributes

bool initialized_ = false
 
double v_
 
std::size_t id_
 

Detailed Description

Definition at line 29 of file external_randomvariable_ops.hpp.

Constructor & Destructor Documentation

◆ ExternalRandomVariable() [1/4]

Definition at line 31 of file external_randomvariable_ops.hpp.

31{}

◆ ExternalRandomVariable() [2/4]

ExternalRandomVariable ( std::size_t  id)
explicit

◆ ExternalRandomVariable() [3/4]

ExternalRandomVariable ( double  v)
explicit

Definition at line 27 of file external_randomvariable_ops.cpp.

27 : initialized_(true), v_(v) {
28 id_ = ComputeEnvironment::instance().context().createInputVariable(v);
29}

◆ ExternalRandomVariable() [4/4]

ExternalRandomVariable ( const std::size_t  randomVariableOpCode,
const std::vector< const ExternalRandomVariable * > &  args 
)

Definition at line 31 of file external_randomvariable_ops.cpp.

32 {
33 std::vector<std::size_t> argIds(args.size());
34 std::transform(args.begin(), args.end(), argIds.begin(), [](const ExternalRandomVariable* v) { return v->id(); });
35 id_ = ComputeEnvironment::instance().context().applyOperation(randomVariableOpCode, argIds);
36 initialized_ = true;
37}

Member Function Documentation

◆ clear()

void clear ( )

Definition at line 39 of file external_randomvariable_ops.cpp.

39 {
40 QL_REQUIRE(initialized_, "ExternalRandomVariable::clear(): not initialized");
41 ComputeEnvironment::instance().context().freeVariable(id_);
42 initialized_ = false;
43}

◆ initialised()

bool initialised ( ) const

Definition at line 37 of file external_randomvariable_ops.hpp.

37{ return initialized_; }

◆ declareAsOutput()

void declareAsOutput ( ) const

Definition at line 45 of file external_randomvariable_ops.cpp.

45 {
46 QL_REQUIRE(initialized_, "ExternalRandomVariable::declareAsOutput(): not initialized");
47 ComputeEnvironment::instance().context().declareOutputVariable(id_);
48}

◆ id()

std::size_t id ( ) const

Definition at line 50 of file external_randomvariable_ops.cpp.

50 {
51 QL_REQUIRE(initialized_, "ExternalRandomVariable::id(): not initialized");
52 return id_;
53}

Member Data Documentation

◆ deleter

std::function< void(ExternalRandomVariable &)> deleter
static
Initial value:
=
std::function<void(ExternalRandomVariable&)>([](ExternalRandomVariable& x) { x.clear(); })

Definition at line 41 of file external_randomvariable_ops.hpp.

◆ initialized_

bool initialized_ = false
private

Definition at line 44 of file external_randomvariable_ops.hpp.

◆ v_

double v_
private

Definition at line 45 of file external_randomvariable_ops.hpp.

◆ id_

std::size_t id_
private

Definition at line 46 of file external_randomvariable_ops.hpp.