The BioCro C++ Library
hyperbolas.h
Go to the documentation of this file.
1#ifndef HYPERBOLAS_H
2#define HYPERBOLAS_H
3
4#include <cmath> // For pow
5#include "../framework/module.h"
6#include "../framework/state_map.h"
7#include "../framework/constants.h"
8
9namespace standardBML
10{
18class golden_ratio_hyperbola : public direct_module
19{
20 public:
22 state_map const& input_quantities,
23 state_map* output_quantities)
24 : direct_module{},
25
26 // Get pointers to input quantities
27 x_ip{get_ip(input_quantities, "x")},
28
29 // Get pointers to output quantities
30 x_op{get_op(output_quantities, "x")}
31
32 {
33 }
34 static string_vector get_inputs();
35 static string_vector get_outputs();
36 static std::string get_name() { return "golden_ratio_hyperbola"; }
37
38 private:
39 // Pointers to input quantities
40 const double* x_ip;
41
42 // Pointers to output quantities
43 double* x_op;
44
45 // Main operation
46 void do_operation() const override;
47};
48
50{
51 return {
52 "x" // unitless
53 };
54}
55
57{
58 return {
59 "x" // unitless
60 };
61}
62
63void golden_ratio_hyperbola::do_operation() const
64{
65 update(x_op, 1 + 1 / *x_ip);
66}
67
75class hyperbola_2d : public direct_module
76{
77 public:
79 state_map const& input_quantities,
80 state_map* output_quantities)
81 : direct_module{},
82
83 // Get pointers to input quantities
84 x_ip{get_ip(input_quantities, "x")},
85 y_ip{get_ip(input_quantities, "y")},
86
87 // Get pointers to output quantities
88 x_op{get_op(output_quantities, "x")},
89 y_op{get_op(output_quantities, "y")}
90
91 {
92 }
93 static string_vector get_inputs();
94 static string_vector get_outputs();
95 static std::string get_name() { return "hyperbola_2d"; }
96
97 private:
98 // Pointers to input quantities
99 const double* x_ip;
100 const double* y_ip;
101
102 // Pointers to output quantities
103 double* x_op;
104 double* y_op;
105
106 // Main operation
107 void do_operation() const override;
108};
109
111{
112 return {
113 "x", // unitless
114 "y" // unitless
115 };
116}
117
119{
120 return {
121 "x", // unitless
122 "y" // unitless
123 };
124}
125
126void hyperbola_2d::do_operation() const
127{
128 update(x_op, 1 + 1 / (*x_ip + *y_ip));
129 update(y_op, 1 + 1 / (2 * *x_ip - *y_ip));
130}
131
132} // namespace standardBML
133#endif
Represents a simple hyperbola defined by f(x) = 1 + 1 / x. Intended to be used as a simple test case ...
Definition: hyperbolas.h:19
static string_vector get_outputs()
Definition: hyperbolas.h:56
static string_vector get_inputs()
Definition: hyperbolas.h:49
static std::string get_name()
Definition: hyperbolas.h:36
golden_ratio_hyperbola(state_map const &input_quantities, state_map *output_quantities)
Definition: hyperbolas.h:21
Represents two 2D hyperbolas defined by f(x,y) = 1 + 1 / (x + y) and g(x,y) = 1 + 1 / (2x - y)....
Definition: hyperbolas.h:76
hyperbola_2d(state_map const &input_quantities, state_map *output_quantities)
Definition: hyperbolas.h:78
static string_vector get_outputs()
Definition: hyperbolas.h:118
static string_vector get_inputs()
Definition: hyperbolas.h:110
static std::string get_name()
Definition: hyperbolas.h:95
This is the standard BioCro module library; it includes the essential modules used in typical BioCro ...
Definition: aba_decay.h:8