Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-tectonic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
agnumpde
dune-tectonic
Commits
e315f9ff
Commit
e315f9ff
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean up qualifiers
parent
8068ec21
Branches
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/samplefunctional.hh
+8
-8
8 additions, 8 deletions
src/samplefunctional.hh
with
8 additions
and
8 deletions
src/samplefunctional.hh
+
8
−
8
View file @
e315f9ff
...
@@ -26,7 +26,7 @@ template <int dim> class SampleFunctional {
...
@@ -26,7 +26,7 @@ template <int dim> class SampleFunctional {
MyNonlinearity
<
dim
>
const
&
phi
)
MyNonlinearity
<
dim
>
const
&
phi
)
:
A
(
A
),
b
(
b
),
phi
(
phi
)
{}
:
A
(
A
),
b
(
b
),
phi
(
phi
)
{}
double
operator
()(
const
SmallVector
v
)
const
{
double
operator
()(
SmallVector
const
v
)
const
{
SmallVector
y
;
SmallVector
y
;
A
.
mv
(
v
,
y
);
// y = Av
A
.
mv
(
v
,
y
);
// y = Av
y
/=
2
;
// y = 1/2 Av
y
/=
2
;
// y = 1/2 Av
...
@@ -34,7 +34,7 @@ template <int dim> class SampleFunctional {
...
@@ -34,7 +34,7 @@ template <int dim> class SampleFunctional {
return
y
*
v
+
phi
(
v
);
// <1/2 Av - b,v> + H(|v|)
return
y
*
v
+
phi
(
v
);
// <1/2 Av - b,v> + H(|v|)
}
}
void
descentDirection
(
const
SmallVector
x
,
SmallVector
&
ret
)
const
{
void
descentDirection
(
SmallVector
const
x
,
SmallVector
&
ret
)
const
{
// Check the squared norm rather than each component because
// Check the squared norm rather than each component because
// negative_projection() divides by it
// negative_projection() divides by it
if
(
x
.
two_norm2
()
==
0.0
)
{
if
(
x
.
two_norm2
()
==
0.0
)
{
...
@@ -87,21 +87,21 @@ template <int dim> class SampleFunctional {
...
@@ -87,21 +87,21 @@ template <int dim> class SampleFunctional {
private
:
private
:
// Gradient of the smooth part
// Gradient of the smooth part
SmallVector
smoothGradient
(
const
SmallVector
x
)
const
{
SmallVector
smoothGradient
(
SmallVector
const
x
)
const
{
SmallVector
y
;
SmallVector
y
;
A
.
mv
(
x
,
y
);
// y = Av
A
.
mv
(
x
,
y
);
// y = Av
y
-=
b
;
// y = Av - b
y
-=
b
;
// y = Av - b
return
y
;
return
y
;
}
}
SmallVector
upperGradient
(
const
SmallVector
x
)
const
{
SmallVector
upperGradient
(
SmallVector
const
x
)
const
{
SmallVector
y
;
SmallVector
y
;
phi
.
upperGradient
(
x
,
y
);
phi
.
upperGradient
(
x
,
y
);
y
+=
smoothGradient
(
x
);
y
+=
smoothGradient
(
x
);
return
y
;
return
y
;
}
}
SmallVector
lowerGradient
(
const
SmallVector
x
)
const
{
SmallVector
lowerGradient
(
SmallVector
const
x
)
const
{
SmallVector
y
;
SmallVector
y
;
phi
.
lowerGradient
(
x
,
y
);
phi
.
lowerGradient
(
x
,
y
);
y
+=
smoothGradient
(
x
);
y
+=
smoothGradient
(
x
);
...
@@ -109,8 +109,8 @@ template <int dim> class SampleFunctional {
...
@@ -109,8 +109,8 @@ template <int dim> class SampleFunctional {
}
}
// No normalising is done!
// No normalising is done!
SmallVector
negative_projection
(
const
SmallVector
z
,
SmallVector
negative_projection
(
SmallVector
const
z
,
const
SmallVector
x
)
const
{
SmallVector
const
x
)
const
{
SmallVector
y
=
z
;
SmallVector
y
=
z
;
y
.
axpy
(
-
(
z
*
x
)
/
x
.
two_norm2
(),
x
);
y
.
axpy
(
-
(
z
*
x
)
/
x
.
two_norm2
(),
x
);
return
y
;
return
y
;
...
@@ -118,7 +118,7 @@ template <int dim> class SampleFunctional {
...
@@ -118,7 +118,7 @@ template <int dim> class SampleFunctional {
};
};
template
<
class
Functional
>
template
<
class
Functional
>
void
minimise
(
const
Functional
J
,
typename
Functional
::
SmallVector
&
x
,
void
minimise
(
Functional
const
J
,
typename
Functional
::
SmallVector
&
x
,
size_t
steps
=
1
,
size_t
steps
=
1
,
Bisection
const
&
bisection
=
Bisection
const
&
bisection
=
Bisection
(
0.0
,
// acceptError: Stop if the search interval has
Bisection
(
0.0
,
// acceptError: Stop if the search interval has
...
...
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