glucat
0.8.4
glucat
scalar_imp.h
Go to the documentation of this file.
1
#ifndef _GLUCAT_SCALAR_IMP_H
2
#define _GLUCAT_SCALAR_IMP_H
3
/***************************************************************************
4
GluCat : Generic library of universal Clifford algebra templates
5
scalar_imp.h : Define functions for scalar_t
6
-------------------
7
begin : 2001-12-20
8
copyright : (C) 2001-2014 by Paul C. Leopardi
9
***************************************************************************
10
11
This library is free software: you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as published
13
by the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
This library is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU Lesser General Public License for more details.
20
21
You should have received a copy of the GNU Lesser General Public License
22
along with this library. If not, see <http://www.gnu.org/licenses/>.
23
24
***************************************************************************
25
This library is based on a prototype written by Arvind Raja and was
26
licensed under the LGPL with permission of the author. See Arvind Raja,
27
"Object-oriented implementations of Clifford algebras in C++: a prototype",
28
in Ablamowicz, Lounesto and Parra (eds.)
29
"Clifford algebras with numeric and symbolic computations, Birkhauser, 1996."
30
***************************************************************************
31
See also Arvind Raja's original header comments and references in glucat.h
32
***************************************************************************/
33
34
#include "
glucat/portability.h
"
35
36
#include <boost/numeric/ublas/traits.hpp>
37
38
#include <cmath>
39
#include <limits>
40
41
namespace
glucat
42
{
44
// Reference: [AA], 2.4, p. 30-31
45
47
template
< >
48
template
<
typename
Other_Scalar_T >
49
inline
50
float
51
numeric_traits<float>::
52
to_scalar_t
(
const
Other_Scalar_T& val)
53
{
return
static_cast<
float
>
(
numeric_traits<Other_Scalar_T>::to_double
(val)); }
54
56
template
< >
57
template
<
typename
Other_Scalar_T >
58
inline
59
double
60
numeric_traits<double>::
61
to_scalar_t
(
const
Other_Scalar_T& val)
62
{
return
numeric_traits<Other_Scalar_T>::to_double
(val); }
63
64
#if defined(_GLUCAT_USE_QD)
65
template
< >
67
template
< >
68
inline
69
long
double
70
numeric_traits<long double>::
71
to_scalar_t
(
const
dd_real& val)
72
{
return
static_cast<
long
double
>
(val.x[0]) +
static_cast<
long
double
>
(val.x[1]); }
73
75
template
< >
76
template
< >
77
inline
78
long
double
79
numeric_traits<long double>::
80
to_scalar_t
(
const
qd_real& val)
81
{
return
static_cast<
long
double
>
(val.x[0]) +
static_cast<
long
double
>
(val.x[1]); }
82
84
template
< >
85
template
< >
86
inline
87
dd_real
88
numeric_traits<dd_real>::
89
to_scalar_t
(
const
long
double
& val)
90
{
return
dd_real(
double
(val),
double
(val -
static_cast<
long
double
>
(
double
(val)))); }
91
93
template
< >
94
template
< >
95
inline
96
dd_real
97
numeric_traits<dd_real>::
98
to_scalar_t
(
const
qd_real& val)
99
{
return
dd_real(val.x[0],val.x[1]); }
100
102
template
< >
103
template
< >
104
inline
105
qd_real
106
numeric_traits<qd_real>::
107
to_scalar_t
(
const
long
double
& val)
108
{
return
qd_real(
double
(val),
double
(val -
static_cast<
long
double
>
(
double
(val))),0.0,0.0); }
109
111
template
< >
112
template
< >
113
inline
114
qd_real
115
numeric_traits<qd_real>::
116
to_scalar_t
(
const
dd_real& val)
117
{
return
qd_real(val.x[0],val.x[1],0.0,0.0); }
118
#endif
119
121
template
<
typename
Scalar_T >
122
inline
123
typename
numeric_traits<Scalar_T>::promoted::type
124
to_promote
(
const
Scalar_T& val)
125
{
126
typedef
typename
numeric_traits<Scalar_T>::promoted::type
promoted_scalar_t;
127
return
numeric_traits<promoted_scalar_t>::to_scalar_t
(val);
128
}
129
131
template
<
typename
Scalar_T >
132
inline
133
typename
numeric_traits<Scalar_T>::demoted::type
134
to_demote
(
const
Scalar_T& val)
135
{
136
typedef
typename
numeric_traits<Scalar_T>::demoted::type
demoted_scalar_t;
137
return
numeric_traits<demoted_scalar_t>::to_scalar_t
(val);
138
}
139
}
140
141
#endif // _GLUCAT_SCALAR_IMP_H
portability.h
glucat::to_demote
numeric_traits< Scalar_T >::demoted::type to_demote(const Scalar_T &val)
Cast to demote.
Definition:
scalar_imp.h:163
glucat::numeric_traits::demoted::type
long double type
Definition:
long_double.h:78
glucat::numeric_traits::to_scalar_t
static Scalar_T to_scalar_t(const Other_Scalar_T &val)
Cast to Scalar_T.
Definition:
scalar.h:198
glucat::numeric_traits::to_double
static double to_double(const Scalar_T &val)
Cast to double.
Definition:
scalar.h:190
glucat
Definition:
clifford_algebra.h:39
glucat::to_promote
numeric_traits< Scalar_T >::promoted::type to_promote(const Scalar_T &val)
Cast to promote.
Definition:
scalar_imp.h:153
glucat::numeric_traits::promoted::type
double type
Definition:
scalar.h:202
Generated on Sun Jul 12 2020 00:00:00 for glucat by
1.8.18