CoDiPack  2.2.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-2024 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 "../unaryExpression.hpp"
44
46namespace codi {
47
48 /*******************************************************************************/
51
53 template<typename T_Real>
54 struct OperationUnaryMinus : public UnaryOperation<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) {
68 CODI_UNUSED(arg);
69 CODI_UNUSED(result);
70 return -1.0;
71 }
72 };
73#define OPERATION_LOGIC OperationUnaryMinus
74#define FUNCTION operator-
75#include "unaryOverloads.tpp"
76
78 template<typename Real, typename Arg>
82
84 /*******************************************************************************/
87
88 using std::abs;
89 using std::acos;
90 using std::asin;
91 using std::atan;
92 using std::atanh;
93 using std::cbrt;
94 using std::ceil;
95 using std::cos;
96 using std::cosh;
97 using std::erf;
98 using std::erfc;
99 using std::exp;
100 using std::fabs;
101 using std::floor;
102 using std::isfinite;
103 using std::isinf;
104 using std::isnan;
105 using std::isnormal;
106 using std::log;
107 using std::log10;
108 using std::round;
109 using std::sin;
110 using std::sinh;
111 using std::sqrt;
112 using std::tan;
113 using std::tanh;
114 using std::tgamma;
115
117 template<typename T_Real>
118 struct OperationAbs : public UnaryOperation<T_Real> {
119 public:
120
121 using Real = CODI_DD(T_Real, double);
122
124 template<typename Arg>
125 static CODI_INLINE Real primal(Arg const& arg) {
126 return abs(arg);
127 }
128
130 template<typename Arg>
131 static CODI_INLINE RealTraits::PassiveReal<Real> gradient(Arg const& arg, Real const& result) {
132 CODI_UNUSED(result);
133 if (arg < 0.0) {
134 return -1.0;
135 } else if (arg > 0.0) {
136 return 1.0;
137 } else {
138 return 0.0;
139 }
140 }
141 };
142#define OPERATION_LOGIC OperationAbs
143#define FUNCTION abs
144#include "unaryOverloads.tpp"
145
146#define OPERATION_LOGIC OperationAbs
147#define FUNCTION fabs
148#include "unaryOverloads.tpp"
149
150#define OPERATION_LOGIC OperationAbs
151#define FUNCTION fabsf
152#include "unaryOverloads.tpp"
153
154#define OPERATION_LOGIC OperationAbs
155#define FUNCTION fabsl
156#include "unaryOverloads.tpp"
157
159 template<typename T_Real>
160 struct OperationAcos : public UnaryOperation<T_Real> {
161 public:
162
163 using Real = CODI_DD(T_Real, double);
164
166 template<typename Arg>
167 static CODI_INLINE Real primal(Arg const& arg) {
168 return acos(arg);
169 }
170
172 template<typename Arg>
173 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
174 CODI_UNUSED(result);
176 if (RealTraits::getPassiveValue(arg) <= -1.0 || 1.0 <= RealTraits::getPassiveValue(arg)) {
177 CODI_EXCEPTION("acos outside of (-1, 1).(Value: %0.15e)", RealTraits::getPassiveValue(arg));
178 }
179 }
180 return -1.0 / sqrt(1.0 - arg * arg);
181 }
182 };
183#define OPERATION_LOGIC OperationAcos
184#define FUNCTION acos
185#include "unaryOverloads.tpp"
186
187#define OPERATION_LOGIC OperationAcos
188#define FUNCTION acosf
189#include "unaryOverloads.tpp"
190
191#define OPERATION_LOGIC OperationAcos
192#define FUNCTION acosl
193#include "unaryOverloads.tpp"
194
196 template<typename T_Real>
197 struct OperationAsin : public UnaryOperation<T_Real> {
198 public:
199
200 using Real = CODI_DD(T_Real, double);
201
203 template<typename Arg>
204 static CODI_INLINE Real primal(Arg const& arg) {
205 return asin(arg);
206 }
207
209 template<typename Arg>
210 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
211 CODI_UNUSED(result);
213 if (RealTraits::getPassiveValue(arg) <= -1.0 || 1.0 <= RealTraits::getPassiveValue(arg)) {
214 CODI_EXCEPTION("asin outside of (-1, 1).(Value: %0.15e)", RealTraits::getPassiveValue(arg));
215 }
216 }
217 return 1.0 / sqrt(1.0 - arg * arg);
218 }
219 };
220#define OPERATION_LOGIC OperationAsin
221#define FUNCTION asin
222#include "unaryOverloads.tpp"
223
224#define OPERATION_LOGIC OperationAsin
225#define FUNCTION asinf
226#include "unaryOverloads.tpp"
227
228#define OPERATION_LOGIC OperationAsin
229#define FUNCTION asinl
230#include "unaryOverloads.tpp"
231
233 template<typename T_Real>
234 struct OperationAtan : public UnaryOperation<T_Real> {
235 public:
236
237 using Real = CODI_DD(T_Real, double);
238
240 template<typename Arg>
241 static CODI_INLINE Real primal(Arg const& arg) {
242 return atan(arg);
243 }
244
246 template<typename Arg>
247 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
248 CODI_UNUSED(result);
249 return 1.0 / (1.0 + arg * arg);
250 }
251 };
252#define OPERATION_LOGIC OperationAtan
253#define FUNCTION atan
254#include "unaryOverloads.tpp"
255
256#define OPERATION_LOGIC OperationAtan
257#define FUNCTION atanf
258#include "unaryOverloads.tpp"
259
260#define OPERATION_LOGIC OperationAtan
261#define FUNCTION atanl
262#include "unaryOverloads.tpp"
263
265 template<typename T_Real>
266 struct OperationAtanh : public UnaryOperation<T_Real> {
267 public:
268
269 using Real = CODI_DD(T_Real, double);
270
272 template<typename Arg>
273 static CODI_INLINE Real primal(Arg const& arg) {
274 return atanh(arg);
275 }
276
278 template<typename Arg>
279 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
280 CODI_UNUSED(result);
282 if (RealTraits::getPassiveValue(arg) <= -1.0 || 1.0 <= RealTraits::getPassiveValue(arg)) {
283 CODI_EXCEPTION("atanh outside of (-1, 1).(Value: %0.15e)", RealTraits::getPassiveValue(arg));
284 }
285 }
286 return 1.0 / (1.0 - arg * arg);
287 }
288 };
289#define OPERATION_LOGIC OperationAtanh
290#define FUNCTION atanh
291#include "unaryOverloads.tpp"
292
293#define OPERATION_LOGIC OperationAtanh
294#define FUNCTION atanhf
295#include "unaryOverloads.tpp"
296
297#define OPERATION_LOGIC OperationAtanh
298#define FUNCTION atanhl
299#include "unaryOverloads.tpp"
300
302 template<typename T_Real>
303 struct OperationCbrt : public UnaryOperation<T_Real> {
304 public:
305
306 using Real = CODI_DD(T_Real, double);
307
309 template<typename Arg>
310 static CODI_INLINE Real primal(Arg const& arg) {
311 return cbrt(arg);
312 }
313
315 template<typename Arg>
316 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
318 if (0.0 == RealTraits::getPassiveValue(arg)) {
319 CODI_EXCEPTION("Cbrt of zero value.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
320 }
321 }
322 if (result != 0.0) {
323 return 1.0 / (3.0 * result * result);
324 } else {
325 return (Real)0.0;
326 }
327 }
328 };
329#define OPERATION_LOGIC OperationCbrt
330#define FUNCTION cbrt
331#include "unaryOverloads.tpp"
332
333#define OPERATION_LOGIC OperationCbrt
334#define FUNCTION cbrtf
335#include "unaryOverloads.tpp"
336
337#define OPERATION_LOGIC OperationCbrt
338#define FUNCTION cbrtl
339#include "unaryOverloads.tpp"
340
342 template<typename Real, typename Arg>
346
348 template<typename Real, typename Arg>
352
354 template<typename Real, typename Arg>
358
360 template<typename T_Real>
361 struct OperationCos : public UnaryOperation<T_Real> {
362 public:
363
364 using Real = CODI_DD(T_Real, double);
365
367 template<typename Arg>
368 static CODI_INLINE Real primal(Arg const& arg) {
369 return cos(arg);
370 }
371
373 template<typename Arg>
374 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
375 CODI_UNUSED(result);
376 return -sin(arg);
377 }
378 };
379#define OPERATION_LOGIC OperationCos
380#define FUNCTION cos
381#include "unaryOverloads.tpp"
382
383#define OPERATION_LOGIC OperationCos
384#define FUNCTION cosf
385#include "unaryOverloads.tpp"
386
387#define OPERATION_LOGIC OperationCos
388#define FUNCTION cosl
389#include "unaryOverloads.tpp"
390
392 template<typename T_Real>
393 struct OperationCosh : public UnaryOperation<T_Real> {
394 public:
395
396 using Real = CODI_DD(T_Real, double);
397
399 template<typename Arg>
400 static CODI_INLINE Real primal(Arg const& arg) {
401 return cosh(arg);
402 }
403
405 template<typename Arg>
406 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
407 CODI_UNUSED(result);
408 return sinh(arg);
409 }
410 };
411#define OPERATION_LOGIC OperationCosh
412#define FUNCTION cosh
413#include "unaryOverloads.tpp"
414
415#define OPERATION_LOGIC OperationCosh
416#define FUNCTION coshf
417#include "unaryOverloads.tpp"
418
419#define OPERATION_LOGIC OperationCosh
420#define FUNCTION coshl
421#include "unaryOverloads.tpp"
422
424 template<typename T_Real>
425 struct OperationErf : public UnaryOperation<T_Real> {
426 public:
427
428 using Real = CODI_DD(T_Real, double);
429
431 template<typename Arg>
432 static CODI_INLINE Real primal(Arg const& arg) {
433 return erf(arg);
434 }
435
437 template<typename Arg>
438 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
439 CODI_UNUSED(result);
440 return 1.128379167095513 * exp(-(arg * arg)); // erf'(arg) = 2.0 / sqrt(pi) * exp(-arg^2)
441 }
442 };
443#define OPERATION_LOGIC OperationErf
444#define FUNCTION erf
445#include "unaryOverloads.tpp"
446
447#define OPERATION_LOGIC OperationErf
448#define FUNCTION erff
449#include "unaryOverloads.tpp"
450
451#define OPERATION_LOGIC OperationErf
452#define FUNCTION erfl
453#include "unaryOverloads.tpp"
454
456 template<typename T_Real>
457 struct OperationErfc : public UnaryOperation<T_Real> {
458 public:
459
460 using Real = CODI_DD(T_Real, double);
461
463 template<typename Arg>
464 static CODI_INLINE Real primal(Arg const& arg) {
465 return erfc(arg);
466 }
467
469 template<typename Arg>
470 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
471 CODI_UNUSED(result);
472 return -1.128379167095513 * exp(-(arg * arg)); // erfc'(arg) = - 2.0 / sqrt(pi) * exp(-arg^2)
473 }
474 };
475#define OPERATION_LOGIC OperationErfc
476#define FUNCTION erfc
477#include "unaryOverloads.tpp"
478
479#define OPERATION_LOGIC OperationErfc
480#define FUNCTION erfcf
481#include "unaryOverloads.tpp"
482
483#define OPERATION_LOGIC OperationErfc
484#define FUNCTION erfcl
485#include "unaryOverloads.tpp"
486
488 template<typename T_Real>
489 struct OperationExp : public UnaryOperation<T_Real> {
490 public:
491
492 using Real = CODI_DD(T_Real, double);
493
495 template<typename Arg>
496 static CODI_INLINE Real primal(Arg const& arg) {
497 return exp(arg);
498 }
499
501 template<typename Arg>
502 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
503 CODI_UNUSED(arg);
504 return result;
505 }
506 };
507#define OPERATION_LOGIC OperationExp
508#define FUNCTION exp
509#include "unaryOverloads.tpp"
510
511#define OPERATION_LOGIC OperationExp
512#define FUNCTION expf
513#include "unaryOverloads.tpp"
514
515#define OPERATION_LOGIC OperationExp
516#define FUNCTION expl
517#include "unaryOverloads.tpp"
518
520 template<typename Real, typename Arg>
524
526 template<typename Real, typename Arg>
530
532 template<typename Real, typename Arg>
536
538 template<typename Real, typename Arg>
542
544 template<typename Real, typename Arg>
548
550 template<typename Real, typename Arg>
554
556 template<typename Real, typename Arg>
560
562 template<typename T_Real>
563 struct OperationLog : public UnaryOperation<T_Real> {
564 public:
565
566 using Real = CODI_DD(T_Real, double);
567
569 template<typename Arg>
570 static CODI_INLINE Real primal(Arg const& arg) {
571 return log(arg);
572 }
573
575 template<typename Arg>
576 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
577 CODI_UNUSED(result);
579 if (0.0 > RealTraits::getPassiveValue(arg)) {
580 CODI_EXCEPTION("Logarithm of negative value or zero.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
581 }
582 }
583 return 1.0 / arg;
584 }
585 };
586#define OPERATION_LOGIC OperationLog
587#define FUNCTION log
588#include "unaryOverloads.tpp"
589
590#define OPERATION_LOGIC OperationLog
591#define FUNCTION logf
592#include "unaryOverloads.tpp"
593
594#define OPERATION_LOGIC OperationLog
595#define FUNCTION logl
596#include "unaryOverloads.tpp"
597
599 template<typename T_Real>
600 struct OperationLog10 : public UnaryOperation<T_Real> {
601 public:
602
603 using Real = CODI_DD(T_Real, double);
604
606 template<typename Arg>
607 static CODI_INLINE Real primal(Arg const& arg) {
608 return log10(arg);
609 }
610
612 template<typename Arg>
613 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
614 CODI_UNUSED(result);
616 if (0.0 > RealTraits::getPassiveValue(arg)) {
617 CODI_EXCEPTION("Logarithm of negative value or zero.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
618 }
619 }
620 return 0.434294481903252 / arg;
621 }
622 };
623#define OPERATION_LOGIC OperationLog10
624#define FUNCTION log10
625#include "unaryOverloads.tpp"
626
627#define OPERATION_LOGIC OperationLog10
628#define FUNCTION log10f
629#include "unaryOverloads.tpp"
630
631#define OPERATION_LOGIC OperationLog10
632#define FUNCTION log10l
633#include "unaryOverloads.tpp"
634
636 template<typename Real, typename Arg>
640
642 template<typename Real, typename Arg>
646
648 template<typename Real, typename Arg>
652
654 template<typename T_Real>
655 struct OperationSin : public UnaryOperation<T_Real> {
656 public:
657
658 using Real = CODI_DD(T_Real, double);
659
661 template<typename Arg>
662 static CODI_INLINE Real primal(Arg const& arg) {
663 return sin(arg);
664 }
665
667 template<typename Arg>
668 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
669 CODI_UNUSED(result);
670 return cos(arg);
671 }
672 };
673#define OPERATION_LOGIC OperationSin
674#define FUNCTION sin
675#include "unaryOverloads.tpp"
676
677#define OPERATION_LOGIC OperationSin
678#define FUNCTION sinf
679#include "unaryOverloads.tpp"
680
681#define OPERATION_LOGIC OperationSin
682#define FUNCTION sinl
683#include "unaryOverloads.tpp"
684
686 template<typename T_Real>
687 struct OperationSinh : public UnaryOperation<T_Real> {
688 public:
689
690 using Real = CODI_DD(T_Real, double);
691
693 template<typename Arg>
694 static CODI_INLINE Real primal(Arg const& arg) {
695 return sinh(arg);
696 }
697
699 template<typename Arg>
700 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
701 CODI_UNUSED(result);
702 return cosh(arg);
703 }
704 };
705#define OPERATION_LOGIC OperationSinh
706#define FUNCTION sinh
707#include "unaryOverloads.tpp"
708
709#define OPERATION_LOGIC OperationSinh
710#define FUNCTION sinhf
711#include "unaryOverloads.tpp"
712
713#define OPERATION_LOGIC OperationSinh
714#define FUNCTION sinhl
715#include "unaryOverloads.tpp"
716
718 template<typename T_Real>
719 struct OperationSqrt : public UnaryOperation<T_Real> {
720 public:
721
722 using Real = CODI_DD(T_Real, double);
723
725 template<typename Arg>
726 static CODI_INLINE Real primal(Arg const& arg) {
727 return sqrt(arg);
728 }
729
731 template<typename Arg>
732 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
734 if (0.0 > RealTraits::getPassiveValue(arg)) {
735 CODI_EXCEPTION("Sqrt of negative value or zero.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
736 }
737 }
738 if (result != 0.0) {
739 return 0.5 / result;
740 } else {
741 return (Real)0.0;
742 }
743 }
744 };
745#define OPERATION_LOGIC OperationSqrt
746#define FUNCTION sqrt
747#include "unaryOverloads.tpp"
748
749#define OPERATION_LOGIC OperationSqrt
750#define FUNCTION sqrtf
751#include "unaryOverloads.tpp"
752
753#define OPERATION_LOGIC OperationSqrt
754#define FUNCTION sqrtl
755#include "unaryOverloads.tpp"
756
758 template<typename T_Real>
759 struct OperationTan : public UnaryOperation<T_Real> {
760 public:
761
762 using Real = CODI_DD(T_Real, double);
763
765 template<typename Arg>
766 static CODI_INLINE Real primal(Arg const& arg) {
767 return tan(arg);
768 }
769
771 template<typename Arg>
772 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
773 CODI_UNUSED(result);
775 if (0.0 == cos(RealTraits::getPassiveValue(arg))) {
776 CODI_EXCEPTION("Tan evaluated at (0.5 + i) * PI.(Value: %0.15e)", RealTraits::getPassiveValue(arg));
777 }
778 }
779 Real tmp = 1.0 / cos(arg);
780 return tmp * tmp;
781 }
782 };
783#define OPERATION_LOGIC OperationTan
784#define FUNCTION tan
785#include "unaryOverloads.tpp"
786
787#define OPERATION_LOGIC OperationTan
788#define FUNCTION tanf
789#include "unaryOverloads.tpp"
790
791#define OPERATION_LOGIC OperationTan
792#define FUNCTION tanl
793#include "unaryOverloads.tpp"
794
796 template<typename T_Real>
797 struct OperationTanh : public UnaryOperation<T_Real> {
798 public:
799
800 using Real = CODI_DD(T_Real, double);
801
803 template<typename Arg>
804 static CODI_INLINE Real primal(Arg const& arg) {
805 return tanh(arg);
806 }
807
809 template<typename Arg>
810 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
811 CODI_UNUSED(arg);
812 return 1.0 - result * result;
813 }
814 };
815#define OPERATION_LOGIC OperationTanh
816#define FUNCTION tanh
817#include "unaryOverloads.tpp"
818
819#define OPERATION_LOGIC OperationTanh
820#define FUNCTION tanhf
821#include "unaryOverloads.tpp"
822
823#define OPERATION_LOGIC OperationTanh
824#define FUNCTION tanhl
825#include "unaryOverloads.tpp"
826
828 template<typename T_Real>
829 struct OperationTgamma : public UnaryOperation<T_Real> {
830 public:
831
832 using Real = CODI_DD(T_Real, double);
833
835 template<typename Arg>
836 static CODI_INLINE Real primal(Arg const& arg) {
837 return tgamma(arg);
838 }
839
841 template<typename Arg>
842 static CODI_INLINE Real gradient(Arg const& arg, Real const& result) {
843 if (arg <= 0.0) {
844 std::cout << "Derivative for gamma function only for positive arguments at the moment" << std::endl;
845 std::exit(1);
846 }
847
848 // Implementation of the digamma function is taken from John Burkardt,
849 // http://people.sc.fsu.edu/~jburkardt/cpp_src/asa103/asa103.cpp
850 //
851 // Definition of Gamma(arg): https://en.wikipedia.org/wiki/Gamma_function
852 // Definition of DiGamma(arg): https://en.wikipedia.org/wiki/Digamma_function
853 // Differentation is Gamma'(arg) = Gamma(arg) * DiGamma(arg)
854
855 Real diGamma = 0.0;
856 if (arg <= 0.000001) { // Special case for small numbers.
857 const Real eulerMascheroni = 0.57721566490153286060;
858 diGamma = -eulerMascheroni - 1.0 / arg + 1.6449340668482264365 * arg;
859 } else {
860 // Shift DiGamma(arg) = DiGamma(arg + 1) - 1/arg
861 // We require arg large such that the approximation below is more accurate.
862 Real shiftBound = 8.5;
863
864 Real shiftedValue = arg;
865 while (shiftedValue < shiftBound) {
866 diGamma -= 1.0 / shiftedValue;
867 shiftedValue += 1.0;
868 }
869
870 // Now compute the approximation via an asymptotic series.
871 Real r = 1.0 / shiftedValue;
872 diGamma += log(shiftedValue) - 0.5 * r;
873
874 Real rSqr = r * r;
875 diGamma -= rSqr * (1.0 / 12.0 -
876 rSqr * (1.0 / 120.0 - rSqr * (1.0 / 252.0 - rSqr * (1.0 / 240.0 - rSqr * (1.0 / 132.0)))));
877 }
878
879 return diGamma * result;
880 }
881 };
882#define OPERATION_LOGIC OperationTgamma
883#define FUNCTION tgamma
884#include "unaryOverloads.tpp"
885
886#define OPERATION_LOGIC OperationTgamma
887#define FUNCTION tgammaf
888#include "unaryOverloads.tpp"
889
890#define OPERATION_LOGIC OperationTgamma
891#define FUNCTION tgammal
892#include "unaryOverloads.tpp"
893
895 /*******************************************************************************/
898
900 template<typename Real, typename Arg>
902 using std::to_string;
903
905 }
906
908}
909
910namespace std {
911
912 using codi::abs;
913 using codi::acos;
914 using codi::acosf;
915 using codi::acosl;
916 using codi::asin;
917 using codi::asinf;
918 using codi::asinl;
919 using codi::atan;
920 using codi::atanf;
921 using codi::atanh;
922 using codi::atanhf;
923 using codi::atanhl;
924 using codi::atanl;
925 using codi::cbrt;
926 using codi::cbrtf;
927 using codi::cbrtl;
928 using codi::ceil;
929 using codi::ceilf;
930 using codi::ceill;
931 using codi::cos;
932 using codi::cosf;
933 using codi::cosh;
934 using codi::coshf;
935 using codi::coshl;
936 using codi::cosl;
937 using codi::erf;
938 using codi::erfc;
939 using codi::erfcf;
940 using codi::erfcl;
941 using codi::erff;
942 using codi::erfl;
943 using codi::exp;
944 using codi::expf;
945 using codi::expl;
946 using codi::fabs;
947 using codi::fabsf;
948 using codi::fabsl;
949 using codi::floor;
950 using codi::floorf;
951 using codi::floorl;
952 using codi::isfinite;
953 using codi::isinf;
954 using codi::isnan;
955 using codi::isnormal;
956 using codi::log;
957 using codi::log10;
958 using codi::log10f;
959 using codi::log10l;
960 using codi::logf;
961 using codi::logl;
962 using codi::round;
963 using codi::roundf;
964 using codi::roundl;
965 using codi::sin;
966 using codi::sinf;
967 using codi::sinh;
968 using codi::sinhf;
969 using codi::sinhl;
970 using codi::sinl;
971 using codi::sqrt;
972 using codi::sqrtf;
973 using codi::sqrtl;
974 using codi::tan;
975 using codi::tanf;
976 using codi::tanh;
977 using codi::tanhf;
978 using codi::tanhl;
979 using codi::tanl;
980 using codi::tgamma;
981 using codi::tgammaf;
982 using codi::tgammal;
983
984 using codi::to_string;
985}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
bool constexpr CheckExpressionArguments
Check for invalid arguments to expressions like division by zero.
Definition config.h:146
PassiveReal< Type > const & getPassiveValue(Type const &v)
Get the basic primal value of the type.
Definition realTraits.hpp:127
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
RealTraits::PassiveReal< Real > round(ExpressionInterface< Real, Arg > const &arg)
Function overload for round.
Definition unaryOperators.hpp:637
RealTraits::PassiveReal< Real > ceil(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceil.
Definition unaryOperators.hpp:343
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
RealTraits::PassiveReal< Real > roundf(ExpressionInterface< Real, Arg > const &arg)
Function overload for roundf.
Definition unaryOperators.hpp:643
bool isfinite(ExpressionInterface< Real, Arg > const &arg)
Function overload for isfinite.
Definition unaryOperators.hpp:539
RealTraits::PassiveReal< Real > floorf(ExpressionInterface< Real, Arg > const &arg)
Function overload for floorf.
Definition unaryOperators.hpp:527
bool isnan(ExpressionInterface< Real, Arg > const &arg)
Function overload for isnan.
Definition unaryOperators.hpp:551
std::string to_string(ExpressionInterface< Real, Arg > const &arg)
Function overload for to_string.
Definition unaryOperators.hpp:901
RealTraits::PassiveReal< Real > roundl(ExpressionInterface< Real, Arg > const &arg)
Function overload for roundl.
Definition unaryOperators.hpp:649
RealTraits::PassiveReal< Real > floorl(ExpressionInterface< Real, Arg > const &arg)
Function overload for floorl.
Definition unaryOperators.hpp:533
ExpressionInterface< Real, Arg > const & operator+(ExpressionInterface< Real, Arg > const &arg)
Function overload for operator +.
Definition unaryOperators.hpp:79
RealTraits::PassiveReal< Real > ceilf(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceilf.
Definition unaryOperators.hpp:349
RealTraits::PassiveReal< Real > floor(ExpressionInterface< Real, Arg > const &arg)
Function overload for floor.
Definition unaryOperators.hpp:521
bool isinf(ExpressionInterface< Real, Arg > const &arg)
Function overload for isinf.
Definition unaryOperators.hpp:545
bool isnormal(ExpressionInterface< Real, Arg > const &arg)
Function overload for isnormal.
Definition unaryOperators.hpp:557
RealTraits::PassiveReal< Real > ceill(ExpressionInterface< Real, Arg > const &arg)
Function overload for ceill.
Definition unaryOperators.hpp:355
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Impl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:75
UnaryOperation implementation for abs.
Definition unaryOperators.hpp:118
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:125
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:121
static RealTraits::PassiveReal< Real > gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:131
UnaryOperation implementation for acos.
Definition unaryOperators.hpp:160
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:173
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:167
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:163
UnaryOperation implementation for asin.
Definition unaryOperators.hpp:197
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:204
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:210
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:200
UnaryOperation implementation for atan.
Definition unaryOperators.hpp:234
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:241
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:237
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:247
UnaryOperation implementation for atanh.
Definition unaryOperators.hpp:266
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:279
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:269
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:273
UnaryOperation implementation for cbrt.
Definition unaryOperators.hpp:303
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:306
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:316
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:310
UnaryOperation implementation for cos.
Definition unaryOperators.hpp:361
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:364
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:368
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:374
UnaryOperation implementation for cosh.
Definition unaryOperators.hpp:393
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:396
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:406
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:400
UnaryOperation implementation for erf.
Definition unaryOperators.hpp:425
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:432
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:428
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:438
UnaryOperation implementation for erfc.
Definition unaryOperators.hpp:457
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:464
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:470
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:460
UnaryOperation implementation for exp.
Definition unaryOperators.hpp:489
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:496
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:492
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:502
UnaryOperation implementation for log10.
Definition unaryOperators.hpp:600
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:603
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:607
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:613
UnaryOperation implementation for log.
Definition unaryOperators.hpp:563
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:570
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:576
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:566
UnaryOperation implementation for sin.
Definition unaryOperators.hpp:655
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:662
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:668
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:658
UnaryOperation implementation for sinh.
Definition unaryOperators.hpp:687
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:690
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:694
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:700
UnaryOperation implementation for sqrt.
Definition unaryOperators.hpp:719
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:732
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:726
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:722
UnaryOperation implementation for tan.
Definition unaryOperators.hpp:759
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:766
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:762
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:772
UnaryOperation implementation for tanh.
Definition unaryOperators.hpp:797
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:810
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:804
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:800
UnaryOperation implementation for tgamma.
Definition unaryOperators.hpp:829
static Real gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:842
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:836
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:832
UnaryOperation implementation for operator -.
Definition unaryOperators.hpp:54
static RealTraits::PassiveReal< Real > gradient(Arg const &arg, Real const &result)
Definition unaryOperators.hpp:67
static Real primal(Arg const &arg)
Definition unaryOperators.hpp:61
T_Real Real
See BinaryOperation.
Definition unaryOperators.hpp:57
Interface for implementing the logic for a UnaryExpression.
Definition unaryExpression.hpp:55