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
Commits
1172c0c1
Commit
1172c0c1
authored
13 years ago
by
Oliver Sander
Committed by
sander@FU-BERLIN.DE
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add a test whether an orthogonal matrix really is orthogonal
[[Imported from SVN: r8563]]
parent
d99f321a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/orthogonalmatrixtest.cc
+26
-10
26 additions, 10 deletions
test/orthogonalmatrixtest.cc
with
26 additions
and
10 deletions
test/orthogonalmatrixtest.cc
+
26
−
10
View file @
1172c0c1
...
@@ -13,7 +13,24 @@ using namespace Dune;
...
@@ -13,7 +13,24 @@ using namespace Dune;
double
eps
=
1e-6
;
double
eps
=
1e-6
;
/** \brief Test orthogonal projection onto the tangent space at q
/** \brief Test whether orthogonal matrix really is orthogonal
*/
template
<
class
T
,
int
N
>
void
testOrthogonality
(
const
OrthogonalMatrix
<
T
,
N
>&
p
)
{
Dune
::
FieldMatrix
<
T
,
N
,
N
>
prod
(
0
);
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
for
(
int
k
=
0
;
k
<
N
;
k
++
)
prod
[
i
][
j
]
+=
p
.
data
()[
k
][
i
]
*
p
.
data
()[
k
][
j
];
for
(
int
i
=
0
;
i
<
N
;
i
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
if
(
std
::
abs
(
prod
[
i
][
j
]
-
(
i
==
j
)
)
>
eps
)
DUNE_THROW
(
Exception
,
"Matrix is not orthogonal"
);
}
/** \brief Test orthogonal projection onto the tangent space at p
*/
*/
template
<
class
T
,
int
N
>
template
<
class
T
,
int
N
>
void
testProjectionOntoTangentSpace
(
const
OrthogonalMatrix
<
T
,
N
>&
p
)
void
testProjectionOntoTangentSpace
(
const
OrthogonalMatrix
<
T
,
N
>&
p
)
...
@@ -36,7 +53,6 @@ void testProjectionOntoTangentSpace(const OrthogonalMatrix<T,N>& p)
...
@@ -36,7 +53,6 @@ void testProjectionOntoTangentSpace(const OrthogonalMatrix<T,N>& p)
for
(
int
l
=
0
;
l
<
N
;
l
++
)
for
(
int
l
=
0
;
l
<
N
;
l
++
)
skewPart
[
j
][
k
]
+=
p
.
data
()[
l
][
j
]
*
projected
[
l
][
k
];
skewPart
[
j
][
k
]
+=
p
.
data
()[
l
][
j
]
*
projected
[
l
][
k
];
std
::
cout
<<
"skew part
\n
"
<<
skewPart
<<
std
::
endl
;
// is it skew?
// is it skew?
for
(
int
j
=
0
;
j
<
N
;
j
++
)
for
(
int
j
=
0
;
j
<
N
;
j
++
)
for
(
int
k
=
0
;
k
<=
j
;
k
++
)
for
(
int
k
=
0
;
k
<=
j
;
k
++
)
...
@@ -56,19 +72,19 @@ void test()
...
@@ -56,19 +72,19 @@ void test()
{
{
std
::
cout
<<
"Testing class "
<<
className
<
OrthogonalMatrix
<
T
,
N
>
>
()
<<
std
::
endl
;
std
::
cout
<<
"Testing class "
<<
className
<
OrthogonalMatrix
<
T
,
N
>
>
()
<<
std
::
endl
;
// Use the ValueFactory for general matrices.
// Get set of orthogonal test matrices
// I am too lazy to program a factory for orthogonal matrices
std
::
vector
<
OrthogonalMatrix
<
T
,
N
>
>
testPoints
;
std
::
vector
<
FieldMatrix
<
T
,
N
,
N
>
>
testPoints
;
ValueFactory
<
OrthogonalMatrix
<
T
,
N
>
>::
get
(
testPoints
);
ValueFactory
<
FieldMatrix
<
T
,
N
,
N
>
>::
get
(
testPoints
);
int
nTestPoints
=
testPoints
.
size
();
int
nTestPoints
=
testPoints
.
size
();
// Test each element in the list
// Test each element in the list
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nTestPoints
;
i
++
)
{
// I cannot use matrices with determinant zero for testing
// Test whether the matrix really is orthogonal
if
(
testPoints
[
i
].
determinant
()
>
eps
)
testOrthogonality
(
testPoints
[
i
]);
testProjectionOntoTangentSpace
(
OrthogonalMatrix
<
T
,
N
>
(
testPoints
[
i
]));
testProjectionOntoTangentSpace
(
testPoints
[
i
]);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment