25 #ifndef WTENSORSYM_TEST_H
26 #define WTENSORSYM_TEST_H
32 #include <cxxtest/TestSuite.h>
33 #include "../WTensorSym.h"
56 TS_ASSERT_EQUALS( w( 0, 0, 0 ), 2 );
57 TS_ASSERT_EQUALS( w( 0, 0, 1 ), 2 );
58 TS_ASSERT_EQUALS( w( 0, 1, 0 ), 2 );
59 TS_ASSERT_EQUALS( w( 0, 1, 1 ), 8 );
60 TS_ASSERT_EQUALS( w( 1, 0, 0 ), 2 );
61 TS_ASSERT_EQUALS( w( 1, 0, 1 ), 8 );
62 TS_ASSERT_EQUALS( w( 1, 1, 0 ), 8 );
63 TS_ASSERT_EQUALS( w( 1, 1, 1 ), 10 );
69 t( 0, 0, 0, 0 ) = 2.0;
71 TS_ASSERT_EQUALS( t( 0, 0, 0, 0 ), 2.0 );
79 std::vector< unsigned int > v( 3, 0 );
82 for( v[ 0 ] = 0; v[ 0 ] < 4; ++v[ 0 ] )
84 for( v[ 1 ] = 0; v[ 1 ] < 4; ++v[ 1 ] )
86 for( v[ 2 ] = 0; v[ 2 ] < 4; ++v[ 2 ] )
88 w[ v ] = v[ 0 ] + v[ 1 ] + v[ 2 ];
89 std::vector< unsigned int > v0 = v;
90 std::sort( v0.begin(), v0.end() );
91 TS_ASSERT_EQUALS( w[ v0 ], v[ 0 ] + v[ 1 ] + v[ 2 ] );
124 TS_ASSERT_EQUALS( t35d( 0, 4, 2 ), 0.0 );
125 TS_ASSERT_EQUALS( t35d( 1, 4, 0 ), 0.0 );
126 TS_ASSERT_EQUALS( t35d( 0, 3, 0 ), 0.0 );
127 TS_ASSERT_EQUALS( t35d( 2, 4, 1 ), 0.0 );
128 TS_ASSERT_EQUALS( t35d( 0, 2, 2 ), 0.0 );
129 TS_ASSERT_EQUALS( t35d( 4, 1, 4 ), 0.0 );
130 TS_ASSERT_EQUALS( t35d( 4, 4, 4 ), 0.0 );
131 TS_ASSERT_EQUALS( t35d( 3, 4, 3 ), 0.0 );
133 TS_ASSERT_EQUALS( t11d( 0 ), 0.0 );
134 TS_ASSERT_EQUALS( t22d( 0, 1 ), 0.0 );
147 TS_ASSERT_EQUALS( m( 1, 0 ), 2 );
148 TS_ASSERT_EQUALS( m( 1, 2 ), 0.456 );
157 w( 0, 0, 1, 1, 0, 1 ) = 4.0;
158 w( 1, 1, 0, 0, 0, 0 ) = 0.56;
163 TS_ASSERT_EQUALS( m( 0, 1, 0, 1, 0, 1 ), 4.0 );
164 TS_ASSERT_EQUALS( m( 1, 0, 0, 0, 1, 0 ), 0.56 );
165 TS_ASSERT_EQUALS( m( 0, 0, 0, 1, 0, 0 ), 0.0 );
182 TS_ASSERT_EQUALS( d, 3.0 );
189 TS_ASSERT_EQUALS( v[ 0 ], 3.0 );
196 TS_ASSERT_EQUALS( m( 1, 0 ), 3.0 );
208 t( 0, 0, 0, 0 ) = 2.5476;
209 t( 1, 1, 1, 1 ) = 3.5476;
210 t( 2, 2, 2, 2 ) = 4.5476;
211 t( 0, 0, 0, 1 ) = 5.5476;
212 t( 0, 0, 0, 2 ) = 6.5476;
213 t( 1, 1, 1, 0 ) = 7.5476;
214 t( 1, 1, 1, 2 ) = 8.5476;
215 t( 2, 2, 2, 0 ) = 9.5476;
216 t( 2, 2, 2, 1 ) = 10.5476;
217 t( 0, 0, 1, 2 ) = 11.5476;
218 t( 1, 1, 0, 2 ) = 12.5476;
219 t( 2, 2, 0, 1 ) = 13.5476;
220 t( 0, 0, 1, 1 ) = 14.5476;
221 t( 0, 0, 2, 2 ) = 15.5476;
222 t( 1, 1, 2, 2 ) = 16.5476;
225 std::vector< WVector3d > gradients;
226 gradients.push_back(
WVector3d( 1.0, 0.0, 0.0 ) );
227 gradients.push_back(
WVector3d( 0.0, 1.0, 0.0 ) );
228 gradients.push_back( normalize(
WVector3d( 1.0, 1.0, 0.0 ) ) );
229 gradients.push_back( normalize(
WVector3d( 0.3, 0.4, 0.5 ) ) );
230 gradients.push_back( normalize(
WVector3d( -7.0, 3.0, -1.0 ) ) );
232 for(
int k = 0; k < 5; ++k )
234 double res =
calcTens( t, gradients[ k ] );
251 for(
int a = 0; a < 3; ++a )
253 for(
int b = 0; b < 3; ++b )
255 for(
int c = 0; c < 3; ++c )
257 for(
int d = 0; d < 3; ++d )
259 res += v[ a ] * v[ b ] * v[ c ] * v[ d ] * t( a, b, c, d );
Matrix template class with variable number of rows and columns.
Test class for the WTensorSym template.
void testAccessOperator2()
Test access operator [].
void testCopyConstructor()
Test copy constructor.
void testEvaluateSphericalFunction()
The optimizations for symmetric tensors should not corrupt the result, so we compare the optimized ev...
void testCopyOperator()
Test copy operator.
void testStandardConstructor()
Test the standard constructor.
void testAccessOperator1()
Test access operator ().
double calcTens(WTensorSym< 4, 3, double > const &t, WVector3d const &v)
A helper function that implements the simple approach to tensor evaluation.
void testCastToVariousTypes()
Test casts to Data_T, WValue or WMatrix, depending on the order of the Tensor.
Implements a symmetric tensor that has the same number of components in every direction.
Data_T evaluateSphericalFunction(WValue< Data_T > const &gradient) const
Evaluate - for a given gradient - the spherical function represented by this symmetric tensor.
Base class for all higher level values like tensors, vectors, matrices and so on.