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
d093bb18
Commit
d093bb18
authored
15 years ago
by
Oliver Sander
Committed by
sander@PCPOOL.MI.FU-BERLIN.DE
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
factor out derivative of arccos squared into a separate method
[[Imported from SVN: r5671]]
parent
72904b79
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
src/unitvector.hh
+12
-8
12 additions, 8 deletions
src/unitvector.hh
with
12 additions
and
8 deletions
src/unitvector.hh
+
12
−
8
View file @
d093bb18
...
...
@@ -11,6 +11,17 @@ class UnitVector
return
(
x
<
1e-4
)
?
1
+
(
x
*
x
/
6
)
:
std
::
sin
(
x
)
/
x
;
}
/** \brief Compute the derivative of arccos^2 without getting unstable for x close to 1 */
static
double
derivativeOfArcCosSquared
(
const
double
&
x
)
{
const
double
eps
=
1e-12
;
if
(
x
>
1
-
eps
)
{
// regular expression is unstable, use the series expansion instead
return
-
2
+
2
*
(
x
-
1
)
/
3
-
4
/
15
*
(
x
-
1
)
*
(
x
-
1
)
+
4
/
35
*
(
x
-
1
)
*
(
x
-
1
)
*
(
x
-
1
);
}
else
if
(
x
<
-
1
+
eps
)
{
// The function is not differentiable
DUNE_THROW
(
Dune
::
Exception
,
"Distance is not differentiable for conjugate points!"
);
}
else
return
-
2
*
std
::
acos
(
x
)
/
std
::
sqrt
(
1
-
x
*
x
);
}
public
:
/** \brief The type used for coordinates */
...
...
@@ -58,17 +69,10 @@ public:
*/
static
EmbeddedTangentVector
derivativeOfDistanceSquaredWRTSecondArgument
(
const
UnitVector
&
a
,
const
UnitVector
&
b
)
{
double
x
=
a
.
data_
*
b
.
data_
;
const
double
eps
=
1e-12
;
EmbeddedTangentVector
result
=
a
.
data_
;
if
(
x
>
1
-
eps
)
{
// regular expression is unstable, use the series expansion instead
result
*=
-
2
+
2
*
(
x
-
1
)
/
3
-
4
/
15
*
(
x
-
1
)
*
(
x
-
1
)
+
4
/
35
*
(
x
-
1
)
*
(
x
-
1
)
*
(
x
-
1
);
}
else
if
(
x
<
-
1
+
eps
)
{
// a and b are conjugate. The function is not differentiable
DUNE_THROW
(
Dune
::
Exception
,
"Distance is not differentiable for conjugate points!"
);
}
else
{
result
*=
-
2
*
std
::
acos
(
x
)
/
std
::
sqrt
(
1
-
x
*
x
);
}
result
*=
derivativeOfArcCosSquared
(
x
);
// Project gradient onto the tangent plane at b in order to obtain the surface gradient
result
=
b
.
projectOntoTangentSpace
(
result
);
...
...
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