1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
25
#ifndef WOSSIMHELPER_TEST_H
26
#define WOSSIMHELPER_TEST_H
28
#include <cxxtest/TestSuite.h>
30
#include "../WOSSIMHelper.h"
33
* Tests for WOSSIMHelper.
35
class WOSSIMHelperTest : public CxxTest::TestSuite
39
* Test ComputeSVD function of WOSSIMHelper
41
void testComputeSVD( void )
44
const size_t nbRows = 3, nbCols = 3;
45
const double a = 1.2, b = 2.3, c = 3.4,
46
d = 4.5, e = 5.6, f = 6.7,
47
g = 3.4, h = 1.2, i = 7.0;
48
WMatrix< double > A( nbRows, nbCols );
60
WMatrix< double > U( nbRows, nbCols );
61
WMatrix< double > V( nbCols, nbCols );
62
WValue< double > S( nbCols );
64
WOSSIMHelper::computeSVD( A, U, V, S );
66
WMatrix< double > Sm( nbRows, nbCols );
71
WMatrix<double> svd( U*Sm*V.transposed() );
73
for( size_t row = 0; row < svd.getNbRows(); row++ )
75
for( size_t col = 0; col < svd.getNbCols(); col++ )
77
TS_ASSERT_DELTA( svd( row, col ), A( row, col ), 0.0001 );
83
* Test pseudoInverse function of WOSSIMHelper
85
// void testPseudoInverse( void )
87
// const size_t nbRows = 3, nbCols = 3;
88
// const double a = 1.2, b = 2.3, c = 3.4,
89
// d = 4.5, e = 5.6, f = 6.7,
90
// g = 3.4, h = 1.2, i = 7.0;
91
// WMatrix< double > A( nbRows, nbCols );
103
// WMatrix<double> Ainvers( WOSSIMHelper::pseudoInverse( A ) );
104
// WMatrix<double> I( A*Ainvers );
106
// for( size_t row = 0; row < I.getNbRows(); row++ )
108
// for( size_t col = 0; col < I.getNbCols(); col++ )
112
// TS_ASSERT_DELTA( I( row, col ), 1.0, 0.0001 );
116
// TS_ASSERT_DELTA( I( row, col ), 0.0, 0.0001 );
123
#endif // WOSSIMHELPER_TEST_H