My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
factory
cf_binom.cc
Go to the documentation of this file.
1
/* emacs edit mode for this file is -*- C++ -*- */
2
3
4
#include "config.h"
5
6
7
#include "
cf_assert.h
"
8
9
#include "
cf_defs.h
"
10
#include "
canonicalform.h
"
11
#include "
cf_binom.h
"
12
13
#ifndef HAVE_NTL
14
15
#define MAXPT 40
16
17
#define INITPT 10
18
19
VAR
CFArray
* ptZ = 0;
20
VAR
CFArray
* ptF = 0;
21
22
VAR
int
charac = 0;
23
VAR
int
gfdeg = 0;
24
VAR
int
ptZmax = INITPT;
25
VAR
int
ptFmax = 0;
26
27
void
28
resetFPT
()
29
{
30
ptFmax = 0;
31
}
32
33
void
34
initPT
( )
35
{
36
STATIC_VAR
bool
initialized =
false
;
37
38
if
( ! initialized ) {
39
initialized =
true
;
40
ptZ =
new
CFArray
[MAXPT+1];
41
ptF =
new
CFArray
[MAXPT+1];
42
int
i
,
j
;
43
ptZ[0] =
CFArray
(1); ptZ[0][0] = 1;
44
ptF[0] =
CFArray
(1);
45
for
(
i
= 1;
i
<= INITPT;
i
++ ) {
46
ptF[
i
] =
CFArray
(
i
+1);
47
ptZ[
i
] =
CFArray
(
i
+1);
48
(ptZ[
i
])[0] = 1;
49
for
(
j
= 1;
j
<
i
;
j
++ )
50
(ptZ[
i
])[
j
] = (ptZ[
i
-1])[
j
-1] + (ptZ[
i
-1])[
j
];
51
(ptZ[
i
])[
i
] = 1;
52
}
53
for
(
i
= INITPT+1;
i
<= MAXPT;
i
++ ) {
54
ptF[
i
] =
CFArray
(
i
+1);
55
ptZ[
i
] =
CFArray
(
i
+1);
56
}
57
ptZmax = INITPT;
58
ptFmax = 0;
59
}
60
}
61
62
CanonicalForm
63
binomialpower
(
const
Variable
&
x
,
const
CanonicalForm
& a,
int
n )
64
{
65
if
( n == 0 )
66
return
1;
67
else
if
( n == 1 )
68
return
x
+ a;
69
else
if
(
getCharacteristic
() == 0 ) {
70
if
( n <= MAXPT ) {
71
if
( n > ptZmax ) {
72
int
i
,
j
;
73
for
(
i
= ptZmax+1;
i
<= n;
i
++ ) {
74
(ptZ[
i
])[0] = 1;
75
for
(
j
= 1;
j
<
i
;
j
++ )
76
(ptZ[
i
])[
j
] = (ptZ[
i
-1])[
j
-1] + (ptZ[
i
-1])[
j
];
77
(ptZ[
i
])[
i
] = 1;
78
}
79
ptZmax = n;
80
}
81
CanonicalForm
result
= 0, apower = 1;
82
int
k
;
83
for
(
k
= n;
k
>= 0;
k
-- ) {
84
result
+=
power
(
x
,
k
) * apower * (ptZ[n])[
k
];
85
if
(
k
!= 0 )
86
apower *= a;
87
}
88
return
result
;
89
}
90
else
{
91
CanonicalForm
result
=
binomialpower
(
x
, a, MAXPT );
92
CanonicalForm
xa =
x
+ a;
93
int
i
;
94
for
(
i
= MAXPT;
i
< n;
i
++ )
95
result
*= xa;
96
return
result
;
97
}
98
}
99
else
{
100
if
(
getCharacteristic
() != charac || gfdeg !=
getGFDegree
() ) {
101
ptFmax = 0;
102
charac =
getCharacteristic
();
103
gfdeg =
getGFDegree
();
104
(ptF[0])[0] = 1;
105
}
106
if
( n <= MAXPT ) {
107
if
( n > ptFmax ) {
108
int
i
,
j
;
109
for
(
i
= ptFmax+1;
i
<= n;
i
++ ) {
110
(ptF[
i
])[0] = 1;
111
for
(
j
= 1;
j
<
i
;
j
++ )
112
(ptF[
i
])[
j
] = (ptF[
i
-1])[
j
-1] + (ptF[
i
-1])[
j
];
113
(ptF[
i
])[
i
] = 1;
114
}
115
ptFmax = n;
116
}
117
CanonicalForm
result
= 0, apower = 1;
118
int
k
;
119
for
(
k
= n;
k
>= 0;
k
-- ) {
120
result
+=
power
(
x
,
k
) * apower * (ptF[n])[
k
];
121
if
(
k
!= 0 )
122
apower *= a;
123
}
124
return
result
;
125
}
126
else
{
127
CanonicalForm
result
=
binomialpower
(
x
, a, MAXPT );
128
CanonicalForm
xa =
x
+ a;
129
int
i
;
130
for
(
i
= MAXPT;
i
< n;
i
++ )
131
result
*= xa;
132
return
result
;
133
}
134
}
135
}
136
#endif
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition
canonicalform.cc:1896
canonicalform.h
Header for factory's main class CanonicalForm.
getGFDegree
int getGFDegree()
Definition
cf_char.cc:75
CFArray
Array< CanonicalForm > CFArray
Definition
canonicalform.h:397
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition
cf_char.cc:70
i
int i
Definition
cfEzgcd.cc:132
k
int k
Definition
cfEzgcd.cc:99
x
Variable x
Definition
cfModGcd.cc:4090
cf_assert.h
assertions for Factory
cf_binom.h
initPT
void initPT()
resetFPT
void resetFPT()
binomialpower
CanonicalForm binomialpower(const Variable &, const CanonicalForm &, int)
cf_defs.h
factory switches.
CanonicalForm
factory's main class
Definition
canonicalform.h:86
Variable
factory's class for variables
Definition
factory.h:127
result
return result
Definition
facAbsBiFact.cc:76
j
int j
Definition
facHensel.cc:110
STATIC_VAR
#define STATIC_VAR
Definition
globaldefs.h:7
VAR
#define VAR
Definition
globaldefs.h:5
Generated on
for My Project by
doxygen 1.17.0
for
Singular