Vita
real.h
Go to the documentation of this file.
1
13#if !defined(VITA_REAL_PRIMITIVE_H)
14#define VITA_REAL_PRIMITIVE_H
15
16#include <string>
17
18#include "kernel/gp/function.h"
21#include "kernel/gp/terminal.h"
22#include "kernel/random.h"
23#include "utility/utility.h"
24
35namespace vita::real
36{
37
38using base_t = D_DOUBLE;
39
40static_assert(std::numeric_limits<base_t>::is_iec559,
41 "Vita requires IEC 559/IEEE 754 floating-point types");
42
49inline base_t base(const value_t &v)
50{
51 return std::get<base_t>(v);
52}
53
66class real : public terminal
67{
68public:
69 explicit real(const cvect &c, base_t m = -1000.0, base_t u = 1000.0)
70 : terminal("REAL", c[0]), min(m), upp(u)
71 {
72 Expects(c.size() == 1);
73 Expects(m < u);
74 }
75
76 bool parametric() const final { return true; }
77
78 terminal_param_t init() const final { return random::between(min, upp); }
79
80 std::string display(terminal_param_t v, format) const final
81 { return std::to_string(v); }
82
83 value_t eval(symbol_params &p) const final
84 {
85 return static_cast<base_t>(p.fetch_param());
86 }
87
88private:
89 const base_t min, upp;
90};
91
97class integer : public terminal
98{
99public:
100 explicit integer(const cvect &c, int m = -128, int u = 127)
101 : terminal("REAL", c[0]), min(m), upp(u)
102 {
103 Expects(c.size() == 1);
104 Expects(m < u);
105 }
106
107 bool parametric() const final { return true; }
108
109 terminal_param_t init() const final { return random::between(min, upp); }
110
111 std::string display(terminal_param_t v, format) const final
112 { return std::to_string(static_cast<int>(v)); }
113
114 value_t eval(symbol_params &p) const final
115 {
116 return static_cast<base_t>(p.fetch_param());
117 }
118
119private:
120 const int min, upp;
121};
122
126class abs : public function
127{
128public:
129 explicit abs(const cvect &c = {0}) : function("FABS", c[0], {c[0]})
130 { Expects(c.size() == 1); }
131
132 std::string display(format f) const final
133 {
134 switch (f)
135 {
136 case cpp_format: return "std::abs(%%1%%)";
137 case mql_format: return "MathAbs(%%1%%)";
138 case python_format: return "abs(%%1%%)";
139 default: return "fabs(%%1%%)";
140 }
141 }
142
143 value_t eval(symbol_params &args) const final
144 {
145 const auto a(args[0]);
146 return has_value(a) ? std::fabs(base(a)) : a;
147 }
148};
149
153class add : public function
154{
155public:
156 explicit add(const cvect &c = {0}) : function("FADD", c[0], {c[0], c[0]}) {}
157
158 bool associative() const final { return true; }
159
160 std::string display(format) const final
161 {
162 return "(%%1%%+%%2%%)";
163 }
164
165 value_t eval(symbol_params &args) const final
166 {
167 const auto a0(args[0]);
168 if (!has_value(a0)) return a0;
169
170 const auto a1(args[1]);
171 if (!has_value(a1)) return a1;
172
173 const base_t ret(base(a0) + base(a1));
174 if (!std::isfinite(ret)) return {};
175
176 return ret;
177 }
178};
179
189class aq : public function
190{
191public:
192 explicit aq(const cvect &c = {0}) : function("AQ", c[0], {c[0], c[0]})
193 { Expects(c.size() == 1); }
194
195 std::string display(format f) const final
196 {
197 switch (f)
198 {
199 case cpp_format: return "(%%1%%/std::sqrt(1.0+std::pow(%%2%%,2.0)))";
200 case mql_format: return "(%%1%%/MathSqrt(1+MathPow(%%2%%,2)))";
201 default: return "(%%1%%/sqrt(1.0+pow(%%2%%,2.0)))";
202 }
203 }
204
205 value_t eval(symbol_params &args) const final
206 {
207 const auto a0(args[0]);
208 if (!has_value(a0)) return a0;
209
210 const auto a1(args[1]);
211 if (!has_value(a1)) return a1;
212
213 const auto x(base(a0)), y(base(a1));
214 const base_t ret(x / std::sqrt(1.0 + y * y));
215 if (!std::isfinite(ret)) return {};
216
217 return ret;
218 }
219};
220
224class cos : public function
225{
226public:
227 explicit cos(const cvect &c = {0}) : function("FCOS", c[0], {c[0]})
228 { Expects(c.size() == 1); }
229
230 std::string display(format f) const final
231 {
232 switch (f)
233 {
234 case cpp_format: return "std::cos(%%1%%)";
235 case mql_format: return "MathCos(%%1%%)";
236 default: return "cos(%%1%%)";
237 }
238 }
239
240 value_t eval(symbol_params &args) const final
241 {
242 const auto a(args[0]);
243 if (!has_value(a)) return a;
244
245 return std::cos(base(a));
246 }
247};
248
252class div : public function
253{
254public:
255 explicit div(const cvect &c = {0}) : function("FDIV", c[0], {c[0], c[0]})
256 { Expects(c.size() == 1); }
257
258 std::string display(format) const final
259 {
260 return "(%%1%%/%%2%%)";
261 }
262
263 value_t eval(symbol_params &args) const final
264 {
265 const auto a0(args[0]);
266 if (!has_value(a0)) return a0;
267
268 const auto a1(args[1]);
269 if (!has_value(a1)) return a1;
270
271 const base_t ret(base(a0) / base(a1));
272 if (!std::isfinite(ret)) return {};
273
274 return ret;
275 }
276};
277
281class gt : public function
282{
283public:
284 explicit gt(const cvect &c = {0, 0}) : function(">", c[1], {c[0], c[0]})
285 { Expects(c.size() == 2); }
286
287 std::string display(format f) const final
288 {
289 switch (f)
290 {
291 case cpp_format: return "std::isgreater(%%1%%,%%2%%)";
292 default: return "(%%1%%>%%2%%)";
293 }
294 }
295
296 value_t eval(symbol_params &args) const final
297 {
298 const auto a0(args[0]);
299 if (!has_value(a0)) return a0;
300
301 const auto a1(args[1]);
302 if (!has_value(a1)) return a1;
303
304 return std::isgreater(base(a0), base(a1));
305 // If one or both arguments of isgreater are NaN, the function returns
306 // `false`, but no FE_INVALID exception is raised (note that the
307 // expression `v0 < v1` may raise an exception in this case).
308 }
309};
310
314class idiv : public function
315{
316public:
317 explicit idiv(const cvect &c = {0}) : function("FIDIV", c[0], {c[0], c[0]})
318 { Expects(c.size() == 1); }
319
320 std::string display(format f) const final
321 {
322 switch (f)
323 {
324 case cpp_format: return "std::floor(%%1%%/%%2%%)";
325 case mql_format: return "MathFloor(%%1%%/%%2%%)";
326 case python_format: return "(%%1%%//%%2%%)";
327 default: return "floor(%%1%%/%%2%%)";
328 }
329 }
330
331 value_t eval(symbol_params &args) const final
332 {
333 const auto a0(args[0]);
334 if (!has_value(a0)) return a0;
335
336 const auto a1(args[1]);
337 if (!has_value(a1)) return a1;
338
339 const base_t ret(std::floor(base(a0) / base(a1)));
340 if (!std::isfinite(ret)) return {};
341
342 return ret;
343 }
344};
345
351class ifb : public function
352{
353public:
354 explicit ifb(const cvect &c = {0, 0})
355 : function("FIFB", c[1], {c[0], c[0], c[0], c[1], c[1]})
356 { Expects(c.size() == 2); }
357
358 std::string display(format f) const final
359 {
360 switch (f)
361 {
362 case python_format:
363 return "(%%4%% if %%2%% <= %%1%% <= %%3%% else %%5%%)";
364 default:
365 return "(fmin(%%2%%,%%3%%) <= %%1%% && %%1%% <= fmax(%%2%%,%%3%%) ?"
366 "%%4%% : %%5%%)";
367 }
368 }
369
370 value_t eval(symbol_params &args) const final
371 {
372 const auto a0(args[0]);
373 if (!has_value(a0)) return a0;
374
375 const auto a1(args[1]);
376 if (!has_value(a1)) return a1;
377
378 const auto a2(args[2]);
379 if (!has_value(a2)) return a2;
380
381 const auto v0(base(a0));
382 const auto v1(base(a1));
383 const auto v2(base(a2));
384
385 const auto min(std::fmin(v1, v2));
386 const auto max(std::fmax(v1, v2));
387
388 if (std::isless(v0, min) || std::isgreater(v0, max))
389 return args[4];
390 else
391 return args[3];
392 }
393};
394
398class ife : public function
399{
400public:
401 explicit ife(const cvect &c = {0, 0})
402 : function("FIFE", c[1], {c[0], c[0], c[1], c[1]})
403 { Expects(c.size() == 2); }
404
405 std::string display(format f) const final
406 {
407 switch (f)
408 {
409 case cpp_format:
410 return "(std::fabs(%%1%%-%%2%%)<2*std::numeric_limits<double>::epsilon()"
411 "? %%3%% : %%4%%)";
412 case mql_format:
413 return "(NormalizeDouble(%%1%%-%%2%%,8)==0 ? %%3%% : %%4%%)";
414 case python_format:
415 return "(%%3%% if isclose(%%1%%,%%2%%) else %%4%%)";
416 default:
417 return "(fabs(%%1%%-%%2%%)<2*DBL_EPSILON ? %%3%% : %%4%%)";
418 }
419 }
420
421 value_t eval(symbol_params &args) const final
422 {
423 const auto a0(args[0]);
424 if (!has_value(a0)) return a0;
425
426 const auto a1(args[1]);
427 if (!has_value(a1)) return a1;
428
429 if (issmall(base(a0) - base(a1)))
430 return args[2];
431 else
432 return args[3];
433 }
434
435 double penalty_nvi(core_interpreter *ci) const final
436 {
438 }
439};
440
444class ifl : public function
445{
446public:
447 explicit ifl(const cvect &c = {0, 0})
448 : function("FIFL", c[1], {c[0], c[0], c[1], c[1]})
449 { Expects(c.size() == 2); }
450
451 std::string display(format f) const final
452 {
453 switch (f)
454 {
455 case python_format: return "(%%3%% if %%1%%<%%2%% else %%4%%)";
456 default: return "(%%1%%<%%2%% ? %%3%% : %%4%%)";
457 }
458 }
459
460 value_t eval(symbol_params &args) const final
461 {
462 const auto a0(args[0]);
463 if (!has_value(a0)) return a0;
464
465 const auto a1(args[1]);
466 if (!has_value(a1)) return a1;
467
468 const auto v0(base(a0)), v1(base(a1));
469 if (std::isless(v0, v1))
470 return args[2];
471 else
472 return args[3];
473 }
474
475 double penalty_nvi(core_interpreter *ci) const final
476 {
478 }
479};
480
484class ifz : public function
485{
486public:
487 explicit ifz(const cvect &c = {0})
488 : function("FIFZ", c[0], {c[0], c[0], c[0]})
489 { Expects(c.size() == 1); }
490
491 std::string display(format f) const final
492 {
493 switch (f)
494 {
495 case cpp_format:
496 return "(std::fabs(%%1%%)<2*std::numeric_limits<double>::epsilon() ? "
497 "%%2%% : %%3%%)";
498 case mql_format:
499 return "(NormalizeDouble(%%1%%,8)==0 ? %%2%% : %%3%%)";
500 case python_format:
501 return "(%%2%% if abs(%%1%%) < 1e-10 else %%3%%)";
502 default:
503 return "(fabs(%%1%%)<2*DBL_EPSILON ? %%2%% : %%3%%)";
504 }
505 }
506
507 value_t eval(symbol_params &args) const final
508 {
509 const auto a0(args[0]);
510 if (!has_value(a0)) return a0;
511
512 if (issmall(base(a0)))
513 return args[1];
514 else
515 return args[2];
516 }
517};
518
522class length : public function
523{
524public:
525 explicit length(const cvect &c = {0, 0}) : function("FLENGTH", c[1], {c[0]})
526 { Expects(c.size() == 2); }
527
528 std::string display(format f) const final
529 {
530 switch (f)
531 {
532 case cpp_format: return "std::string(%%1%%).length()";
533 case mql_format: return "StringLen(%%1%%)";
534 case python_format: return "len(%%1%%)";
535 default: return "strlen(%%1%%)";
536 }
537 }
538
539 value_t eval(symbol_params &args) const final
540 {
541 const auto a(args[0]);
542 if (!has_value(a)) return a;
543
544 return static_cast<base_t>(std::get<D_STRING>(a).length());
545 }
546};
547
551class ln : public function
552{
553public:
554 explicit ln(const cvect &c = {0}) : function("FLN", c[0], {c[0]})
555 { Expects(c.size() == 1); }
556
557 std::string display(format f) const final
558 {
559 switch (f)
560 {
561 case cpp_format: return "std::log(%%1%%)";
562 case mql_format: return "MathLog(%%1%%)";
563 default: return "log(%%1%%)";
564 }
565 }
566
572 value_t eval(symbol_params &args) const final
573 {
574 const auto a0(args[0]);
575 if (!has_value(a0)) return a0;
576
577 const auto ret(std::log(base(a0)));
578 if (!std::isfinite(ret)) return {};
579
580 return ret;
581 }
582};
583
587class lt : public function
588{
589public:
590 explicit lt(const cvect &c = {0, 0}) : function("<", c[1], {c[0], c[0]})
591 { Expects(c.size() == 2); }
592
593 std::string display(format f) const final
594 {
595 switch (f)
596 {
597 case cpp_format: return "std::isless(%%1%%,%%2%%)";
598 default: return "(%%1%%<%%2%%)";
599 }
600 }
601
602 value_t eval(symbol_params &args) const final
603 {
604 const auto a0(args[0]);
605 if (!has_value(a0)) return a0;
606
607 const auto a1(args[1]);
608 if (!has_value(a1)) return a1;
609
610 return std::isless(base(a0), base(a1));
611 // If one or both arguments of `isless` are NaN, the function returns
612 // false, but no FE_INVALID exception is raised (note that the
613 // expression `v0 < v1` may raise an exception in this case).
614 }
615};
616
620class max : public function
621{
622public:
623 explicit max(const cvect &c = {0}) : function("FMAX", c[0], {c[0], c[0]})
624 { Expects(c.size() == 1); }
625
626 std::string display(format f) const final
627 {
628 switch (f)
629 {
630 case cpp_format: return "std::fmax(%%1%%,%%2%%)";
631 case python_format: return "max(%%1%%,%%2%%)";
632 default: return "fmax(%%1%%,%%2%%)";
633 }
634 }
635
636 value_t eval(symbol_params &args) const final
637 {
638 const auto a0(args[0]);
639 if (!has_value(a0)) return a0;
640
641 const auto a1(args[1]);
642 if (!has_value(a1)) return a1;
643
644 const base_t ret(std::fmax(base(a0), base(a1)));
645 if (!std::isfinite(ret)) return {};
646
647 return ret;
648 }
649};
650
654class mod : public function
655{
656public:
657 explicit mod(const cvect &c = {0}) : function("FMOD", c[0], {c[0], c[0]})
658 { Expects(c.size() == 1); }
659
660 std::string display(format f) const final
661 {
662 switch (f)
663 {
664 case cpp_format: return "std::fmod(%%1%%,%%2%%)";
665 case mql_format: return "MathMod(%%1%%,%%2%%)";
666 case python_format: return "(%%1%% % %%2%%)";
667 default: return "fmod(%%1%%,%%2%%)";
668 }
669 }
670
671 value_t eval(symbol_params &args) const final
672 {
673 const auto a0(args[0]);
674 if (!has_value(a0)) return a0;
675
676 const auto a1(args[1]);
677 if (!has_value(a1)) return a1;
678
679 const base_t ret(std::fmod(base(a0), base(a1)));
680 if (!std::isfinite(ret)) return {};
681
682 return ret;
683 }
684};
685
689class mul : public function
690{
691public:
692 explicit mul(const cvect &c = {0}) : function("FMUL", c[0], {c[0], c[0]})
693 { Expects(c.size() == 1); }
694
695 std::string display(format) const final
696 {
697 return "(%%1%%*%%2%%)";
698 }
699
700 value_t eval(symbol_params &args) const final
701 {
702 const auto a0(args[0]);
703 if (!has_value(a0)) return a0;
704
705 const auto a1(args[1]);
706 if (!has_value(a1)) return a1;
707
708 const base_t ret(base(a0) * base(a1));
709 if (!std::isfinite(ret)) return {};
710
711 return ret;
712 }
713};
714
718class sin : public function
719{
720public:
721 explicit sin(const cvect &c = {0}) : function("FSIN", c[0], {c[0]})
722 { Expects(c.size() == 1); }
723
724 std::string display(format f) const final
725 {
726 switch (f)
727 {
728 case cpp_format: return "std::sin(%%1%%)";
729 case mql_format: return "MathSin(%%1%%)";
730 default: return "sin(%%1%%)";
731 }
732 }
733
734 value_t eval(symbol_params &args) const final
735 {
736 const auto a(args[0]);
737 if (!has_value(a)) return a;
738
739 return std::sin(base(a));
740 }
741};
742
746class sqrt : public function
747{
748public:
749 explicit sqrt(const cvect &c = {0}) : function("FSQRT", c[0], {c[0]})
750 { Expects(c.size() == 1); }
751
752 std::string display(format f) const final
753 {
754 switch (f)
755 {
756 case cpp_format: return "std::sqrt(%%1%%)";
757 case mql_format: return "MathSqrt(%%1%%)";
758 default: return "sqrt(%%1%%)";
759 }
760 }
761
762 value_t eval(symbol_params &args) const final
763 {
764 const auto a(args[0]);
765 if (!has_value(a)) return a;
766
767 const auto v(base(a));
768 if (std::isless(v, 0.0))
769 return {};
770
771 return std::sqrt(v);
772 }
773};
774
778class sub : public function
779{
780public:
781 explicit sub(const cvect &c = {0}) : function("FSUB", c[0], {c[0], c[0]})
782 { Expects(c.size() == 1); }
783
784 std::string display(format) const final
785 {
786 return "(%%1%%-%%2%%)";
787 }
788
789 value_t eval(symbol_params &args) const final
790 {
791 const auto a0(args[0]);
792 if (!has_value(a0)) return a0;
793
794 const auto a1(args[1]);
795 if (!has_value(a1)) return a1;
796
797 const base_t ret(base(a0) - base(a1));
798 if (!std::isfinite(ret)) return {};
799
800 return ret;
801 }
802};
803
804
808class sigmoid : public function
809{
810public:
811 explicit sigmoid(const cvect &c = {0}) : function("FSIGMOID", c[0], {c[0]})
812 { Expects(c.size() == 1); }
813
814 std::string display(format f) const final
815 {
816 switch (f)
817 {
818 case cpp_format: return "1.0 / (1.0 + std::exp(-%%1%%))";
819 case mql_format: return "1.0 / (1.0 + MathExp(-%%1%%))";
820 case python_format: return "1. / (1. + math.exp(-%%1%%))";
821 default: return "1 / (1 + exp(-%%1%%))";
822 }
823 }
824
825 value_t eval(symbol_params &args) const final
826 {
827 const auto a0(args[0]);
828 if (!has_value(a0)) return a0;
829
830 // The sigmoid function can be expressed in one of two equivalent ways:
831 // sigmoid(x) = 1 / (1 + exp(-x)) = exp(x) / (exp(x) + 1)
832 // Each version can be used in order to avoid numerical overflow in extreme
833 // cases (`x --> +inf` and `x --> -inf` respectively).
834 const auto x(base(a0));
835 if (x >= 0.0)
836 return 1.0 / (1.0 + std::exp(-x));
837
838 return std::exp(x) / (1.0 + std::exp(x));
839 }
840};
841
842} // namespace vita::real
843
844#endif // include guard
Minimum interface of an interpreter.
A symbol with arity() > 0.
Definition: function.h:35
function(const std::string &, category_t, cvect)
Definition: function.cc:25
The absolute value of a real number.
Definition: real.h:127
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:143
std::string display(format f) const final
Definition: real.h:132
Sum of two real numbers.
Definition: real.h:154
bool associative() const final
Is the symbol subject to the associative law of arithmetic?
Definition: real.h:158
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:165
std::string display(format) const final
Definition: real.h:160
Analytic quotient (AQ).
Definition: real.h:190
std::string display(format f) const final
Definition: real.h:195
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:205
cos() of a real number.
Definition: real.h:225
std::string display(format f) const final
Definition: real.h:230
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:240
Unprotected division (UPD) between two real numbers.
Definition: real.h:253
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:263
std::string display(format) const final
Definition: real.h:258
"Greater Than" operator.
Definition: real.h:282
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:296
std::string display(format f) const final
Definition: real.h:287
Quotient of the division between two real numbers.
Definition: real.h:315
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:331
std::string display(format f) const final
Definition: real.h:320
"If between" operator.
Definition: real.h:352
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:370
std::string display(format f) const final
Definition: real.h:358
"If equal" operator.
Definition: real.h:399
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:421
double penalty_nvi(core_interpreter *ci) const final
Definition: real.h:435
std::string display(format f) const final
Definition: real.h:405
"If less then" operator.
Definition: real.h:445
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:460
std::string display(format f) const final
Definition: real.h:451
double penalty_nvi(core_interpreter *ci) const final
Definition: real.h:475
"If zero" operator.
Definition: real.h:485
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:507
std::string display(format f) const final
Definition: real.h:491
Ephemeral random integer constant.
Definition: real.h:98
value_t eval(symbol_params &p) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:114
bool parametric() const final
A parametric terminal needs an additional parameter to be evaluated.
Definition: real.h:107
terminal_param_t init() const final
Used to initialize the internal parameter of the terminal.
Definition: real.h:109
std::string display(terminal_param_t v, format) const final
Definition: real.h:111
Length of a string.
Definition: real.h:523
std::string display(format f) const final
Definition: real.h:528
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:539
Natural logarithm of a real number.
Definition: real.h:552
value_t eval(symbol_params &args) const final
Definition: real.h:572
std::string display(format f) const final
Definition: real.h:557
"Less Then" operator.
Definition: real.h:588
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:602
std::string display(format f) const final
Definition: real.h:593
The larger of two floating point values.
Definition: real.h:621
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:636
std::string display(format f) const final
Definition: real.h:626
Remainder of the division between real numbers.
Definition: real.h:655
std::string display(format f) const final
Definition: real.h:660
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:671
Product of real numbers.
Definition: real.h:690
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:700
std::string display(format) const final
Definition: real.h:695
Ephemeral random constant.
Definition: real.h:67
terminal_param_t init() const final
Used to initialize the internal parameter of the terminal.
Definition: real.h:78
bool parametric() const final
A parametric terminal needs an additional parameter to be evaluated.
Definition: real.h:76
std::string display(terminal_param_t v, format) const final
Definition: real.h:80
value_t eval(symbol_params &p) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:83
Sigmoid function.
Definition: real.h:809
std::string display(format f) const final
Definition: real.h:814
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:825
sin() of a real number.
Definition: real.h:719
std::string display(format f) const final
Definition: real.h:724
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:734
Square root of a real number.
Definition: real.h:747
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:762
std::string display(format f) const final
Definition: real.h:752
Subtraction between real numbers.
Definition: real.h:779
std::string display(format) const final
Definition: real.h:784
value_t eval(symbol_params &args) const final
Calculates the value of / performs the action associated with the symbol (it's implementation specifi...
Definition: real.h:789
An interface for parameter passing to functions / terminals.
format
Symbol rendering format.
Definition: symbol.h:39
bool terminal() const
Definition: symbol.h:153
A symbol with zero-arity.
Definition: terminal.h:27
We assume that errors during floating-point operations aren't terminal errors.
Definition: real.h:36
base_t base(const value_t &v)
A simple shortcut for casting an value_t to base_t.
Definition: real.h:49
double comparison_function_penalty(core_interpreter *ci)
A simple, convenient function for the penalty score of the typical four-terms comparison.
Definition: comp_penalty.h:29
bool has_value(const value_t &v)
Definition: value.h:51
std::variant< D_VOID, D_INT, D_DOUBLE, D_STRING > value_t
A variant containing the data types used by the interpreter for internal calculations / output value ...
Definition: value.h:45