Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
3e609fbf
Commit
3e609fbf
authored
Dec 06, 2010
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Plain Diff
[MERGE]
parents
16d81ee3
859f9750
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
16 deletions
+108
-16
src/common/datastructures/WDendrogram.cpp
src/common/datastructures/WDendrogram.cpp
+14
-10
src/common/datastructures/WDendrogram.h
src/common/datastructures/WDendrogram.h
+2
-1
src/common/datastructures/test/WDendrogram_test.h
src/common/datastructures/test/WDendrogram_test.h
+44
-2
src/modules/gaussProcesses/detTractClusteringGP/WMDetTractClusteringGP.cpp
...Processes/detTractClusteringGP/WMDetTractClusteringGP.cpp
+2
-3
src/modules/gaussProcesses/detTractClusteringGP/test/WMDetTractClustering_test.h
...ses/detTractClusteringGP/test/WMDetTractClustering_test.h
+46
-0
No files found.
src/common/datastructures/WDendrogram.cpp
View file @
3e609fbf
...
...
@@ -31,6 +31,8 @@
#include <vector>
#include "../WAssert.h"
#include "../WLogger.h"
#include "../WStringUtils.h"
#include "WDendrogram.h"
WDendrogram
::
WDendrogram
(
size_t
n
)
...
...
@@ -86,11 +88,8 @@ std::string WDendrogram::toTXTString() const
level
[
i
]
=
std
::
max
(
level
[
left
],
level
[
right
]
)
+
1
;
preds
[
m_parents
[
i
]
].
insert
(
i
);
std
::
set
<
size_t
>
join
;
std
::
set_union
(
childsOfInnerNodes
[
m_parents
[
i
]
].
begin
(),
childsOfInnerNodes
[
m_parents
[
i
]
].
end
(),
childsOfInnerNodes
[
i
].
begin
(),
childsOfInnerNodes
[
i
].
end
(),
std
::
inserter
(
join
,
join
.
begin
()
)
);
std
::
set_union
(
childsOfInnerNodes
[
m_parents
[
i
]
].
begin
(),
childsOfInnerNodes
[
m_parents
[
i
]
].
end
(),
childsOfInnerNodes
[
i
].
begin
(),
childsOfInnerNodes
[
i
].
end
(),
std
::
inserter
(
join
,
join
.
begin
()
)
);
childsOfInnerNodes
[
m_parents
[
i
]
]
=
join
;
ss
<<
"("
<<
level
[
i
]
<<
", ("
;
size_t
numElements
=
childsOfInnerNodes
[
i
].
size
();
...
...
@@ -106,11 +105,16 @@ std::string WDendrogram::toTXTString() const
}
numElements
-=
1
;
}
ss
<<
" ("
<<
left
<<
", "
<<
right
<<
"), "
<<
m_heights
[
i
-
m_heights
.
size
()
+
1
]
<<
")"
<<
std
::
endl
;
// TODO(math): the needs to be made with a writer instead
std
::
ofstream
file
(
"/home/math/pansen.txt"
);
file
<<
ss
.
str
();
file
.
close
();
using
string_utils
::
operator
<<
;
ss
<<
"("
<<
left
<<
", "
<<
right
<<
"), "
<<
m_heights
[
i
-
m_heights
.
size
()
-
1
]
<<
")"
<<
std
::
endl
;
}
// TODO(math): the needs to be made with a writer instead
wlog
::
debug
(
"WDendrogram"
)
<<
"start writing the txt file to pansen.txt"
;
std
::
ofstream
file
(
"/home/math/pansen.txt"
);
file
<<
ss
.
str
();
file
.
close
();
wlog
::
debug
(
"WDendrogram"
)
<<
"written the txt file to pansen.txt"
;
return
ss
.
str
();
}
src/common/datastructures/WDendrogram.h
View file @
3e609fbf
...
...
@@ -25,8 +25,9 @@
#ifndef WDENDROGRAM_H
#define WDENDROGRAM_H
#include <
vector
>
#include <
sstream
>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
...
...
src/common/datastructures/test/WDendrogram_test.h
View file @
3e609fbf
...
...
@@ -27,6 +27,7 @@
#include <cxxtest/TestSuite.h>
#include "../../WLogger.h"
#include "../WDendrogram.h"
/**
...
...
@@ -36,10 +37,51 @@ class WDendrogramTest : public CxxTest::TestSuite
{
public:
/**
* When a new node is created, each member should be equal to zero.
* Check if the dendrogram correctly constructs the txt string. <dfn>($level, ($childs,...),
* ($left, $right), $similarity)\n</dfn> But for the leaves we have <dfn>(0,
* ($tractNum,))\n</dfn>.
\verbatim
.----'----. 0.32
| 8 |
0.4 .---'---. |
| 6 | .--'--. 0.6
0.8 .--'--. | | 7 |
| 5 | | | |
| | | | |
0 1 2 3 4
\endverbatim
*/
void
test
NewNodesHaveAlwaysZerosAssignedInitially
(
void
)
void
test
StringCreation
(
void
)
{
WDendrogram
d
(
5
);
d
.
merge
(
0
,
1
,
0.8
);
// 5
d
.
merge
(
5
,
2
,
0.4
);
// 6
d
.
merge
(
3
,
4
,
0.60
);
// 7
d
.
merge
(
6
,
7
,
0.32
);
// 8
std
::
stringstream
ss
;
ss
<<
"(0, (0,))"
<<
std
::
endl
;
ss
<<
"(0, (1,))"
<<
std
::
endl
;
ss
<<
"(0, (2,))"
<<
std
::
endl
;
ss
<<
"(0, (3,))"
<<
std
::
endl
;
ss
<<
"(0, (4,))"
<<
std
::
endl
;
ss
<<
"(1, (0, 1), (0, 1), 0.8)"
<<
std
::
endl
;
ss
<<
"(2, (0, 1, 2), (2, 5), 0.4)"
<<
std
::
endl
;
ss
<<
"(1, (3, 4), (3, 4), 0.6)"
<<
std
::
endl
;
ss
<<
"(3, (0, 1, 2, 3, 4), (6, 7), 0.32)"
<<
std
::
endl
;
if
(
ss
.
str
()
!=
d
.
toTXTString
()
)
{
std
::
cout
<<
"Expected:"
<<
std
::
endl
<<
ss
.
str
();
std
::
cout
<<
"But got:"
<<
std
::
endl
<<
d
.
toTXTString
();
TS_FAIL
(
"Invalid dendrogram to string generation"
);
}
}
/**
* Sets up the WLogger to properly log some thing...
*/
void
setUp
(
void
)
{
WLogger
::
startup
();
}
};
...
...
src/modules/gaussProcesses/detTractClusteringGP/WMDetTractClusteringGP.cpp
View file @
3e609fbf
...
...
@@ -138,8 +138,7 @@ boost::shared_ptr< WMDetTractClusteringGP::MST > WMDetTractClusteringGP::compute
// initialize the first the similarities to the root node.
const
WGaussProcess
&
root
=
dataSet
->
front
();
// is the root vertex of the MST
std
::
vector
<
double
>
similarities
(
dataSet
->
size
(),
0.0
);
similarities
[
0
]
=
wlimits
::
MAX_DOUBLE
;
// root node has maximal similarity and is selected first
for
(
size_t
i
=
1
;
i
<
dataSet
->
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
dataSet
->
size
();
++
i
)
{
const
WGaussProcess
&
p
=
(
*
dataSet
)[
i
];
if
(
root
.
getBB
().
minDistance
(
p
.
getBB
()
)
<
root
.
getMaxSegmentLength
()
+
p
.
getMaxSegmentLength
()
)
...
...
@@ -226,7 +225,7 @@ boost::shared_ptr< WDendrogram > WMDetTractClusteringGP::computeDendrogram( boos
size_t
u
=
cit
->
second
.
first
;
size_t
v
=
cit
->
second
.
second
;
// u and v may already
contain to
a cluster, thus we need their cannonical elements
// u and v may already
be a member of
a cluster, thus we need their cannonical elements
size_t
cEu
=
uf
.
find
(
u
);
size_t
cEv
=
uf
.
find
(
v
);
...
...
src/modules/gaussProcesses/detTractClusteringGP/test/WMDetTractClustering_test.h
0 → 100644
View file @
3e609fbf
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMDETTRACTCLUSTERING_TEST_H
#define WMDETTRACTCLUSTERING_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WMDetTractClustering.h"
/**
* TODO(math): Document this!
*/
class
WMDetTractClusteringTest
:
public
CxxTest
::
TestSuite
{
public:
/**
* TODO(math): Document this!
*/
void
testSomething
(
void
)
{
}
};
#endif // WMDETTRACTCLUSTERING_TEST_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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