Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
external_randomvariable_ops.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/ad/external_randomvariable_ops.hpp
20 \brief ops for external randomvariables
21*/
22
23#pragma once
24
26
27namespace QuantExt {
28
30public:
32 explicit ExternalRandomVariable(std::size_t id);
33 explicit ExternalRandomVariable(double v);
34 ExternalRandomVariable(const std::size_t randomVariableOpCode,
35 const std::vector<const ExternalRandomVariable*>& args);
36 void clear();
37 bool initialised() const { return initialized_; }
38 void declareAsOutput() const;
39 std::size_t id() const;
40
41 static std::function<void(ExternalRandomVariable&)> deleter;
42
43private:
44 bool initialized_ = false;
45 double v_;
46 std::size_t id_;
47};
48
49// is the given random variable deterministic and zero?
51 return false;
52}
53
55 std::function<ExternalRandomVariable(const std::vector<const ExternalRandomVariable*>&)>;
56
57std::vector<ExternalRandomVariableOp> getExternalRandomVariableOps();
58
59using ExternalRandomVariableGrad = std::function<std::vector<ExternalRandomVariable>(
60 const std::vector<const ExternalRandomVariable*>&, const ExternalRandomVariable*)>;
61
62std::vector<ExternalRandomVariableGrad> getExternalRandomVariableGradients();
63
64
65} // namespace QuantExt
static std::function< void(ExternalRandomVariable &)> deleter
std::function< std::vector< ExternalRandomVariable >(const std::vector< const ExternalRandomVariable * > &, const ExternalRandomVariable *)> ExternalRandomVariableGrad
std::vector< ExternalRandomVariableOp > getExternalRandomVariableOps()
std::function< ExternalRandomVariable(const std::vector< const ExternalRandomVariable * > &)> ExternalRandomVariableOp
bool isDeterministicAndZero(const ExternalRandomVariable &x)
std::vector< ExternalRandomVariableGrad > getExternalRandomVariableGradients()
ops for type randomvariable