C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
rmath.inl
1/*
2** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3**
4** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5** Universitaet Karlsruhe, Germany
6** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7** Universitaet Wuppertal, Germany
8**
9** This library is free software; you can redistribute it and/or
10** modify it under the terms of the GNU Library General Public
11** License as published by the Free Software Foundation; either
12** version 2 of the License, or (at your option) any later version.
13**
14** This library is distributed in the hope that it will be useful,
15** but WITHOUT ANY WARRANTY; without even the implied warranty of
16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17** Library General Public License for more details.
18**
19** You should have received a copy of the GNU Library General Public
20** License along with this library; if not, write to the Free
21** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24/* CVS $Id: rmath.inl,v 1.31 2014/01/30 17:23:48 cxsc Exp $ */
25
26#include "rtsrmath.h"
27#include "xscclass.hpp"
28#define CXSC_INCLUDE
29#undef LINT_ARGS
30#include <fi_lib.hpp>
31#undef CXSC_INCLUDE
32
33//#include "fi_lib.hpp"
34
35namespace cxsc{
36using namespace fi_lib;
37inline real t_std_fct_call(int (fct)(const ExtReal *,ExtReal *),const real &arg)
38{
39 real erg(arg);
40 int rnd=t_grnd();
41 t_srnd(NEAR);
42 ExtReal a,r;
43 t_ltoe((LongReal*)&erg,&a);
44 fct(&a,&r);
45 t_etol(&r,(LongReal*)&erg);
46 t_srnd(rnd);
47 return erg;
48}
49
50inline real t_std_fct_call(int (fct)(const ExtReal *,const ExtReal *,ExtReal *),const real & arg1, const real & arg2)
51{
52 real erg(arg1),expo(arg2); // expo semioptimal.. :I
53 int rnd=t_grnd();
54 t_srnd(NEAR);
55 ExtReal a,b,r;
56 t_ltoe((LongReal*)&erg,&a);
57 t_ltoe((LongReal*)&expo,&b);
58 fct(&a,&b,&r);
59 t_etol(&r,(LongReal*)&erg);
60 t_srnd(rnd);
61 return erg;
62}
63
64inline real sqr(const real &arg) noexcept { return (arg*arg); }
65inline real sqrt(const real & arg) { return q_sqrt(*(double *)&arg); }
66// { return t_std_fct_call(t_sqte,arg); }
67inline real sqrt(const real & arg,int n) { return pow(arg,1.0/n); }
68// inline real sqrtm1(const real & arg) { return t_std_fct_call(t_sqme,arg); }
69inline real sqrtm1(const real & arg) {
70 real erg(arg);
71 int rnd=t_grnd();
72 t_srnd(NEAR);
73 ExtReal a,r;
74 t_ltoe((LongReal*)&erg,&a);
75 t_sqme(&a,&r);
76 t_etol(&r,(LongReal*)&erg);
77 t_srnd(rnd);
78 return erg;
79}
80
81inline real sin(const real & arg) noexcept { return q_sin(*(double*)&arg); } // { return t_std_fct_call(t_sine,arg); }
82inline real cos(const real & arg) noexcept { return q_cos(*(double*)&arg); } // { return t_std_fct_call(t_cose,arg); }
83inline real tan(const real & arg) noexcept { return q_tan(*(double*)&arg); } //{ return t_std_fct_call(t_tane,arg); }
84inline real cot(const real & arg) noexcept { return q_cot(*(double*)&arg); } //{ return t_std_fct_call(t_cote,arg); }
85
86inline real asin(const real & arg) { return q_asin(*(double*)&arg); } // { return t_std_fct_call(t_asne,arg); }
87inline real acos(const real & arg) { return q_acos(*(double*)&arg); } // { return t_std_fct_call(t_acse,arg); }
88inline real atan(const real & arg) { return q_atan(*(double*)&arg); } // { return t_std_fct_call(t_atne,arg); }
89inline real acot(const real & arg) { return q_acot(*(double*)&arg); } // { return t_std_fct_call(t_acte,arg); }
90
91inline real expm1(const real & arg)throw() { return q_expm(*(double*)&arg); } // { return t_std_fct_call(t_exme,arg); }
92inline real lnp1(const real & arg) { return q_lg1p(*(double*)&arg); } // { return t_std_fct_call(t_lnpe,arg); }
93
94inline real exp(const real & arg) noexcept { return q_exp(*(double*)&arg); } // { return t_std_fct_call(t_expe,arg); }
95inline real ln(const real & arg) { return q_log(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
96inline real log2(const real & arg) { return q_log2(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
97inline real log10(const real & arg) { return q_lg10(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
98
99inline real sinh(const real & arg) noexcept { return q_sinh(*(double*)&arg); } // { return t_std_fct_call(t_snhe,arg); }
100inline real cosh(const real & arg) noexcept { return q_cosh(*(double*)&arg); } // { return t_std_fct_call(t_cshe,arg); }
101inline real tanh(const real & arg) noexcept { return q_tanh(*(double*)&arg); } // { return t_std_fct_call(t_tnhe,arg); }
102inline real coth(const real & arg) noexcept { return q_coth(*(double*)&arg); } // { return t_std_fct_call(t_cthe,arg); }
103
104inline real asinh(const real & arg) { return q_asnh(*(double*)&arg); } // { return t_std_fct_call(t_ashe,arg); }
105inline real acosh(const real & arg) { return q_acsh(*(double*)&arg); } // { return t_std_fct_call(t_ache,arg); }
106inline real atanh(const real & arg) { return q_atnh(*(double*)&arg); } // { return t_std_fct_call(t_anhe,arg); }
107inline real acoth(const real & arg) { return q_acth(*(double*)&arg); } // { return t_std_fct_call(t_athe,arg); }
108
120inline real erf(const real & arg) { return q_erf(*(double*)&arg); } // { return t_std_fct_call(t_athe,arg); }
127inline real erfc(const real & arg) { return q_erfc(*(double*)&arg); } // { return t_std_fct_call(t_athe,arg); }
128
129//inline real pow(const real & arg,const real &expo) { return t_std_fct_call(t_powe,arg,expo); }
130inline real pow(const real & arg,const real &expo) {
131 real erg(arg),expohelp(expo); // expo semioptimal.. :I
132 int rnd=t_grnd();
133 t_srnd(NEAR);
134 ExtReal a,b,r;
135 t_ltoe((LongReal*)&erg,&a);
136 t_ltoe((LongReal*)&expohelp,&b);
137 t_powe(&a,&b,&r);
138 t_etol(&r,(LongReal*)&erg);
139 t_srnd(rnd);
140 return erg;
141}
142
143inline real power(const real & arg,const int n) { return pow(arg,n); }
144
145} // namespace cxsc
146
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
interval erf(const interval &a)
The Gauss error function .
Definition imath.cpp:354
cinterval asinh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:2718
cinterval coth(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:578
cinterval log2(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:898
cinterval power(const cinterval &z, int n) noexcept
Calculates .
Definition cimath.cpp:1941
cinterval log10(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:903
cinterval ln(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:851
cinterval pow(const cinterval &z, const interval &p) noexcept
Calculates .
Definition cimath.cpp:2074
cinterval sinh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:231
cinterval asin(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:2311
cinterval tan(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:393
interval arg(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:741
cinterval acos(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:2553
cinterval acosh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:2732
real sqrtm1(const real &)
Calculates .
Definition rmath.inl:69
cinterval cosh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:223
cinterval cos(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:207
cinterval exp(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:159
interval erfc(const interval &a)
The complementary Gauss error function .
Definition imath.cpp:361
cinterval tanh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:565
cinterval expm1(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:177
cinterval cot(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:538
cinterval sqrt(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:1007
cinterval acot(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:3130
cinterval sqr(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:3342
cinterval lnp1(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:867
cinterval atan(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:2938
cinterval atanh(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:3317
cinterval acoth(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:3330
cinterval sin(const cinterval &z) noexcept
Calculates .
Definition cimath.cpp:215