Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
7940c3c2
Commit
7940c3c2
authored
Feb 08, 2019
by
thomas.forbriger
Browse files
croposp [WP]: triples with fast stepping pairs works
parent
e0c04d57
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/ts/croposp/croposptest.cc
View file @
7940c3c2
...
...
@@ -28,8 +28,8 @@ using std::cerr;
using
std
::
endl
;
struct
Options
{
bool
pairs
,
verbose
;
unsigned
int
npairs
;
bool
pairs
,
verbose
,
triples
;
unsigned
int
npairs
,
ntriples
;
};
// struct Options
int
main
(
int
iargc
,
char
*
argv
[])
...
...
@@ -39,7 +39,7 @@ int main(int iargc, char* argv[])
char
usage_text
[]
=
{
CROPOSPTEST_VERSION
"
\n
"
"usage: croposptest [-v] [-pairs n]"
"
\n
"
"usage: croposptest [-v] [-pairs
n] [-triples
n]"
"
\n
"
" or: croposptest --help|-h"
"
\n
"
};
...
...
@@ -59,6 +59,8 @@ int main(int iargc, char* argv[])
{
"v"
,
arg_no
,
"-"
},
// 2: test pairs
{
"pairs"
,
arg_yes
,
"4"
},
// 3: test pairs
{
"triples"
,
arg_yes
,
"4"
},
{
NULL
}
};
...
...
@@ -84,6 +86,8 @@ int main(int iargc, char* argv[])
opt
.
verbose
=
cmdline
.
optset
(
1
);
opt
.
pairs
=
cmdline
.
optset
(
2
);
opt
.
npairs
=
cmdline
.
int_arg
(
2
);
opt
.
triples
=
cmdline
.
optset
(
3
);
opt
.
ntriples
=
cmdline
.
int_arg
(
3
);
// ----------------------------------------------------------------------
...
...
@@ -124,6 +128,58 @@ int main(int iargc, char* argv[])
}
}
// if opt.pairs
// ----------------------------------------------------------------------
if
(
opt
.
triples
)
{
croposp
::
Triples
triples_pf
(
opt
.
ntriples
,
true
);
croposp
::
Triples
triples_sf
(
opt
.
ntriples
,
false
);
cout
<<
TFXX_value
(
opt
.
ntriples
)
<<
" "
<<
TFXX_value
(
triples_pf
.
size
())
<<
" "
<<
TFXX_value
(
triples_pf
.
pairs
())
<<
" "
<<
TFXX_value
(
triples_pf
.
triples
())
<<
endl
;
cout
<<
TFXX_value
(
opt
.
ntriples
)
<<
" "
<<
TFXX_value
(
triples_sf
.
size
())
<<
" "
<<
TFXX_value
(
triples_sf
.
pairs
())
<<
" "
<<
TFXX_value
(
triples_sf
.
triples
())
<<
endl
;
cout
<<
endl
<<
"single cycles fast:"
<<
endl
;
for
(
unsigned
int
k
=
1
;
k
<
opt
.
ntriples
;
++
k
)
{
for
(
unsigned
int
l
=
0
;
l
<
k
;
++
l
)
{
for
(
unsigned
int
i
=
0
;
i
<
opt
.
ntriples
;
++
i
)
{
if
((
k
!=
i
)
&&
(
l
!=
i
))
{
cout
<<
TFXX_value
(
i
)
<<
" "
<<
TFXX_value
(
k
)
<<
" "
<<
TFXX_value
(
l
)
<<
" "
<<
TFXX_value
(
triples_pf
(
i
,
k
,
l
))
<<
endl
;
}
}
}
}
cout
<<
endl
<<
"pairs cycle fast:"
<<
endl
;
for
(
unsigned
int
i
=
0
;
i
<
opt
.
ntriples
;
++
i
)
{
for
(
unsigned
int
k
=
1
;
k
<
opt
.
ntriples
;
++
k
)
{
for
(
unsigned
int
l
=
0
;
l
<
k
;
++
l
)
{
if
((
k
!=
i
)
&&
(
l
!=
i
))
{
cout
<<
TFXX_value
(
i
)
<<
" "
<<
TFXX_value
(
k
)
<<
" "
<<
TFXX_value
(
l
)
<<
" "
<<
TFXX_value
(
triples_pf
(
i
,
k
,
l
))
<<
endl
;
}
}
}
}
}
// if (opt.triples)
}
/* ----- END OF croposptest.cc ----- */
src/ts/croposp/triples.cc
View file @
7940c3c2
...
...
@@ -61,27 +61,23 @@ namespace croposp {
const
unsigned
int
&
l
)
const
{
unsigned
int
retval
=
0
;
unsigned
int
npairs
=
this
->
pairs
();
unsigned
int
size
=
this
->
size
();
TFXX_assert
((
i
!=
k
)
&&
(
k
!=
l
)
&&
(
l
!=
i
),
"triple indices must be unique; report this as a bug"
);
TFXX_assert
((
i
<
size
)
&&
(
k
<
size
)
&&
(
l
<
size
),
"index value(s) out of range; report this as a bug"
);
croposp
::
Pairs
pairs
(
size
-
1
);
unsigned
int
kk
=
k
;
unsigned
int
ll
=
l
;
if
(
kk
>
i
)
{
--
kk
;
}
if
(
ll
>
i
)
{
--
ll
;
}
if
(
this
->
Mpairs_first
)
{
unsigned
int
ii
=
i
;
if
(
ii
>
k
)
{
--
ii
;
}
if
(
ii
>
l
)
{
--
ii
;
}
retval
=
this
->
Mpairs
.
operator
()(
k
,
l
)
+
ii
*
npairs
;
retval
=
pairs
(
kk
,
ll
)
+
i
*
pairs
.
pairs
();
}
else
{
croposp
::
Pairs
pairs
(
size
-
1
);
unsigned
int
kk
=
k
;
unsigned
int
ll
=
l
;
if
(
kk
>
i
)
{
--
kk
;
}
if
(
ll
>
i
)
{
--
ll
;
}
retval
=
pairs
(
kk
,
ll
)
+
i
*
npairs
;
retval
=
pairs
(
kk
,
ll
)
*
pairs
.
size
()
+
i
;
}
return
(
retval
);
}
// unsigned int Triples::operator()(const unsigned int& i,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment