CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
unaryOperators.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <cmath>
38
39#include "../../config.h"
40#include "../../misc/exceptions.hpp"
41#include "../../misc/macros.hpp"
42#include "../../traits/realTraits.hpp"
43#include "../computeExpression.hpp"
44
46namespace codi {
47
48 /*******************************************************************************/
51
53 template<typename T_Real>
54 struct OperationUnaryMinus : public UnaryJacobianOperation<T_Real, OperationUnaryMinus<T_Real>> {
55 public:
56
57 using Real = CODI_DD(T_Real, double);
58
60 template<typename Arg>
61 static CODI_INLINE Real primal(Arg const& arg) {
62 return -arg;
63 }
64
66 template<typename Arg>
67 static CODI_INLINE RealTraits::PassiveReal<Real> gradient(Arg const& arg, Real const& result) {
69 CODI_UNUSED(result);
70 return -1.0;
71 }
72
74 static CODI_INLINE std::string getMathRep() {
75 return "-";
76 }
77 };
78#define OPERATION_LOGIC OperationUnaryMinus
79#define FUNCTION operator-
80#include "unaryOverloads.tpp"
81
83 template<typename Real, typename Arg>
87
89 /*******************************************************************************/
92
93 using std::abs;
94 using std::acos;
95 using std::acosh;
96 using std::asin;
97 using std::asinh;
98 using std::atan;
99 using std::atanh;
100 using std::cbrt;
101 using std::ceil;
102 using std::cos;
103 using std::cosh;
104 using std::erf;
105 using std::erfc;
106 using std::exp;
107 using std::fabs;
108 using std::floor;
109 using std::isfinite;
110 using std::isinf;
111 using std::isnan;
112 using std::isnormal;
113 using std::log;
114 using std::log10;
115 using std::log1p;
116 using std::log2;
117 using std::round;
118 using std::sin;
119 using std::sinh;
120 using std::sqrt;
121 using std::tan;
122 using std::tanh;
123 using std::tgamma;
124
126 template<typename T_Real>
127 struct OperationAbs : public UnaryJacobianOperation<T_Real, OperationAbs<T_Real>> {
128 public:
129
130 using Real = CODI_DD(T_Real, double);
131
133 template<typename Arg>
134 static CODI_INLINE Real primal(Arg const& arg) {
135 return abs(arg);
136 }
137
139 template<typename Arg>
140 static CODI_INLINE RealTraits::PassiveReal<Real> gradient(Arg const& arg, Real const& result) {
141 CODI_UNUSED(result);
142 if (arg < 0.0) {
143 return -1.0;
144 } else if (arg > 0.0) {
145 return 1.0;
146 } else {
147 return 0.0;
148 }
149 }
150
152 static CODI_INLINE std::string getMathRep() {
153 return "abs";
154 }
155 };
156#define OPERATION_LOGIC OperationAbs
157#define FUNCTION abs
158#include "unaryOverloads.tpp"
159
160#define OPERATION_LOGIC OperationAbs
161#define FUNCTION fabs
162#include "unaryOverloads.tpp"
163
164#define OPERATION_LOGIC OperationAbs
165#define FUNCTION fabsf
166#include "unaryOverloads.tpp"
167
168#define OPERATION_LOGIC OperationAbs
169#define FUNCTION fabsl
170#include "unaryOverloads.tpp"
171
173 template<typename T_Real>
174 struct OperationAcos : public UnaryJacobianOperation<T_Real, OperationAcos<T_Real>> {
175 public:
176
177 using Real = CODI_DD(T_Real, double);
178
180 template<typename Arg>
181 static CODI_INLINE Real primal(Arg const& arg) {
182 return acos(arg);
183 }
184
186 template<typename Arg>
187 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
188 CODI_UNUSED(result);
190 checkArgument(arg);
191 }
192 return -1.0 / sqrt(1.0 - arg * arg);
193 }
194
196 static CODI_INLINE std::string getMathRep() {
197 return "acos";
198 }
199
200 private:
201
202 template<typename Arg>
203 CODI_INLINE static void checkArgument(Arg const& arg) {
205 CODI_EXCEPTION("Argument of acos outside of (-1, 1). (Value: %0.15e)", RealTraits::getPassiveValue(arg));
206 }
207 }
208
209 template<typename Arg>
210 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
211 if (0.0 == RealTraits::getPassiveValue(imag(arg)) &&
213 CODI_EXCEPTION("Argument of acos outside of C \\ {-1, 1}. (Value: %0.15e + %0.15e i)",
215 }
216 }
217 };
218#define OPERATION_LOGIC OperationAcos
219#define FUNCTION acos
220#include "unaryOverloads.tpp"
221
222#define OPERATION_LOGIC OperationAcos
223#define FUNCTION acosf
224#include "unaryOverloads.tpp"
225
226#define OPERATION_LOGIC OperationAcos
227#define FUNCTION acosl
228#include "unaryOverloads.tpp"
229
231 template<typename T_Real>
232 struct OperationAcosh : public UnaryJacobianOperation<T_Real, OperationAcosh<T_Real>> {
233 public:
234
235 using Real = CODI_DD(T_Real, double);
236
238 template<typename Arg>
239 static CODI_INLINE Real primal(Arg const& arg) {
240 return acosh(arg);
241 }
242
244 template<typename Arg>
245 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
246 CODI_UNUSED(result);
248 checkArgument(arg);
249 }
250 return 1.0 / (sqrt(arg + 1.0) * sqrt(arg - 1.0));
251 }
252
254 static CODI_INLINE std::string getMathRep() {
255 return "acosh";
256 }
257
258 private:
259
260 template<typename Arg>
261 CODI_INLINE static void checkArgument(Arg const& arg) {
262 if (RealTraits::getPassiveValue(arg) > 1.0) {
263 CODI_EXCEPTION("Argument of acosh outside of (1, inf). (Value: %0.15e)", RealTraits::getPassiveValue(arg));
264 }
265 }
266
267 template<typename Arg>
268 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
270 CODI_EXCEPTION("Argument of acosh outside of C \\ {1, -1}. (Value: %0.15e + %0.15e i)",
272 }
273 }
274 };
275#define OPERATION_LOGIC OperationAcosh
276#define FUNCTION acosh
277#include "unaryOverloads.tpp"
278
279#define OPERATION_LOGIC OperationAcosh
280#define FUNCTION acoshf
281#include "unaryOverloads.tpp"
282
283#define OPERATION_LOGIC OperationAcosh
284#define FUNCTION acoshl
285#include "unaryOverloads.tpp"
286
288 template<typename T_Real>
289 struct OperationAsin : public UnaryJacobianOperation<T_Real, OperationAsin<T_Real>> {
290 public:
291
292 using Real = CODI_DD(T_Real, double);
293
295 template<typename Arg>
296 static CODI_INLINE Real primal(Arg const& arg) {
297 return asin(arg);
298 }
299
301 template<typename Arg>
302 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
303 CODI_UNUSED(result);
305 checkArgument(arg);
306 }
307 return 1.0 / sqrt(1.0 - arg * arg);
308 }
309
311 static CODI_INLINE std::string getMathRep() {
312 return "asin";
313 }
314
315 private:
316
317 template<typename Arg>
318 CODI_INLINE static void checkArgument(Arg const& arg) {
320 CODI_EXCEPTION("Argument of asin outside of (-1, 1). (Value: %0.15e)", RealTraits::getPassiveValue(arg));
321 }
322 }
323
324 template<typename Arg>
325 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
326 if (0.0 == RealTraits::getPassiveValue(imag(arg)) &&
328 CODI_EXCEPTION("Argument of asin outside of C \\ {1, -1}. (Value: %0.15e + %0.15e i)",
330 }
331 }
332 };
333#define OPERATION_LOGIC OperationAsin
334#define FUNCTION asin
335#include "unaryOverloads.tpp"
336
337#define OPERATION_LOGIC OperationAsin
338#define FUNCTION asinf
339#include "unaryOverloads.tpp"
340
341#define OPERATION_LOGIC OperationAsin
342#define FUNCTION asinl
343#include "unaryOverloads.tpp"
344
346 template<typename T_Real>
347 struct OperationAsinh : public UnaryJacobianOperation<T_Real, OperationAsinh<T_Real>> {
348 public:
349
350 using Real = CODI_DD(T_Real, double);
351
353 template<typename Arg>
354 static CODI_INLINE Real primal(Arg const& arg) {
355 return asinh(arg);
356 }
357
359 template<typename Arg>
360 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
361 CODI_UNUSED(result);
362
364 checkArgument(arg);
365 }
366
367 return 1.0 / sqrt(arg * arg + 1.0);
368 }
369
371 static CODI_INLINE std::string getMathRep() {
372 return "asinh";
373 }
374
375 private:
376
377 template<typename Arg>
378 CODI_INLINE static void checkArgument(Arg const& arg) {
380 // Nothing to check.
381 }
382
383 template<typename Arg>
384 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
386 CODI_EXCEPTION("Argument of asinh outside of C \\ {i, -i}. (Value: %0.15e + %0.15e i)",
388 }
389 }
390 };
391#define OPERATION_LOGIC OperationAsinh
392#define FUNCTION asinh
393#include "unaryOverloads.tpp"
394
395#define OPERATION_LOGIC OperationAsinh
396#define FUNCTION asinhf
397#include "unaryOverloads.tpp"
398
399#define OPERATION_LOGIC OperationAsinh
400#define FUNCTION asinhl
401#include "unaryOverloads.tpp"
402
404 template<typename T_Real>
405 struct OperationAtan : public UnaryJacobianOperation<T_Real, OperationAtan<T_Real>> {
406 public:
407
408 using Real = CODI_DD(T_Real, double);
409
411 template<typename Arg>
412 static CODI_INLINE Real primal(Arg const& arg) {
413 return atan(arg);
414 }
415
417 template<typename Arg>
418 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
419 CODI_UNUSED(result);
420
422 checkArgument(arg);
423 }
424
425 return 1.0 / (1.0 + arg * arg);
426 }
427
429 static CODI_INLINE std::string getMathRep() {
430 return "atan";
431 }
432
433 private:
434
435 template<typename Arg>
436 CODI_INLINE static void checkArgument(Arg const& arg) {
438 // Nothing to check.
439 }
440
441 template<typename Arg>
442 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
444 CODI_EXCEPTION("Argument of atan outside of C \\ {i, -i}. (Value: %0.15e + %0.15e i)",
446 }
447 }
448 };
449#define OPERATION_LOGIC OperationAtan
450#define FUNCTION atan
451#include "unaryOverloads.tpp"
452
453#define OPERATION_LOGIC OperationAtan
454#define FUNCTION atanf
455#include "unaryOverloads.tpp"
456
457#define OPERATION_LOGIC OperationAtan
458#define FUNCTION atanl
459#include "unaryOverloads.tpp"
460
462 template<typename T_Real>
463 struct OperationAtanh : public UnaryJacobianOperation<T_Real, OperationAtanh<T_Real>> {
464 public:
465
466 using Real = CODI_DD(T_Real, double);
467
469 template<typename Arg>
470 static CODI_INLINE Real primal(Arg const& arg) {
471 return atanh(arg);
472 }
473
475 template<typename Arg>
476 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
477 CODI_UNUSED(result);
479 checkArgument(arg);
480 }
481 return 1.0 / (1.0 - arg * arg);
482 }
483
485 static CODI_INLINE std::string getMathRep() {
486 return "atanh";
487 }
488
489 private:
490
491 template<typename Arg>
492 CODI_INLINE static void checkArgument(Arg const& arg) {
494 CODI_EXCEPTION("Argument of atanh outside of (-1, 1). (Value: %0.15e)", RealTraits::getPassiveValue(arg));
495 }
496 }
497
498 template<typename Arg>
499 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
500 if (0.0 == RealTraits::getPassiveValue(imag(arg)) &&
502 CODI_EXCEPTION("Argument of atanh outside of C \\ (-1, 1). (Value: %0.15e + %0.15e i)",
504 }
505 }
506 };
507#define OPERATION_LOGIC OperationAtanh
508#define FUNCTION atanh
509#include "unaryOverloads.tpp"
510
511#define OPERATION_LOGIC OperationAtanh
512#define FUNCTION atanhf
513#include "unaryOverloads.tpp"
514
515#define OPERATION_LOGIC OperationAtanh
516#define FUNCTION atanhl
517#include "unaryOverloads.tpp"
518
520 template<typename T_Real>
521 struct OperationCbrt : public UnaryJacobianOperation<T_Real, OperationCbrt<T_Real>> {
522 public:
523
524 using Real = CODI_DD(T_Real, double);
525
527 template<typename Arg>
528 static CODI_INLINE Real primal(Arg const& arg) {
529 return cbrt(arg);
530 }
531
533 template<typename Arg>
534 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
536 if (0.0 == RealTraits::getPassiveValue(arg)) {
537 CODI_EXCEPTION("Cbrt of zero value. (Value: %0.15e)", RealTraits::getPassiveValue(arg));
538 }
539 }
540 if (result != 0.0) {
541 return 1.0 / (3.0 * result * result);
542 } else {
543 return (Real)0.0;
544 }
545 }
546
548 static CODI_INLINE std::string getMathRep() {
549 return "cbrt";
550 }
551 };
552#define OPERATION_LOGIC OperationCbrt
553#define FUNCTION cbrt
554#include "unaryOverloads.tpp"
555
556#define OPERATION_LOGIC OperationCbrt
557#define FUNCTION cbrtf
558#include "unaryOverloads.tpp"
559
560#define OPERATION_LOGIC OperationCbrt
561#define FUNCTION cbrtl
562#include "unaryOverloads.tpp"
563
565 template<typename Real, typename Arg>
569
571 template<typename Real, typename Arg>
575
577 template<typename Real, typename Arg>
581
583 template<typename T_Real>
584 struct OperationCos : public UnaryJacobianOperation<T_Real, OperationCos<T_Real>> {
585 public:
586
587 using Real = CODI_DD(T_Real, double);
588
590 template<typename Arg>
591 static CODI_INLINE Real primal(Arg const& arg) {
592 return cos(arg);
593 }
594
596 template<typename Arg>
597 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
598 CODI_UNUSED(result);
599 return -sin(arg);
600 }
601
603 static CODI_INLINE std::string getMathRep() {
604 return "cos";
605 }
606 };
607#define OPERATION_LOGIC OperationCos
608#define FUNCTION cos
609#include "unaryOverloads.tpp"
610
611#define OPERATION_LOGIC OperationCos
612#define FUNCTION cosf
613#include "unaryOverloads.tpp"
614
615#define OPERATION_LOGIC OperationCos
616#define FUNCTION cosl
617#include "unaryOverloads.tpp"
618
620 template<typename T_Real>
621 struct OperationCosh : public UnaryJacobianOperation<T_Real, OperationCosh<T_Real>> {
622 public:
623
624 using Real = CODI_DD(T_Real, double);
625
627 template<typename Arg>
628 static CODI_INLINE Real primal(Arg const& arg) {
629 return cosh(arg);
630 }
631
633 template<typename Arg>
634 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
635 CODI_UNUSED(result);
636 return sinh(arg);
637 }
638
640 static CODI_INLINE std::string getMathRep() {
641 return "sinh";
642 }
643 };
644#define OPERATION_LOGIC OperationCosh
645#define FUNCTION cosh
646#include "unaryOverloads.tpp"
647
648#define OPERATION_LOGIC OperationCosh
649#define FUNCTION coshf
650#include "unaryOverloads.tpp"
651
652#define OPERATION_LOGIC OperationCosh
653#define FUNCTION coshl
654#include "unaryOverloads.tpp"
655
657 template<typename T_Real>
658 struct OperationErf : public UnaryJacobianOperation<T_Real, OperationErf<T_Real>> {
659 public:
660
661 using Real = CODI_DD(T_Real, double);
662
664 template<typename Arg>
665 static CODI_INLINE Real primal(Arg const& arg) {
666 return erf(arg);
667 }
668
670 template<typename Arg>
671 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
672 CODI_UNUSED(result);
673 return 1.128379167095513 * exp(-(arg * arg)); // erf'(arg) = 2.0 / sqrt(pi) * exp(-arg^2)
674 }
675
677 static CODI_INLINE std::string getMathRep() {
678 return "erf";
679 }
680 };
681#define OPERATION_LOGIC OperationErf
682#define FUNCTION erf
683#include "unaryOverloads.tpp"
684
685#define OPERATION_LOGIC OperationErf
686#define FUNCTION erff
687#include "unaryOverloads.tpp"
688
689#define OPERATION_LOGIC OperationErf
690#define FUNCTION erfl
691#include "unaryOverloads.tpp"
692
694 template<typename T_Real>
695 struct OperationErfc : public UnaryJacobianOperation<T_Real, OperationErfc<T_Real>> {
696 public:
697
698 using Real = CODI_DD(T_Real, double);
699
701 template<typename Arg>
702 static CODI_INLINE Real primal(Arg const& arg) {
703 return erfc(arg);
704 }
705
707 template<typename Arg>
708 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
709 CODI_UNUSED(result);
710 return -1.128379167095513 * exp(-(arg * arg)); // erfc'(arg) = - 2.0 / sqrt(pi) * exp(-arg^2)
711 }
712
714 static CODI_INLINE std::string getMathRep() {
715 return "erfc";
716 }
717 };
718#define OPERATION_LOGIC OperationErfc
719#define FUNCTION erfc
720#include "unaryOverloads.tpp"
721
722#define OPERATION_LOGIC OperationErfc
723#define FUNCTION erfcf
724#include "unaryOverloads.tpp"
725
726#define OPERATION_LOGIC OperationErfc
727#define FUNCTION erfcl
728#include "unaryOverloads.tpp"
729
731 template<typename T_Real>
732 struct OperationExp : public UnaryJacobianOperation<T_Real, OperationExp<T_Real>> {
733 public:
734
735 using Real = CODI_DD(T_Real, double);
736
738 template<typename Arg>
739 static CODI_INLINE Real primal(Arg const& arg) {
740 return exp(arg);
741 }
742
744 template<typename Arg>
745 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
747 return result;
748 }
749
751 static CODI_INLINE std::string getMathRep() {
752 return "exp";
753 }
754 };
755#define OPERATION_LOGIC OperationExp
756#define FUNCTION exp
757#include "unaryOverloads.tpp"
758
759#define OPERATION_LOGIC OperationExp
760#define FUNCTION expf
761#include "unaryOverloads.tpp"
762
763#define OPERATION_LOGIC OperationExp
764#define FUNCTION expl
765#include "unaryOverloads.tpp"
766
768 template<typename Real, typename Arg>
772
774 template<typename Real, typename Arg>
778
780 template<typename Real, typename Arg>
784
786 template<typename Real, typename Arg>
790
792 template<typename Real, typename Arg>
796
798 template<typename Real, typename Arg>
802
804 template<typename Real, typename Arg>
808
810 template<typename T_Real>
811 struct OperationLog : public UnaryJacobianOperation<T_Real, OperationLog<T_Real>> {
812 public:
813
814 using Real = CODI_DD(T_Real, double);
815
817 template<typename Arg>
818 static CODI_INLINE Real primal(Arg const& arg) {
819 return log(arg);
820 }
821
823 template<typename Arg>
824 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
825 CODI_UNUSED(result);
827 checkArgument(arg);
828 }
829 return 1.0 / arg;
830 }
831
833 static CODI_INLINE std::string getMathRep() {
834 return "log";
835 }
836
837 private:
838
839 template<typename Arg>
840 CODI_INLINE static void checkArgument(Arg const& arg) {
841 if (0.0 > RealTraits::getPassiveValue(arg)) {
842 CODI_EXCEPTION("Logarithm of negative value or zero. (Value: %0.15e)", RealTraits::getPassiveValue(arg));
843 }
844 }
845
846 template<typename Arg>
847 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
848 if (0.0 == RealTraits::getPassiveValue(abs(arg))) {
849 CODI_EXCEPTION("Logarithm of zero. (Value: %0.15e)", RealTraits::getPassiveValue(abs(arg)));
850 }
851 }
852 };
853#define OPERATION_LOGIC OperationLog
854#define FUNCTION log
855#include "unaryOverloads.tpp"
856
857#define OPERATION_LOGIC OperationLog
858#define FUNCTION logf
859#include "unaryOverloads.tpp"
860
861#define OPERATION_LOGIC OperationLog
862#define FUNCTION logl
863#include "unaryOverloads.tpp"
864
866 template<typename T_Real>
867 struct OperationLog10 : public UnaryJacobianOperation<T_Real, OperationLog10<T_Real>> {
868 public:
869
870 using Real = CODI_DD(T_Real, double);
871
873 template<typename Arg>
874 static CODI_INLINE Real primal(Arg const& arg) {
875 return log10(arg);
876 }
877
879 template<typename Arg>
880 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
881 CODI_UNUSED(result);
883 checkArgument(arg);
884 }
885 return 0.434294481903252 / arg;
886 }
887
889 static CODI_INLINE std::string getMathRep() {
890 return "log10";
891 }
892
893 private:
894 template<typename Arg>
895 CODI_INLINE static void checkArgument(Arg const& arg) {
896 if (0.0 > RealTraits::getPassiveValue(arg)) {
897 CODI_EXCEPTION("Logarithm of negative value or zero. (Value: %0.15e)", RealTraits::getPassiveValue(arg));
898 }
899 }
900
901 template<typename Arg>
902 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
903 if (0.0 == RealTraits::getPassiveValue(abs(arg))) {
904 CODI_EXCEPTION("Logarithm of zero. (Value: %0.15e)", RealTraits::getPassiveValue(abs(arg)));
905 }
906 }
907 };
908#define OPERATION_LOGIC OperationLog10
909#define FUNCTION log10
910#include "unaryOverloads.tpp"
911
912#define OPERATION_LOGIC OperationLog10
913#define FUNCTION log10f
914#include "unaryOverloads.tpp"
915
916#define OPERATION_LOGIC OperationLog10
917#define FUNCTION log10l
918#include "unaryOverloads.tpp"
919
921 template<typename T_Real>
922 struct OperationLog1p : public UnaryJacobianOperation<T_Real, OperationLog1p<T_Real>> {
923 public:
924
925 using Real = CODI_DD(T_Real, double);
926
928 template<typename Arg>
929 static CODI_INLINE Real primal(Arg const& arg) {
930 return log1p(arg);
931 }
932
934 template<typename Arg>
935 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
936 CODI_UNUSED(result);
938 if (0.0 > RealTraits::getPassiveValue(arg)) {
939 CODI_EXCEPTION("Logarithm of negative value or zero.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
940 }
941 }
942 return 1.0 / (arg + 1.0);
943 }
944
946 static CODI_INLINE std::string getMathRep() {
947 return "log1p";
948 }
949 };
950#define OPERATION_LOGIC OperationLog1p
951#define FUNCTION log1p
952#include "unaryOverloads.tpp"
953
954#define OPERATION_LOGIC OperationLog1p
955#define FUNCTION log1pf
956#include "unaryOverloads.tpp"
957
958#define OPERATION_LOGIC OperationLog1p
959#define FUNCTION log1pl
960#include "unaryOverloads.tpp"
961
963 template<typename T_Real>
964 struct OperationLog2 : public UnaryJacobianOperation<T_Real, OperationLog2<T_Real>> {
965 public:
966
967 using Real = CODI_DD(T_Real, double);
968
970 template<typename Arg>
971 static CODI_INLINE Real primal(Arg const& arg) {
972 return log2(arg);
973 }
974
976 template<typename Arg>
977 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
978 CODI_UNUSED(result);
980 if (0.0 > RealTraits::getPassiveValue(arg)) {
981 CODI_EXCEPTION("Logarithm of negative value or zero.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
982 }
983 }
984 return 1.442695040888963 / arg;
985 }
986
988 static CODI_INLINE std::string getMathRep() {
989 return "log2";
990 }
991 };
992#define OPERATION_LOGIC OperationLog2
993#define FUNCTION log2
994#include "unaryOverloads.tpp"
995
996#define OPERATION_LOGIC OperationLog2
997#define FUNCTION log2f
998#include "unaryOverloads.tpp"
999
1000#define OPERATION_LOGIC OperationLog2
1001#define FUNCTION log2l
1002#include "unaryOverloads.tpp"
1003
1005 template<typename Real, typename Arg>
1009
1011 template<typename Real, typename Arg>
1015
1017 template<typename Real, typename Arg>
1021
1023 template<typename T_Real>
1024 struct OperationSin : public UnaryJacobianOperation<T_Real, OperationSin<T_Real>> {
1025 public:
1026
1027 using Real = CODI_DD(T_Real, double);
1028
1030 template<typename Arg>
1031 static CODI_INLINE Real primal(Arg const& arg) {
1032 return sin(arg);
1033 }
1034
1036 template<typename Arg>
1037 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1038 CODI_UNUSED(result);
1039 return cos(arg);
1040 }
1041
1043 static CODI_INLINE std::string getMathRep() {
1044 return "sin";
1045 }
1046 };
1047#define OPERATION_LOGIC OperationSin
1048#define FUNCTION sin
1049#include "unaryOverloads.tpp"
1050
1051#define OPERATION_LOGIC OperationSin
1052#define FUNCTION sinf
1053#include "unaryOverloads.tpp"
1054
1055#define OPERATION_LOGIC OperationSin
1056#define FUNCTION sinl
1057#include "unaryOverloads.tpp"
1058
1060 template<typename T_Real>
1061 struct OperationSinh : public UnaryJacobianOperation<T_Real, OperationSinh<T_Real>> {
1062 public:
1063
1064 using Real = CODI_DD(T_Real, double);
1065
1067 template<typename Arg>
1068 static CODI_INLINE Real primal(Arg const& arg) {
1069 return sinh(arg);
1070 }
1071
1073 template<typename Arg>
1074 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1075 CODI_UNUSED(result);
1076 return cosh(arg);
1077 }
1078
1080 static CODI_INLINE std::string getMathRep() {
1081 return "sinh";
1082 }
1083 };
1084#define OPERATION_LOGIC OperationSinh
1085#define FUNCTION sinh
1086#include "unaryOverloads.tpp"
1087
1088#define OPERATION_LOGIC OperationSinh
1089#define FUNCTION sinhf
1090#include "unaryOverloads.tpp"
1091
1092#define OPERATION_LOGIC OperationSinh
1093#define FUNCTION sinhl
1094#include "unaryOverloads.tpp"
1095
1097 template<typename T_Real>
1098 struct OperationSqrt : public UnaryJacobianOperation<T_Real, OperationSqrt<T_Real>> {
1099 public:
1100
1101 using Real = CODI_DD(T_Real, double);
1102
1104 template<typename Arg>
1105 static CODI_INLINE Real primal(Arg const& arg) {
1106 return sqrt(arg);
1107 }
1108
1110 template<typename Arg>
1111 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1113 checkArgument(arg);
1114 }
1115 if (result != 0.0) {
1116 return 0.5 / result;
1117 } else {
1118 return (Real)0.0;
1119 }
1120 }
1121
1123 static CODI_INLINE std::string getMathRep() {
1124 return "sqrt";
1125 }
1126
1127 private:
1128 template<typename Arg>
1129 CODI_INLINE static void checkArgument(Arg const& arg) {
1130 if (0.0 > RealTraits::getPassiveValue(arg)) {
1131 CODI_EXCEPTION("Sqrt of negative value or zero. (Value: %0.15e)", RealTraits::getPassiveValue(arg));
1132 }
1133 }
1134
1135 template<typename Arg>
1136 CODI_INLINE static void checkArgument(std::complex<Arg> const& arg) {
1138 }
1139 };
1140#define OPERATION_LOGIC OperationSqrt
1141#define FUNCTION sqrt
1142#include "unaryOverloads.tpp"
1143
1144#define OPERATION_LOGIC OperationSqrt
1145#define FUNCTION sqrtf
1146#include "unaryOverloads.tpp"
1147
1148#define OPERATION_LOGIC OperationSqrt
1149#define FUNCTION sqrtl
1150#include "unaryOverloads.tpp"
1151
1153 template<typename T_Real>
1154 struct OperationTan : public UnaryJacobianOperation<T_Real, OperationTan<T_Real>> {
1155 public:
1156
1157 using Real = CODI_DD(T_Real, double);
1158
1160 template<typename Arg>
1161 static CODI_INLINE Real primal(Arg const& arg) {
1162 return tan(arg);
1163 }
1164
1166 template<typename Arg>
1167 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1168 CODI_UNUSED(result);
1170 checkArgument(arg);
1171 }
1172 Real tmp = 1.0 / cos(arg);
1173 return tmp * tmp;
1174 }
1175
1177 static CODI_INLINE std::string getMathRep() {
1178 return "tan";
1179 }
1180
1181 private:
1182 template<typename Arg>
1183 CODI_INLINE static void checkArgument(Arg const& arg) {
1184 if (0.0 == abs(cos(RealTraits::getPassiveValue(arg)))) {
1185 CODI_EXCEPTION("Tan evaluated at (0.5 + i) * PI. (Value: %0.15e)", RealTraits::getPassiveValue(arg));
1186 }
1187 }
1188 };
1189#define OPERATION_LOGIC OperationTan
1190#define FUNCTION tan
1191#include "unaryOverloads.tpp"
1192
1193#define OPERATION_LOGIC OperationTan
1194#define FUNCTION tanf
1195#include "unaryOverloads.tpp"
1196
1197#define OPERATION_LOGIC OperationTan
1198#define FUNCTION tanl
1199#include "unaryOverloads.tpp"
1200
1202 template<typename T_Real>
1203 struct OperationTanh : public UnaryJacobianOperation<T_Real, OperationTanh<T_Real>> {
1204 public:
1205
1206 using Real = CODI_DD(T_Real, double);
1207
1209 template<typename Arg>
1210 static CODI_INLINE Real primal(Arg const& arg) {
1211 return tanh(arg);
1212 }
1213
1215 template<typename Arg>
1216 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1218 return 1.0 - result * result;
1219 }
1220
1222 static CODI_INLINE std::string getMathRep() {
1223 return "tanh";
1224 }
1225 };
1226#define OPERATION_LOGIC OperationTanh
1227#define FUNCTION tanh
1228#include "unaryOverloads.tpp"
1229
1230#define OPERATION_LOGIC OperationTanh
1231#define FUNCTION tanhf
1232#include "unaryOverloads.tpp"
1233
1234#define OPERATION_LOGIC OperationTanh
1235#define FUNCTION tanhl
1236#include "unaryOverloads.tpp"
1237
1239 template<typename T_Real>
1240 struct OperationTgamma : public UnaryJacobianOperation<T_Real, OperationTgamma<T_Real>> {
1241 public:
1242
1243 using Real = CODI_DD(T_Real, double);
1244
1246 template<typename Arg>
1247 static CODI_INLINE Real primal(Arg const& arg) {
1248 return tgamma(arg);
1249 }
1250
1252 template<typename Arg>
1253 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
1254 if (arg <= 0.0) {
1255 std::cout << "Derivative for gamma function only for positive arguments at the moment" << std::endl;
1256 std::exit(1);
1257 }
1258
1259 // Implementation of the digamma function is taken from John Burkardt,
1260 // http://people.sc.fsu.edu/~jburkardt/cpp_src/asa103/asa103.cpp
1261 //
1262 // Definition of Gamma(arg): https://en.wikipedia.org/wiki/Gamma_function
1263 // Definition of DiGamma(arg): https://en.wikipedia.org/wiki/Digamma_function
1264 // Differentation is Gamma'(arg) = Gamma(arg) * DiGamma(arg)
1265
1266 Real diGamma = 0.0;
1267 if (arg <= 0.000001) { // Special case for small numbers.
1268 const Real eulerMascheroni = 0.57721566490153286060;
1269 diGamma = -eulerMascheroni - 1.0 / arg + 1.6449340668482264365 * arg;
1270 } else {
1271 // Shift DiGamma(arg) = DiGamma(arg + 1) - 1/arg
1272 // We require arg large such that the approximation below is more accurate.
1273 Real shiftBound = 8.5;
1274
1275 Real shiftedValue = arg;
1276 while (shiftedValue < shiftBound) {
1277 diGamma -= 1.0 / shiftedValue;
1278 shiftedValue += 1.0;
1279 }
1280
1281 // Now compute the approximation via an asymptotic series.
1282 Real r = 1.0 / shiftedValue;
1283 diGamma += log(shiftedValue) - 0.5 * r;
1284
1285 Real rSqr = r * r;
1286 diGamma -= rSqr * (1.0 / 12.0 -
1287 rSqr * (1.0 / 120.0 - rSqr * (1.0 / 252.0 - rSqr * (1.0 / 240.0 - rSqr * (1.0 / 132.0)))));
1288 }
1289
1290 return diGamma * result;
1291 }
1292
1294 static CODI_INLINE std::string getMathRep() {
1295 return "tgamma";
1296 }
1297 };
1298#define OPERATION_LOGIC OperationTgamma
1299#define FUNCTION tgamma
1300#include "unaryOverloads.tpp"
1301
1302#define OPERATION_LOGIC OperationTgamma
1303#define FUNCTION tgammaf
1304#include "unaryOverloads.tpp"
1305
1306#define OPERATION_LOGIC OperationTgamma
1307#define FUNCTION tgammal
1308#include "unaryOverloads.tpp"
1309
1311 /*******************************************************************************/
1314
1316 template<typename Real, typename Arg>
1318 using std::to_string;
1319
1321 }
1322
1324}
1325
1326namespace std {
1327
1328 using codi::abs;
1329 using codi::acos;
1330 using codi::acosf;
1331 using codi::acosh;
1332 using codi::acoshf;
1333 using codi::acoshl;
1334 using codi::acosl;
1335 using codi::asin;
1336 using codi::asinf;
1337 using codi::asinh;
1338 using codi::asinhf;
1339 using codi::asinhl;
1340 using codi::asinl;
1341 using codi::atan;
1342 using codi::atanf;
1343 using codi::atanh;
1344 using codi::atanhf;
1345 using codi::atanhl;
1346 using codi::atanl;
1347 using codi::cbrt;
1348 using codi::cbrtf;
1349 using codi::cbrtl;
1350 using codi::ceil;
1351 using codi::ceilf;
1352 using codi::ceill;
1353 using codi::cos;
1354 using codi::cosf;
1355 using codi::cosh;
1356 using codi::coshf;
1357 using codi::coshl;
1358 using codi::cosl;
1359 using codi::erf;
1360 using codi::erfc;
1361 using codi::erfcf;
1362 using codi::erfcl;
1363 using codi::erff;
1364 using codi::erfl;
1365 using codi::exp;
1366 using codi::expf;
1367 using codi::expl;
1368 using codi::fabs;
1369 using codi::fabsf;
1370 using codi::fabsl;
1371 using codi::floor;
1372 using codi::floorf;
1373 using codi::floorl;
1374 using codi::isfinite;
1375 using codi::isinf;
1376 using codi::isnan;
1377 using codi::isnormal;
1378 using codi::log;
1379 using codi::log10;
1380 using codi::log10f;
1381 using codi::log10l;
1382 using codi::log1p;
1383 using codi::log1pf;
1384 using codi::log1pl;
1385 using codi::log2;
1386 using codi::log2f;
1387 using codi::log2l;
1388 using codi::logf;
1389 using codi::logl;
1390 using codi::round;
1391 using codi::roundf;
1392 using codi::roundl;
1393 using codi::sin;
1394 using codi::sinf;
1395 using codi::sinh;
1396 using codi::sinhf;
1397 using codi::sinhl;
1398 using codi::sinl;
1399 using codi::sqrt;
1400 using codi::sqrtf;
1401 using codi::sqrtl;
1402 using codi::tan;
1403 using codi::tanf;
1404 using codi::tanh;
1405 using codi::tanhf;
1406 using codi::tanhl;
1407 using codi::tanl;
1408 using codi::tgamma;
1409 using codi::tgammaf;
1410 using codi::tgammal;
1411
1412 using codi::to_string;
1413}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
bool constexpr CheckExpressionArguments
Check for invalid arguments to expressions like division by zero.
Definition config.h:146
inlinePassiveReal< Type > getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:133
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
inlineauto erff(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlinebool isinf(ExpressionInterface< Real, Arg > const &arg)
Function overload for isinf.
Definition unaryOperators.hpp:793
inlineauto logl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlinestd::string to_string(ExpressionInterface< Real, Arg > const &arg)
Function overload for to_string.
Definition unaryOperators.hpp:1317
inlineauto sqrtl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acosl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tgammal(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acoshf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > floorl(ExpressionInterface< Real, Arg > const &arg)
Function overload for floorl.
Definition unaryOperators.hpp:781
inlineauto erfcl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto erf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto fabsl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log10f(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto exp(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tanf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > round(ExpressionInterface< Real, Arg > const &arg)
Function overload for round.
Definition unaryOperators.hpp:1006
inlineauto sinh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > roundl(ExpressionInterface< Real, Arg > const &arg)
Function overload for roundl.
Definition unaryOperators.hpp:1018
inlinebool isnormal(ExpressionInterface< Real, Arg > const &arg)
Function overload for isnormal.
Definition unaryOperators.hpp:805
inlineauto log(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sinhl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto asinhl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto atanhf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto atan(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sqrtf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sinl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > ceil(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceil.
Definition unaryOperators.hpp:566
inlineauto asin(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log1p(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto atanhl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acos(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto asinh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto erfl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cos(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > ceill(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceill.
Definition unaryOperators.hpp:578
inlineauto coshf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tanh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cbrt(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cosf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acosf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tgammaf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tanhl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log2f(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log10(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sinf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto atanf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log2l(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto coshl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto expl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto asinl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cbrtl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto operator+(ExpressionInterface< std::complex< Real >, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION(complex, real).
Definition allOperators.hpp:92
inlineauto cosh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto imag(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto abs(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto expf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > roundf(ExpressionInterface< Real, Arg > const &arg)
Function overload for roundf.
Definition unaryOperators.hpp:1012
inlineauto log10l(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cosl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acoshl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sinhf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlinebool isnan(ExpressionInterface< Real, Arg > const &arg)
Function overload for isnan.
Definition unaryOperators.hpp:799
inlineauto atanh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto atanl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto cbrtf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sqrt(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tan(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineauto log1pl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tgamma(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto erfcf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
inlineauto arg(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlineRealTraits::PassiveReal< Real > floor(ExpressionInterface< Real, Arg > const &arg)
Function overload for floor.
Definition unaryOperators.hpp:769
inlineauto tanl(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log2(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto sin(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto log1pf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto fabsf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto acosh(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto asinf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto tanhf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto fabs(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineauto logf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > ceilf(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceilf.
Definition unaryOperators.hpp:572
inlineauto erfc(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlineRealTraits::PassiveReal< Real > floorf(ExpressionInterface< Real, Arg > const &arg)
Function overload for floorf.
Definition unaryOperators.hpp:775
inlineauto asinhf(ExpressionInterface< Real, Arg > const &arg)
Function overload for FUNCTION.
Definition unaryOperators.hpp:71
inlinebool isfinite(ExpressionInterface< Real, Arg > const &arg)
Function overload for isfinite.
Definition unaryOperators.hpp:787
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
UnaryJacobianOperation implementation for abs.
Definition unaryOperators.hpp:127
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:134
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:130
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:152
static inlineRealTraits::PassiveReal< Real > gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:140
UnaryJacobianOperation implementation for acos.
Definition unaryOperators.hpp:174
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:181
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:196
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:177
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:187
UnaryJacobianOperation implementation for acosh.
Definition unaryOperators.hpp:232
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:235
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:254
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:245
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:239
UnaryJacobianOperation implementation for asin.
Definition unaryOperators.hpp:289
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:311
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:296
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:292
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:302
UnaryJacobianOperation implementation for asinh.
Definition unaryOperators.hpp:347
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:360
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:350
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:371
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:354
UnaryJacobianOperation implementation for atan.
Definition unaryOperators.hpp:405
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:418
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:408
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:412
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:429
UnaryJacobianOperation implementation for atanh.
Definition unaryOperators.hpp:463
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:470
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:485
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:466
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:476
UnaryJacobianOperation implementation for cbrt.
Definition unaryOperators.hpp:521
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:548
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:528
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:524
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:534
UnaryJacobianOperation implementation for cos.
Definition unaryOperators.hpp:584
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:603
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:597
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:591
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:587
UnaryJacobianOperation implementation for cosh.
Definition unaryOperators.hpp:621
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:624
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:628
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:634
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:640
UnaryJacobianOperation implementation for erf.
Definition unaryOperators.hpp:658
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:671
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:677
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:665
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:661
UnaryJacobianOperation implementation for erfc.
Definition unaryOperators.hpp:695
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:708
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:714
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:702
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:698
UnaryJacobianOperation implementation for exp.
Definition unaryOperators.hpp:732
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:751
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:735
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:739
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:745
UnaryJacobianOperation implementation for log10.
Definition unaryOperators.hpp:867
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:870
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:880
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:874
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:889
UnaryJacobianOperation implementation for log1p.
Definition unaryOperators.hpp:922
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:946
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:925
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:929
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:935
UnaryJacobianOperation implementation for log2.
Definition unaryOperators.hpp:964
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:971
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:977
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:988
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:967
UnaryJacobianOperation implementation for log.
Definition unaryOperators.hpp:811
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:814
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:818
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:824
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:833
UnaryJacobianOperation implementation for sin.
Definition unaryOperators.hpp:1024
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1043
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1037
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1031
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1027
UnaryJacobianOperation implementation for sinh.
Definition unaryOperators.hpp:1061
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1080
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1064
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1074
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1068
UnaryJacobianOperation implementation for sqrt.
Definition unaryOperators.hpp:1098
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1105
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1111
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1101
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1123
UnaryJacobianOperation implementation for tan.
Definition unaryOperators.hpp:1154
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1177
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1157
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1161
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1167
UnaryJacobianOperation implementation for tanh.
Definition unaryOperators.hpp:1203
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1222
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1216
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1206
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1210
UnaryJacobianOperation implementation for tgamma.
Definition unaryOperators.hpp:1240
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:1247
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:1294
static inlineReal gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:1253
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:1243
UnaryJacobianOperation implementation for operator -.
Definition unaryOperators.hpp:54
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition unaryOperators.hpp:74
static inlineRealTraits::PassiveReal< Real > gradient(Arg const &arg, Real const &result)
Compute .
Definition unaryOperators.hpp:67
T_Real Real
See UnaryJacobianOperation.
Definition unaryOperators.hpp:57
static inlineReal primal(Arg const &arg)
Definition unaryOperators.hpp:61
Implements UnaryOperation for functions where the gradient can be computed and transposed.
Definition computeExpression.hpp:149