My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
factory
fac_iterfor.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 "
fac_iterfor.h
"
11
12
#ifndef HAVE_NTL
13
14
void
15
IteratedFor::fill
(
int
from,
int
max
)
16
{
17
while
(
from
<
N
) {
18
imax
[
from
] =
max
;
19
index
[
from
] = 0;
20
from
++;
21
}
22
index
[
N
] =
max
;
23
}
24
25
IteratedFor::IteratedFor
(
int
from,
int
to,
int
max
) :
MAX
(
max
), FROM( from ), TO( to ),
N
( TO-FROM ),
last
(
false
)
26
{
27
ASSERT
(
N
>= 0 &&
max
>= 0,
"illegal iterated for"
);
28
index
=
new
int
[
N
+1];
29
imax =
new
int
[
N
+1];
30
fill( 0,
max
);
31
}
32
33
IteratedFor::IteratedFor
(
const
IteratedFor
& I ) :
MAX
( I.
MAX
), FROM( I.FROM ), TO( I.TO ),
N
( I.
N
),
last
( I.
last
)
34
{
35
index
=
new
int
[
N
+1];
36
imax =
new
int
[
N
+1];
37
for
(
int
i
= 0;
i
<=
N
;
i
++ ) {
38
index
[
i
] = I.
index
[
i
];
39
imax[
i
] = I.
imax
[
i
];
40
}
41
}
42
43
IteratedFor::~IteratedFor
()
44
{
45
delete
[]
index
;
46
delete
[]
imax
;
47
}
48
49
IteratedFor
&
50
IteratedFor::operator=
(
const
IteratedFor
& I )
51
{
52
if
(
this
!= &I ) {
53
if
(
N
!= I.
N
) {
54
N
= I.
N
;
55
delete
[]
index
;
56
delete
[]
imax
;
57
index
=
new
int
[
N
+1];
58
imax
=
new
int
[
N
+1];
59
}
60
FROM
= I.
FROM
;
61
TO
= I.
TO
;
62
MAX
= I.
MAX
;
63
last
= I.
last
;
64
for
(
int
i
= 0;
i
<=
N
;
i
++ ) {
65
index
[
i
] = I.
index
[
i
];
66
imax
[
i
] = I.
imax
[
i
];
67
}
68
}
69
return
*
this
;
70
}
71
72
void
73
IteratedFor::nextiteration
()
74
{
75
ASSERT
( !
last
,
"no more iterations"
);
76
if
(
index
[0] ==
MAX
)
77
last
=
true
;
78
else
{
79
if
(
index
[
N
-1] !=
imax
[
N
-1] ) {
80
index
[
N
-1]++;
81
index
[
N
]--;
82
}
83
else
{
84
int
i
=
N
-1,
m
=
index
[
N
];
85
while
(
i
> 0 &&
index
[
i
] ==
imax
[
i
] ) {
86
m
+=
imax
[
i
];
87
i
--;
88
}
89
index
[
i
]++;
m
--;
90
fill
(
i
+1,
m
);
91
}
92
}
93
}
94
95
int
96
IteratedFor::operator[]
(
int
i
)
const
97
{
98
ASSERT
(
i
>=
FROM
&&
i
<=
TO
,
"illegal index"
);
99
return
index
[
i
-
FROM
];
100
}
101
102
#ifndef NOSTREAMIO
103
OSTREAM
&
operator<<
(
OSTREAM
& os,
const
IteratedFor
& I )
104
{
105
os <<
"( "
<< I[I.
from
()];
106
for
(
int
i
= I.from()+1;
i
<= I.to();
i
++ )
107
os <<
", "
<< I[
i
];
108
os <<
" )"
;
109
return
os;
110
}
111
#endif
/* NOSTREAMIO */
112
#endif
OSTREAM
#define OSTREAM
Definition
canonicalform.h:16
N
const CanonicalForm CFMap CFMap & N
Definition
cfEzgcd.cc:56
m
int m
Definition
cfEzgcd.cc:128
i
int i
Definition
cfEzgcd.cc:132
false
return false
Definition
cfModGcd.cc:85
cf_assert.h
assertions for Factory
ASSERT
#define ASSERT(expression, message)
Definition
cf_assert.h:99
cf_defs.h
factory switches.
IteratedFor
Definition
fac_iterfor.h:19
IteratedFor::operator[]
int operator[](int) const
IteratedFor::imax
int * imax
Definition
fac_iterfor.h:27
IteratedFor::FROM
int FROM
Definition
fac_iterfor.h:22
IteratedFor::TO
int TO
Definition
fac_iterfor.h:23
IteratedFor::IteratedFor
IteratedFor(int from, int to, int max)
IteratedFor::nextiteration
void nextiteration()
IteratedFor::max
int max() const
Definition
fac_iterfor.h:37
IteratedFor::~IteratedFor
~IteratedFor()
IteratedFor::from
int from() const
Definition
fac_iterfor.h:34
IteratedFor::MAX
int MAX
Definition
fac_iterfor.h:21
IteratedFor::last
bool last
Definition
fac_iterfor.h:25
IteratedFor::N
int N
Definition
fac_iterfor.h:24
IteratedFor::fill
void fill(int from, int n)
IteratedFor::operator=
IteratedFor & operator=(const IteratedFor &)
IteratedFor::index
int * index
Definition
fac_iterfor.h:26
fac_iterfor.h
max
static int max(int a, int b)
Definition
fast_mult.cc:264
last
STATIC_VAR poly last
Definition
hdegree.cc:1138
MAX
#define MAX(a, b)
Definition
omDebug.c:100
index
static int index(p_Length length, p_Ord ord)
Definition
p_Procs_Impl.h:592
operator<<
ostream & operator<<(ostream &s, const spectrum &spec)
Definition
semic.cc:249
Generated on
for My Project by
doxygen 1.17.0
for
Singular