My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
svd
libs
ap.cpp
Go to the documentation of this file.
1
#include "
svd_si.h
"
2
#ifdef HAVE_SVD
3
4
const
double
ap::machineepsilon
= 5
E
-16;
5
const
double
ap::maxrealnumber
= 1E300;
6
const
double
ap::minrealnumber
= 1
E
-300;
7
8
//
9
// ap::complex operations
10
//
11
bool
ap::operator==
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
12
{
return
lhs.
x
==rhs.
x
&& lhs.
y
==rhs.
y
; }
13
14
bool
ap::operator!=
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
15
{
return
lhs.
x
!=rhs.
x
|| lhs.
y
!=rhs.
y
; }
16
17
const
ap::complex
ap::operator+
(
const
ap::complex
& lhs)
18
{
return
lhs; }
19
20
const
ap::complex
ap::operator-
(
const
ap::complex
& lhs)
21
{
return
ap::complex
(-lhs.
x
, -lhs.
y
); }
22
23
const
ap::complex
ap::operator+
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
24
{
ap::complex
r = lhs; r += rhs;
return
r; }
25
26
const
ap::complex
ap::operator+
(
const
ap::complex
& lhs,
const
double
& rhs)
27
{
ap::complex
r = lhs; r += rhs;
return
r; }
28
29
const
ap::complex
ap::operator+
(
const
double
& lhs,
const
ap::complex
& rhs)
30
{
ap::complex
r = rhs; r += lhs;
return
r; }
31
32
const
ap::complex
ap::operator-
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
33
{
ap::complex
r = lhs; r -= rhs;
return
r; }
34
35
const
ap::complex
ap::operator-
(
const
ap::complex
& lhs,
const
double
& rhs)
36
{
ap::complex
r = lhs; r -= rhs;
return
r; }
37
38
const
ap::complex
ap::operator-
(
const
double
& lhs,
const
ap::complex
& rhs)
39
{
ap::complex
r = lhs; r -= rhs;
return
r; }
40
41
const
ap::complex
ap::operator*
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
42
{
return
ap::complex
(lhs.
x
*rhs.
x
- lhs.
y
*rhs.
y
, lhs.
x
*rhs.
y
+ lhs.
y
*rhs.
x
); }
43
44
const
ap::complex
ap::operator*
(
const
ap::complex
& lhs,
const
double
& rhs)
45
{
return
ap::complex
(lhs.
x
*rhs, lhs.
y
*rhs); }
46
47
const
ap::complex
ap::operator*
(
const
double
& lhs,
const
ap::complex
& rhs)
48
{
return
ap::complex
(lhs*rhs.
x
, lhs*rhs.
y
); }
49
50
const
ap::complex
ap::operator/
(
const
ap::complex
& lhs,
const
ap::complex
& rhs)
51
{
52
ap::complex
result
;
53
double
e;
54
double
f
;
55
if
( fabs(rhs.
y
)<fabs(rhs.
x
) )
56
{
57
e = rhs.
y
/rhs.
x
;
58
f
= rhs.
x
+rhs.
y
*e;
59
result
.x = (lhs.
x
+lhs.
y
*e)/
f
;
60
result
.y = (lhs.
y
-lhs.
x
*e)/
f
;
61
}
62
else
63
{
64
e = rhs.
x
/rhs.
y
;
65
f
= rhs.
y
+rhs.
x
*e;
66
result
.x = (lhs.
y
+lhs.
x
*e)/
f
;
67
result
.y = (-lhs.
x
+lhs.
y
*e)/
f
;
68
}
69
return
result
;
70
}
71
72
const
ap::complex
ap::operator/
(
const
double
& lhs,
const
ap::complex
& rhs)
73
{
74
ap::complex
result
;
75
double
e;
76
double
f
;
77
if
( fabs(rhs.
y
)<fabs(rhs.
x
) )
78
{
79
e = rhs.
y
/rhs.
x
;
80
f
= rhs.
x
+rhs.
y
*e;
81
result
.x = lhs/
f
;
82
result
.y = -lhs*e/
f
;
83
}
84
else
85
{
86
e = rhs.
x
/rhs.
y
;
87
f
= rhs.
y
+rhs.
x
*e;
88
result
.x = lhs*e/
f
;
89
result
.y = -lhs/
f
;
90
}
91
return
result
;
92
}
93
94
const
ap::complex
ap::operator/
(
const
ap::complex
& lhs,
const
double
& rhs)
95
{
return
ap::complex
(lhs.
x
/rhs, lhs.
y
/rhs); }
96
97
double
ap::abscomplex
(
const
ap::complex
&z)
98
{
99
double
w
;
100
double
xabs;
101
double
yabs;
102
double
v
;
103
104
xabs = fabs(z.
x
);
105
yabs = fabs(z.
y
);
106
w
= xabs>yabs ? xabs : yabs;
107
v
= xabs<yabs ? xabs : yabs;
108
if
(
v
==0 )
109
return
w
;
110
else
111
{
112
double
t =
v
/
w
;
113
return
w
*
sqrt
(1+t*t);
114
}
115
}
116
117
const
ap::complex
ap::conj
(
const
ap::complex
&z)
118
{
return
ap::complex
(z.
x
, -z.
y
); }
119
120
const
ap::complex
ap::csqr
(
const
ap::complex
&z)
121
{
return
ap::complex
(z.
x
*z.
x
-z.
y
*z.
y
, 2*z.
x
*z.
y
); }
122
123
//
124
// standard functions
125
//
126
int
ap::sign
(
double
x
)
127
{
128
if
(
x
>0 )
return
1;
129
if
(
x
<0 )
return
-1;
130
return
0;
131
}
132
133
double
ap::randomreal
()
134
{
135
int
i
= rand();
136
while
(
i
==RAND_MAX)
137
i
=rand();
138
return
double(
i
)/double(RAND_MAX);
139
}
140
141
int
ap::randominteger
(
int
maxv)
142
{
return
rand()%maxv; }
143
144
int
ap::round
(
double
x
)
145
{
return
int(floor(
x
+0.5)); }
146
147
int
ap::trunc
(
double
x
)
148
{
return
int(
x
>0 ? floor(
x
) : ceil(
x
)); }
149
150
int
ap::ifloor
(
double
x
)
151
{
return
int(floor(
x
)); }
152
153
int
ap::iceil
(
double
x
)
154
{
return
int(ceil(
x
)); }
155
156
double
ap::pi
()
157
{
return
3.14159265358979323846; }
158
159
double
ap::sqr
(
double
x
)
160
{
return
x
*
x
; }
161
162
int
ap::maxint
(
int
m1,
int
m2)
163
{
164
return
m1>m2 ? m1 : m2;
165
}
166
167
int
ap::minint
(
int
m1,
int
m2)
168
{
169
return
m1>m2 ? m2 : m1;
170
}
171
172
double
ap::maxreal
(
double
m1,
double
m2)
173
{
174
return
m1>m2 ? m1 : m2;
175
}
176
177
double
ap::minreal
(
double
m1,
double
m2)
178
{
179
return
m1>m2 ? m2 : m1;
180
}
181
#endif
i
int i
Definition
cfEzgcd.cc:132
x
Variable x
Definition
cfModGcd.cc:4090
f
FILE * f
Definition
checklibs.c:9
ap::complex
Definition
ap.h:60
ap::complex::x
double x
Definition
ap.h:100
ap::complex::y
double y
Definition
ap.h:100
result
return result
Definition
facAbsBiFact.cc:76
E
REvaluation E(1, terms.length(), IntRandom(25))
w
const CanonicalForm & w
Definition
facAbsFact.cc:51
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
sqrt
gmp_float sqrt(const gmp_float &a)
Definition
mpr_complex.cc:319
ap::maxint
int maxint(int m1, int m2)
Definition
ap.cpp:162
ap::iceil
int iceil(double x)
Definition
ap.cpp:153
ap::sqr
double sqr(double x)
Definition
ap.cpp:159
ap::operator*
const complex operator*(const complex &lhs, const complex &rhs)
Definition
ap.cpp:41
ap::csqr
const complex csqr(const complex &z)
Definition
ap.cpp:120
ap::machineepsilon
const double machineepsilon
Definition
svd_si.h:995
ap::round
int round(double x)
Definition
ap.cpp:144
ap::trunc
int trunc(double x)
Definition
ap.cpp:147
ap::minrealnumber
const double minrealnumber
Definition
svd_si.h:997
ap::randomreal
double randomreal()
Definition
ap.cpp:133
ap::randominteger
int randominteger(int maxv)
Definition
ap.cpp:141
ap::sign
int sign(double x)
Definition
ap.cpp:126
ap::maxreal
double maxreal(double m1, double m2)
Definition
ap.cpp:172
ap::abscomplex
const double abscomplex(const complex &z)
Definition
ap.cpp:97
ap::operator!=
const bool operator!=(const complex &lhs, const complex &rhs)
Definition
ap.cpp:14
ap::minreal
double minreal(double m1, double m2)
Definition
ap.cpp:177
ap::minint
int minint(int m1, int m2)
Definition
ap.cpp:167
ap::pi
double pi()
Definition
ap.cpp:156
ap::conj
const complex conj(const complex &z)
Definition
ap.cpp:117
ap::operator+
const complex operator+(const complex &lhs)
Definition
ap.cpp:17
ap::ifloor
int ifloor(double x)
Definition
ap.cpp:150
ap::operator/
const complex operator/(const complex &lhs, const complex &rhs)
Definition
ap.cpp:50
ap::maxrealnumber
const double maxrealnumber
Definition
svd_si.h:996
ap::operator==
const bool operator==(const complex &lhs, const complex &rhs)
Definition
ap.cpp:11
ap::operator-
const complex operator-(const complex &lhs)
Definition
ap.cpp:20
svd_si.h
Generated on
for My Project by
doxygen 1.17.0
for
Singular