Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sander, Oliver
dune-gfe
Compare revisions
5db924c4105eabb2bfb4b0d22219d5872c1fc2c1 to master
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
osander/dune-gfe
Select target project
No results found
master
Select Git revision
Swap
Target
spraetor/dune-gfe
Select target project
osander/dune-gfe
lnebel/dune-gfe
spraetor/dune-gfe
3 results
5db924c4105eabb2bfb4b0d22219d5872c1fc2c1
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/svdtest.cc
+2
-2
2 additions, 2 deletions
test/svdtest.cc
test/targetspacetest.cc
+14
-14
14 additions, 14 deletions
test/targetspacetest.cc
test/valuefactory.hh
+255
-250
255 additions, 250 deletions
test/valuefactory.hh
with
271 additions
and
266 deletions
test/svdtest.cc
View file @
48b9358e
...
...
@@ -16,7 +16,7 @@ int main()
int
nTestValues
=
5
;
double
maxDiff
=
0
;
MultiIndex
index
(
N
*
M
,
nTestValues
);
GFE
::
MultiIndex
index
(
N
*
M
,
nTestValues
);
int
numIndices
=
index
.
cycle
();
for
(
int
i
=
0
;
i
<
numIndices
;
i
++
,
++
index
)
{
...
...
@@ -32,7 +32,7 @@ int main()
FieldMatrix
<
double
,
N
,
N
>
v
;
FieldMatrix
<
double
,
N
,
M
>
testMatrixBackup
=
testMatrix
;
svdcmp
(
testMatrix
,
w
,
v
);
GFE
::
svdcmp
(
testMatrix
,
w
,
v
);
// Multiply the three matrices to see whether we get the original one back
FieldMatrix
<
double
,
N
,
M
>
product
(
0
);
...
...
This diff is collapsed.
Click to expand it.
test/targetspacetest.cc
View file @
48b9358e
...
...
@@ -231,9 +231,9 @@ void testDerivativeOfHessianOfDistanceSquared(const TargetSpace& a, const Target
// Test mixed third derivative with respect to first (once) and second (twice) argument
/////////////////////////////////////////////////////////////////////////////////////////////
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d2d2d2
=
TargetSpace
::
thirdDerivativeOfDistanceSquaredWRTSecondArgument
(
a
,
b
);
GFE
::
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d2d2d2
=
TargetSpace
::
thirdDerivativeOfDistanceSquaredWRTSecondArgument
(
a
,
b
);
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d2d2d2_fd
;
GFE
::
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d2d2d2_fd
;
for
(
size_t
i
=
0
;
i
<
embeddedDim
;
i
++
)
{
...
...
@@ -270,9 +270,9 @@ void testMixedDerivativeOfHessianOfDistanceSquared(const TargetSpace& a, const T
// Test mixed third derivative with respect to first (once) and second (twice) argument
/////////////////////////////////////////////////////////////////////////////////////////////
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d1d2d2
=
TargetSpace
::
thirdDerivativeOfDistanceSquaredWRTFirst1AndSecond2Argument
(
a
,
b
);
GFE
::
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d1d2d2
=
TargetSpace
::
thirdDerivativeOfDistanceSquaredWRTFirst1AndSecond2Argument
(
a
,
b
);
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d1d2d2_fd
;
GFE
::
Tensor3
<
double
,
embeddedDim
,
embeddedDim
,
embeddedDim
>
d1d2d2_fd
;
for
(
size_t
i
=
0
;
i
<
embeddedDim
;
i
++
)
{
...
...
@@ -359,7 +359,7 @@ void test()
std
::
cout
<<
"Testing class "
<<
className
<
TargetSpace
>
()
<<
std
::
endl
;
std
::
vector
<
TargetSpace
>
testPoints
;
ValueFactory
<
TargetSpace
>::
get
(
testPoints
);
GFE
::
ValueFactory
<
TargetSpace
>::
get
(
testPoints
);
int
nTestPoints
=
testPoints
.
size
();
...
...
@@ -397,23 +397,23 @@ void test()
int
main
()
try
{
// Test the RealTuple class
test
<
RealTuple
<
double
,
1
>
>
();
test
<
RealTuple
<
double
,
3
>
>
();
test
<
GFE
::
RealTuple
<
double
,
1
>
>
();
test
<
GFE
::
RealTuple
<
double
,
3
>
>
();
// Test the UnitVector class
test
<
UnitVector
<
double
,
2
>
>
();
test
<
UnitVector
<
double
,
3
>
>
();
test
<
UnitVector
<
double
,
4
>
>
();
test
<
GFE
::
UnitVector
<
double
,
2
>
>
();
test
<
GFE
::
UnitVector
<
double
,
3
>
>
();
test
<
GFE
::
UnitVector
<
double
,
4
>
>
();
// Test the rotation class
test
<
Rotation
<
double
,
3
>
>
();
test
<
GFE
::
Rotation
<
double
,
3
>
>
();
// Test the ProductManifold class
test
<
Dune
::
GFE
::
ProductManifold
<
RealTuple
<
double
,
1
>
,
Rotation
<
double
,
3
>
,
UnitVector
<
double
,
2
>
>
>
();
test
<
Dune
::
GFE
::
ProductManifold
<
Rotation
<
double
,
3
>
,
UnitVector
<
double
,
5
>
>
>
();
test
<
GFE
::
ProductManifold
<
GFE
::
RealTuple
<
double
,
1
>
,
GFE
::
Rotation
<
double
,
3
>
,
GFE
::
UnitVector
<
double
,
2
>
>
>
();
test
<
GFE
::
ProductManifold
<
GFE
::
Rotation
<
double
,
3
>
,
GFE
::
UnitVector
<
double
,
5
>
>
>
();
//
// test<HyperbolicHalfspacePoint<double,2> >();
// test<
GFE::
HyperbolicHalfspacePoint<double,2> >();
}
catch
(
Exception
&
e
)
{
...
...
This diff is collapsed.
Click to expand it.
test/valuefactory.hh
View file @
48b9358e
...
...
@@ -10,355 +10,360 @@
#include
<dune/gfe/spaces/rotation.hh>
#include
<dune/gfe/spaces/unitvector.hh>
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the generic dummy. The actual work is done in specializations.
*/
template
<
class
T
>
class
ValueFactory
namespace
Dune
::
GFE
{
public:
static
void
get
(
std
::
vector
<
T
>&
values
);
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the generic dummy. The actual work is done in specializations.
*/
template
<
class
T
>
class
ValueFactory
{
public:
static
void
get
(
std
::
vector
<
T
>&
values
);
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for RealTuple<1>
*/
template
<
>
class
ValueFactory
<
RealTuple
<
double
,
1
>
>
{
public:
static
void
get
(
std
::
vector
<
RealTuple
<
double
,
1
>
>&
values
)
{
std
::
vector
<
double
>
testPoints
=
{
-
3
,
-
1
,
0
,
2
,
4
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for RealTuple<1>
*/
template
<
>
class
ValueFactory
<
RealTuple
<
double
,
1
>
>
{
public:
static
void
get
(
std
::
vector
<
RealTuple
<
double
,
1
>
>&
values
)
{
values
.
resize
(
testPoints
.
size
())
;
std
::
vector
<
double
>
testPoints
=
{
-
3
,
-
1
,
0
,
2
,
4
}
;
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
RealTuple
<
double
,
1
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
RealTuple
<
double
,
1
>
(
testPoints
[
i
]);
}
;
}
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for RealTuple<3>
*/
template
<
>
class
ValueFactory
<
RealTuple
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
RealTuple
<
double
,
3
>
>&
values
)
{
};
std
::
vector
<
Dune
::
FieldVector
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
-
0.304319
},
{
-
0.6
,
0.1
,
-
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
-
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
-
0.304319
}};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for RealTuple<3>
*/
template
<
>
class
ValueFactory
<
RealTuple
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
RealTuple
<
double
,
3
>
>&
values
)
{
values
.
resize
(
testPoints
.
size
());
std
::
vector
<
Dune
::
FieldVector
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
-
0.304319
},
{
-
0.6
,
0.1
,
-
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
-
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
-
0.304319
}};
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
RealTuple
<
double
,
3
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
RealTuple
<
double
,
3
>
(
testPoints
[
i
]);
}
;
}
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<2>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
2
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
2
>
>&
values
)
{
};
std
::
vector
<
std
::
array
<
double
,
2
>
>
testPoints
=
{{
1
,
0
},
{
0.5
,
0.5
},
{
0
,
1
},
{
-
0.5
,
0.5
},
{
-
1
,
0
},
{
-
0.5
,
-
0.5
},
{
0
,
-
1
},
{
0.5
,
-
0.5
},
{
0.1
,
1
},
{
1
,
.1
}};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<2>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
2
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
2
>
>&
values
)
{
values
.
resize
(
testPoints
.
size
())
;
std
::
vector
<
std
::
array
<
double
,
2
>
>
testPoints
=
{{
1
,
0
},
{
0.5
,
0.5
},
{
0
,
1
},
{
-
0.5
,
0.5
},
{
-
1
,
0
},
{
-
0.5
,
-
0.5
},
{
0
,
-
1
},
{
0.5
,
-
0.5
},
{
0.1
,
1
},
{
1
,
.1
}}
;
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
2
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
2
>
(
testPoints
[
i
]);
}
;
}
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<3>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
3
>
>&
values
)
{
std
::
vector
<
std
::
array
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
-
0.304319
},
{
-
0.6
,
0.1
,
-
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
-
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
-
0.304319
}};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<3>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
3
>
>&
values
)
{
values
.
resize
(
testPoints
.
size
());
std
::
vector
<
std
::
array
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0
},
{
0
,
1
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
-
0.304319
},
{
-
0.6
,
0.1
,
-
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
-
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
-
0.304319
}};
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
3
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
3
>
(
testPoints
[
i
]);
}
;
}
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<4>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
4
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
4
>
>&
values
)
{
std
::
vector
<
std
::
array
<
double
,
4
>
>
testPoints
=
{{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
,
0.5
},
{
-
0.490946
,
-
0.306456
,
0.81551
,
0.23
},{
-
0.944506
,
0.123687
,
-
0.304319
,
-
0.7
},
{
-
0.6
,
0.1
,
-
0.2
,
0.8
},{
0.45
,
0.12
,
0.517
,
0
},
{
-
0.1
,
0.3
,
-
0.1
,
0.73
},{
-
0.444506
,
0.123687
,
0.104319
,
-
0.23
},{
-
0.7
,
-
0.123687
,
-
0.304319
,
0.72
}};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for UnitVector<4>
*/
template
<
>
class
ValueFactory
<
UnitVector
<
double
,
4
>
>
{
public:
static
void
get
(
std
::
vector
<
UnitVector
<
double
,
4
>
>&
values
)
{
std
::
vector
<
std
::
array
<
double
,
4
>
>
testPoints
=
{{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
,
0.5
},
{
-
0.490946
,
-
0.306456
,
0.81551
,
0.23
},{
-
0.944506
,
0.123687
,
-
0.304319
,
-
0.7
},
{
-
0.6
,
0.1
,
-
0.2
,
0.8
},{
0.45
,
0.12
,
0.517
,
0
},
{
-
0.1
,
0.3
,
-
0.1
,
0.73
},{
-
0.444506
,
0.123687
,
0.104319
,
-
0.23
},{
-
0.7
,
-
0.123687
,
-
0.304319
,
0.72
}};
values
.
resize
(
testPoints
.
size
());
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
4
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
UnitVector
<
double
,
4
>
(
testPoints
[
i
]);
}
;
}
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for Rotation<3>
*/
template
<
>
class
ValueFactory
<
Rotation
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
Rotation
<
double
,
3
>
>&
values
)
{
std
::
vector
<
std
::
array
<
double
,
4
>
>
testPoints
=
{{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
,
0.5
},
{
-
0.490946
,
-
0.306456
,
0.81551
,
0.23
},{
-
0.944506
,
0.123687
,
-
0.304319
,
-
0.7
},
{
-
0.6
,
0.1
,
-
0.2
,
0.8
},{
0.45
,
0.12
,
0.517
,
0
},
{
-
0.1
,
0.3
,
-
0.1
,
0.73
},{
-
0.444506
,
0.123687
,
0.104319
,
-
0.23
},{
-
0.7
,
-
0.123687
,
-
0.304319
,
0.72
},
{
-
0.035669
,
-
0.463824
,
-
0.333265
,
0.820079
},
{
0.0178678
,
0.916836
,
0.367358
,
0.155374
}};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for Rotation<3>
*/
template
<
>
class
ValueFactory
<
Rotation
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
Rotation
<
double
,
3
>
>&
values
)
{
values
.
resize
(
testPoints
.
size
());
std
::
vector
<
std
::
array
<
double
,
4
>
>
testPoints
=
{{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
-
0.838114
,
0.356751
,
-
0.412667
,
0.5
},
{
-
0.490946
,
-
0.306456
,
0.81551
,
0.23
},{
-
0.944506
,
0.123687
,
-
0.304319
,
-
0.7
},
{
-
0.6
,
0.1
,
-
0.2
,
0.8
},{
0.45
,
0.12
,
0.517
,
0
},
{
-
0.1
,
0.3
,
-
0.1
,
0.73
},{
-
0.444506
,
0.123687
,
0.104319
,
-
0.23
},{
-
0.7
,
-
0.123687
,
-
0.304319
,
0.72
},
{
-
0.035669
,
-
0.463824
,
-
0.333265
,
0.820079
},
{
0.0178678
,
0.916836
,
0.367358
,
0.155374
}};
// Set up elements of S^1
for
(
std
::
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
Rotation
<
double
,
3
>
(
testPoints
[
i
]);
values
.
resize
(
testPoints
.
size
());
}
// Set up elements of S^1
for
(
std
::
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
Rotation
<
double
,
3
>
(
testPoints
[
i
]);
}
;
}
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for a ProductManifold<RealTuple,Rotation>
*/
template
<
>
class
ValueFactory
<
Dune
::
GFE
::
ProductManifold
<
RealTuple
<
double
,
3
>
,
Rotation
<
double
,
3
>
>
>
{
public:
static
void
get
(
std
::
vector
<
Dune
::
GFE
::
ProductManifold
<
RealTuple
<
double
,
3
>
,
Rotation
<
double
,
3
>
>
>&
values
)
{
};
using
namespace
Dune
::
Indices
;
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for a ProductManifold<RealTuple,Rotation>
*/
template
<
>
class
ValueFactory
<
Dune
::
GFE
::
ProductManifold
<
RealTuple
<
double
,
3
>
,
Rotation
<
double
,
3
>
>
>
{
public:
static
void
get
(
std
::
vector
<
Dune
::
GFE
::
ProductManifold
<
RealTuple
<
double
,
3
>
,
Rotation
<
double
,
3
>
>
>&
values
)
{
std
::
vector
<
RealTuple
<
double
,
3
>
>
rValues
;
ValueFactory
<
RealTuple
<
double
,
3
>
>::
get
(
rValues
);
using
namespace
Dune
::
Indices
;
std
::
vector
<
R
otation
<
double
,
3
>
>
q
Values
;
ValueFactory
<
R
otation
<
double
,
3
>
>::
get
(
q
Values
);
std
::
vector
<
R
ealTuple
<
double
,
3
>
>
r
Values
;
ValueFactory
<
R
ealTuple
<
double
,
3
>
>::
get
(
r
Values
);
int
nTestPoints
=
std
::
min
(
rValues
.
size
(),
qValues
.
size
());
std
::
vector
<
Rotation
<
double
,
3
>
>
qValues
;
ValueFactory
<
Rotation
<
double
,
3
>
>::
get
(
qValues
);
v
alues
.
re
size
(
nTestPoints
);
int
nTestPoints
=
std
::
min
(
rV
alues
.
size
(
),
qValues
.
size
()
);
// Set up elements of SE(3)
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
{
values
[
i
][
_0
]
=
rValues
[
i
];
values
[
i
][
_1
]
=
qValues
[
i
];
}
values
.
resize
(
nTestPoints
);
}
// Set up elements of SE(3)
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
{
values
[
i
][
_0
]
=
rValues
[
i
];
values
[
i
][
_1
]
=
qValues
[
i
];
}
}
;
}
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for square FieldMatrices
*/
template
<
class
T
,
int
N
>
class
ValueFactory
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>
{
public:
static
void
get
(
std
::
vector
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>&
values
)
{
};
int
nTestPoints
=
10
;
values
.
resize
(
nTestPoints
);
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for square FieldMatrices
*/
template
<
class
T
,
int
N
>
class
ValueFactory
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>
{
public:
static
void
get
(
std
::
vector
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>&
values
)
{
// Set up elements of T^{N \times N}
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
for
(
int
k
=
0
;
k
<
N
;
k
++
)
values
[
i
][
j
][
k
]
=
std
::
rand
()
%
100
-
50
;
int
nTestPoints
=
10
;
values
.
resize
(
nTestPoints
);
}
// Set up elements of T^{N \times N}
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
for
(
int
k
=
0
;
k
<
N
;
k
++
)
values
[
i
][
j
][
k
]
=
std
::
rand
()
%
100
-
50
;
}
;
}
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for OrthogonalMatrices
*/
template
<
class
T
,
int
N
>
class
ValueFactory
<
OrthogonalMatrix
<
T
,
N
>
>
{
static
Dune
::
FieldVector
<
T
,
N
>
proj
(
const
Dune
::
FieldVector
<
T
,
N
>&
u
,
const
Dune
::
FieldVector
<
T
,
N
>&
v
)
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for OrthogonalMatrices
*/
template
<
class
T
,
int
N
>
class
ValueFactory
<
OrthogonalMatrix
<
T
,
N
>
>
{
Dune
::
FieldVector
<
T
,
N
>
result
=
u
;
result
*=
(
v
*
u
)
/
(
u
*
u
);
return
result
;
}
public
:
static
void
get
(
std
::
vector
<
OrthogonalMatrix
<
T
,
N
>
>&
values
)
{
static
Dune
::
FieldVector
<
T
,
N
>
proj
(
const
Dune
::
FieldVector
<
T
,
N
>&
u
,
const
Dune
::
FieldVector
<
T
,
N
>&
v
)
{
Dune
::
FieldVector
<
T
,
N
>
result
=
u
;
result
*=
(
v
*
u
)
/
(
u
*
u
);
return
result
;
}
public
:
static
void
get
(
std
::
vector
<
OrthogonalMatrix
<
T
,
N
>
>&
values
)
{
// Get general matrices
std
::
vector
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>
mValues
;
ValueFactory
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>::
get
(
mValues
);
// Get general matrices
std
::
vector
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>
mValues
;
ValueFactory
<
Dune
::
FieldMatrix
<
T
,
N
,
N
>
>::
get
(
mValues
);
values
.
resize
(
mValues
.
size
());
values
.
resize
(
mValues
.
size
());
// Do Gram-Schmidt orthogonalization of the rows
for
(
size_t
m
=
0
;
m
<
mValues
.
size
();
m
++
)
{
// Do Gram-Schmidt orthogonalization of the rows
for
(
size_t
m
=
0
;
m
<
mValues
.
size
();
m
++
)
{
Dune
::
FieldMatrix
<
T
,
N
,
N
>&
v
=
mValues
[
m
];
Dune
::
FieldMatrix
<
T
,
N
,
N
>&
v
=
mValues
[
m
];
if
(
std
::
fabs
(
v
.
determinant
())
<
1e-6
)
continue
;
if
(
std
::
fabs
(
v
.
determinant
())
<
1e-6
)
continue
;
for
(
int
j
=
0
;
j
<
N
;
j
++
)
{
for
(
int
j
=
0
;
j
<
N
;
j
++
)
{
for
(
int
i
=
0
;
i
<
j
;
i
++
)
{
for
(
int
i
=
0
;
i
<
j
;
i
++
)
{
// v_j = v_j - proj_{v_i} v_j
v
[
j
]
-=
proj
(
v
[
i
],
v
[
j
]);
// v_j = v_j - proj_{v_i} v_j
v
[
j
]
-=
proj
(
v
[
i
],
v
[
j
]);
}
// normalize
v
[
j
]
/=
v
[
j
].
two_norm
();
}
// normalize
v
[
j
]
/=
v
[
j
].
two_norm
();
}
values
[
m
]
=
OrthogonalMatrix
<
T
,
N
>
(
v
);
values
[
m
]
=
OrthogonalMatrix
<
T
,
N
>
(
v
);
}
}
}
};
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for HyperbolicHalfspacePoint<3>
*/
template
<
>
class
ValueFactory
<
HyperbolicHalfspacePoint
<
double
,
2
>
>
{
public:
static
void
get
(
std
::
vector
<
HyperbolicHalfspacePoint
<
double
,
2
>
>&
values
)
{
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for HyperbolicHalfspacePoint<3>
*/
template
<
>
class
ValueFactory
<
HyperbolicHalfspacePoint
<
double
,
2
>
>
{
public:
static
void
get
(
std
::
vector
<
HyperbolicHalfspacePoint
<
double
,
2
>
>&
values
)
{
std
::
vector
<
Dune
::
FieldVector
<
double
,
2
>
>
testPoints
=
{{
0
,
2
},
{
0
,
1
},
{
0
,
0.5
},
{
-
0.490946
,
0.81551
},{
-
0.944506
,
0.304319
},
{
-
0.6
,
0.2
},{
0.45
,
0.517
},
{
-
0.1
,
0.1
},{
-
0.444506
,
0.104319
},{
-
0.7
,
0.304319
}};
std
::
vector
<
Dune
::
FieldVector
<
double
,
2
>
>
testPoints
=
{{
0
,
2
},
{
0
,
1
},
{
0
,
0.5
},
{
-
0.490946
,
0.81551
},{
-
0.944506
,
0.304319
},
{
-
0.6
,
0.2
},{
0.45
,
0.517
},
{
-
0.1
,
0.1
},{
-
0.444506
,
0.104319
},{
-
0.7
,
0.304319
}};
values
.
resize
(
testPoints
.
size
());
values
.
resize
(
testPoints
.
size
());
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
HyperbolicHalfspacePoint
<
double
,
2
>
(
testPoints
[
i
]);
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
HyperbolicHalfspacePoint
<
double
,
2
>
(
testPoints
[
i
]);
}
}
};
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for HyperbolicHalfspacePoint<3>
*/
template
<
>
class
ValueFactory
<
HyperbolicHalfspacePoint
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
HyperbolicHalfspacePoint
<
double
,
3
>
>&
values
)
{
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for HyperbolicHalfspacePoint<3>
*/
template
<
>
class
ValueFactory
<
HyperbolicHalfspacePoint
<
double
,
3
>
>
{
public:
static
void
get
(
std
::
vector
<
HyperbolicHalfspacePoint
<
double
,
3
>
>&
values
)
{
std
::
vector
<
Dune
::
FieldVector
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0.01
},
{
0
,
1
,
0.01
},
{
-
0.838114
,
0.356751
,
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
0.304319
},
{
-
0.6
,
0.1
,
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
0.304319
}};
std
::
vector
<
Dune
::
FieldVector
<
double
,
3
>
>
testPoints
=
{{
1
,
0
,
0.01
},
{
0
,
1
,
0.01
},
{
-
0.838114
,
0.356751
,
0.412667
},
{
-
0.490946
,
-
0.306456
,
0.81551
},{
-
0.944506
,
0.123687
,
0.304319
},
{
-
0.6
,
0.1
,
0.2
},{
0.45
,
0.12
,
0.517
},
{
-
0.1
,
0.3
,
0.1
},{
-
0.444506
,
0.123687
,
0.104319
},{
-
0.7
,
-
0.123687
,
0.304319
}};
values
.
resize
(
testPoints
.
size
());
values
.
resize
(
testPoints
.
size
());
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
HyperbolicHalfspacePoint
<
double
,
3
>
(
testPoints
[
i
]);
// Set up elements of S^1
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
values
[
i
]
=
HyperbolicHalfspacePoint
<
double
,
3
>
(
testPoints
[
i
]);
}
}
};
};
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for ProductManifold<...>
*/
template
<
typename
...
TargetSpaces
>
class
ValueFactory
<
Dune
::
GFE
::
ProductManifold
<
TargetSpaces
...
>
>
{
using
TargetSpace
=
Dune
::
GFE
::
ProductManifold
<
TargetSpaces
...
>
;
/** \brief A class that creates sets of values of various types, to be used in unit tests
*
* This is the specialization for ProductManifold<...>
*/
template
<
typename
...
TargetSpaces
>
class
ValueFactory
<
Dune
::
GFE
::
ProductManifold
<
TargetSpaces
...
>
>
{
using
TargetSpace
=
Dune
::
GFE
::
ProductManifold
<
TargetSpaces
...
>
;
public:
static
void
get
(
std
::
vector
<
TargetSpace
>&
values
)
{
public:
static
void
get
(
std
::
vector
<
TargetSpace
>&
values
)
{
std
::
vector
<
typename
TargetSpace
::
CoordinateType
>
testPoints
(
10
);
std
::
vector
<
typename
TargetSpace
::
CoordinateType
>
testPoints
(
10
);
std
::
generate
(
testPoints
.
begin
(),
testPoints
.
end
(),
[](){
return
Dune
::
GFE
::
randomFieldVector
<
typename
TargetSpace
::
field_type
,
TargetSpace
::
CoordinateType
::
dimension
>
(
0.9
,
1.1
)
;
});
std
::
generate
(
testPoints
.
begin
(),
testPoints
.
end
(),
[](){
return
Dune
::
GFE
::
randomFieldVector
<
typename
TargetSpace
::
field_type
,
TargetSpace
::
CoordinateType
::
dimension
>
(
0.9
,
1.1
)
;
});
values
.
resize
(
testPoints
.
size
());
values
.
resize
(
testPoints
.
size
());
std
::
transform
(
testPoints
.
cbegin
(),
testPoints
.
cend
(),
values
.
begin
(),[](
const
auto
&
testPoint
){
return
TargetSpace
(
testPoint
);});
}
};
std
::
transform
(
testPoints
.
cbegin
(),
testPoints
.
cend
(),
values
.
begin
(),[](
const
auto
&
testPoint
){
return
TargetSpace
(
testPoint
);});
}
};
}
// namespace Dune::GFE
#endif
This diff is collapsed.
Click to expand it.
Prev
1
…
4
5
6
7
8
Next