OpenWalnut  1.5.0dev
WFiber_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WFIBER_TEST_H
26 #define WFIBER_TEST_H
27 
28 #include <string>
29 #include <vector>
30 
31 #include <cxxtest/TestSuite.h>
32 
33 #include "../../math/linearAlgebra/WPosition.h"
34 #include "../WFiber.h"
35 #include "WFiberTraits.h"
36 
37 /**
38  * Unit tests our WFiber class
39  */
40 class WFiberTest : public CxxTest::TestSuite
41 {
42 public:
43  /**
44  * Two fibers are equal if they have equal WPositions in same order
45  */
46  void testEqualityOperator( void )
47  {
48  WFiber fib1;
49  WFiber fib2;
50  fib1.push_back( WPosition( 1.2, 3.4, 5.6 ) );
51  fib1.push_back( WPosition( 7.8, 9.0, -1.2 ) );
52  fib2.push_back( WPosition( 1.2, 3.4, 5.6 ) );
53  fib2.push_back( WPosition( 7.8, 9.0, -1.2 ) );
54  TS_ASSERT_EQUALS( fib1, fib2 );
55  }
56 
57  /**
58  * dLt(Q,R) chooses just the maximum out come of either dt(Q,r) or dt(R,Q)
59  * and hence it is a symmetric metric.
60  */
61  void testDLTisSymmetric( void )
62  {
63  WFiber q;
64  q.push_back( WPosition( 0, 1, 0 ) );
65  q.push_back( WPosition( 0, 0, 0 ) );
66  WFiber r;
67  r.push_back( WPosition( 1, 1, 0 ) );
68  r.push_back( WPosition( 2, 2, 0 ) );
69 
70  TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, q, r ), std::sqrt( 5.0 ) / 2.0 );
71  TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, r, q ), std::sqrt( 5.0 ) / 2.0 );
72  }
73 
74  /**
75  * dSt(Q,R) chooses just the minimum outcome of either dt(Q,r) or dt(R,Q)
76  * and hence it is a symmetric metric.
77  */
78  void testDSTisSymmetric( void )
79  {
80  WFiber q;
81  q.push_back( WPosition( 0, 1, 0 ) );
82  q.push_back( WPosition( 0, 0, 0 ) );
83  WFiber r;
84  r.push_back( WPosition( 1, 1, 0 ) );
85  r.push_back( WPosition( 2, 2, 0 ) );
86 
87  TS_ASSERT_EQUALS( WFiber::distDST( 1.0, q, r ), std::sqrt( 2.0 ) / 2.0 );
88  TS_ASSERT_EQUALS( WFiber::distDST( 1.0, r, q ), std::sqrt( 2.0 ) / 2.0 );
89  }
90 
91  /**
92  * The dt(Q,R) measure (mean closest point distance) is not symmetric.
93  * distances below a certain threshold will be omitted.
94  */
95  void testDTMeasure( void )
96  {
97  WFiber q;
98  q.push_back( WPosition( 0, 1, 0 ) );
99  q.push_back( WPosition( 0, 0, 0 ) );
100  WFiber r;
101  r.push_back( WPosition( 1, 1, 0 ) );
102  r.push_back( WPosition( 2, 2, 0 ) );
103 
104  TS_ASSERT_EQUALS( WFiber::distDST( 1.0, q, r ), std::sqrt( 2.0 ) / 2.0 );
105  TS_ASSERT_EQUALS( WFiber::distDLT( 1.0, q, r ), std::sqrt( 5.0 ) / 2.0 );
106  }
107 };
108 
109 #endif // WFIBER_TEST_H
Unit tests our WFiber class.
Definition: WFiber_test.h:41
void testEqualityOperator(void)
Two fibers are equal if they have equal WPositions in same order.
Definition: WFiber_test.h:46
void testDTMeasure(void)
The dt(Q,R) measure (mean closest point distance) is not symmetric.
Definition: WFiber_test.h:95
void testDLTisSymmetric(void)
dLt(Q,R) chooses just the maximum out come of either dt(Q,r) or dt(R,Q) and hence it is a symmetric m...
Definition: WFiber_test.h:61
void testDSTisSymmetric(void)
dSt(Q,R) chooses just the minimum outcome of either dt(Q,r) or dt(R,Q) and hence it is a symmetric me...
Definition: WFiber_test.h:78
Represents a neural pathway.
Definition: WFiber.h:40
static double distDLT(double thresholdSquare, const WFiber &q, const WFiber &r)
This is the Larger thresholded distance as described by Zhang: http://dx.doi.org/10....
Definition: WFiber.cpp:104
static double distDST(double thresholdSquare, const WFiber &q, const WFiber &r)
This is the Smaller thresholded distance as described by Zhang: http://dx.doi.org/10....
Definition: WFiber.cpp:98
void push_back(const value_type &value)
Wrapper around std::vector member function.
Definition: WMixinVector.h:457
This only is a 3d double vector.