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 
35 namespace cxsc{
36 using namespace fi_lib;
37 inline 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 
50 inline 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 
64 inline real sqr(const real &arg) throw() { return (arg*arg); }
65 inline real sqrt(const real & arg) { return q_sqrt(*(double *)&arg); }
66 // { return t_std_fct_call(t_sqte,arg); }
67 inline 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); }
69 inline 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 
81 inline real sin(const real & arg) throw() { return q_sin(*(double*)&arg); } // { return t_std_fct_call(t_sine,arg); }
82 inline real cos(const real & arg) throw() { return q_cos(*(double*)&arg); } // { return t_std_fct_call(t_cose,arg); }
83 inline real tan(const real & arg) throw() { return q_tan(*(double*)&arg); } //{ return t_std_fct_call(t_tane,arg); }
84 inline real cot(const real & arg) throw() { return q_cot(*(double*)&arg); } //{ return t_std_fct_call(t_cote,arg); }
85 
86 inline real asin(const real & arg) { return q_asin(*(double*)&arg); } // { return t_std_fct_call(t_asne,arg); }
87 inline real acos(const real & arg) { return q_acos(*(double*)&arg); } // { return t_std_fct_call(t_acse,arg); }
88 inline real atan(const real & arg) { return q_atan(*(double*)&arg); } // { return t_std_fct_call(t_atne,arg); }
89 inline real acot(const real & arg) { return q_acot(*(double*)&arg); } // { return t_std_fct_call(t_acte,arg); }
90 
91 inline real expm1(const real & arg)throw() { return q_expm(*(double*)&arg); } // { return t_std_fct_call(t_exme,arg); }
92 inline real lnp1(const real & arg) { return q_lg1p(*(double*)&arg); } // { return t_std_fct_call(t_lnpe,arg); }
93 
94 inline real exp(const real & arg) throw() { return q_exp(*(double*)&arg); } // { return t_std_fct_call(t_expe,arg); }
95 inline real ln(const real & arg) { return q_log(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
96 inline real log2(const real & arg) { return q_log2(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
97 inline real log10(const real & arg) { return q_lg10(*(double*)&arg); } // { return t_std_fct_call(t_lnee,arg); }
98 
99 inline real sinh(const real & arg) throw() { return q_sinh(*(double*)&arg); } // { return t_std_fct_call(t_snhe,arg); }
100 inline real cosh(const real & arg) throw() { return q_cosh(*(double*)&arg); } // { return t_std_fct_call(t_cshe,arg); }
101 inline real tanh(const real & arg) throw() { return q_tanh(*(double*)&arg); } // { return t_std_fct_call(t_tnhe,arg); }
102 inline real coth(const real & arg) throw() { return q_coth(*(double*)&arg); } // { return t_std_fct_call(t_cthe,arg); }
103 
104 inline real asinh(const real & arg) { return q_asnh(*(double*)&arg); } // { return t_std_fct_call(t_ashe,arg); }
105 inline real acosh(const real & arg) { return q_acsh(*(double*)&arg); } // { return t_std_fct_call(t_ache,arg); }
106 inline real atanh(const real & arg) { return q_atnh(*(double*)&arg); } // { return t_std_fct_call(t_anhe,arg); }
107 inline real acoth(const real & arg) { return q_acth(*(double*)&arg); } // { return t_std_fct_call(t_athe,arg); }
108 
120 inline real erf(const real & arg) { return q_erf(*(double*)&arg); } // { return t_std_fct_call(t_athe,arg); }
127 inline 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); }
130 inline 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 
143 inline real power(const real & arg,const int n) { return pow(arg,n); }
144 
145 } // namespace cxsc
146 
cxsc::ln
cinterval ln(const cinterval &z)
Calculates .
Definition: cimath.cpp:851
cxsc::lnp1
cinterval lnp1(const cinterval &z)
Calculates .
Definition: cimath.cpp:867
cxsc::atan
cinterval atan(const cinterval &z)
Calculates .
Definition: cimath.cpp:2938
cxsc::tanh
cinterval tanh(const cinterval &z)
Calculates .
Definition: cimath.cpp:565
cxsc::asin
cinterval asin(const cinterval &z)
Calculates .
Definition: cimath.cpp:2311
cxsc::cosh
cinterval cosh(const cinterval &z)
Calculates .
Definition: cimath.cpp:223
cxsc::sqrtm1
real sqrtm1(const real &)
Calculates .
Definition: rmath.inl:69
cxsc::tan
cinterval tan(const cinterval &z)
Calculates .
Definition: cimath.cpp:393
cxsc::acoth
cinterval acoth(const cinterval &z)
Calculates .
Definition: cimath.cpp:3330
cxsc::sinh
cinterval sinh(const cinterval &z)
Calculates .
Definition: cimath.cpp:231
cxsc::coth
cinterval coth(const cinterval &z)
Calculates .
Definition: cimath.cpp:578
cxsc::log2
cinterval log2(const cinterval &z)
Calculates .
Definition: cimath.cpp:898
cxsc::erfc
interval erfc(const interval &a)
The complementary Gauss error function .
Definition: imath.cpp:361
cxsc::sqrt
cinterval sqrt(const cinterval &z)
Calculates .
Definition: cimath.cpp:1007
cxsc::pow
cinterval pow(const cinterval &z, const interval &p)
Calculates .
Definition: cimath.cpp:2074
cxsc::acosh
cinterval acosh(const cinterval &z)
Calculates .
Definition: cimath.cpp:2732
cxsc::erf
interval erf(const interval &a)
The Gauss error function .
Definition: imath.cpp:354
cxsc::power
cinterval power(const cinterval &z, int n)
Calculates .
Definition: cimath.cpp:1941
cxsc::cos
cinterval cos(const cinterval &z)
Calculates .
Definition: cimath.cpp:207
cxsc::acot
cinterval acot(const cinterval &z)
Calculates .
Definition: cimath.cpp:3130
cxsc
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
cxsc::sqr
cinterval sqr(const cinterval &z)
Calculates .
Definition: cimath.cpp:3342
cxsc::sin
cinterval sin(const cinterval &z)
Calculates .
Definition: cimath.cpp:215
cxsc::cot
cinterval cot(const cinterval &z)
Calculates .
Definition: cimath.cpp:538
cxsc::arg
interval arg(const cinterval &z)
Calculates .
Definition: cimath.cpp:741
cxsc::expm1
cinterval expm1(const cinterval &z)
Calculates .
Definition: cimath.cpp:177
cxsc::acos
cinterval acos(const cinterval &z)
Calculates .
Definition: cimath.cpp:2553
cxsc::exp
cinterval exp(const cinterval &z)
Calculates .
Definition: cimath.cpp:159
cxsc::atanh
cinterval atanh(const cinterval &z)
Calculates .
Definition: cimath.cpp:3317
cxsc::log10
cinterval log10(const cinterval &z)
Calculates .
Definition: cimath.cpp:903
cxsc::asinh
cinterval asinh(const cinterval &z)
Calculates .
Definition: cimath.cpp:2718
cxsc::real
The Scalar Type real.
Definition: real.hpp:114