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
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
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
podlesny
dune-tectonic
Commits
386b8d0e
Commit
386b8d0e
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
SF -> Functional
parent
65ea5c5a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/duneevaluate.cc
+5
-5
5 additions, 5 deletions
src/duneevaluate.cc
src/duneminimise.cc
+6
-6
6 additions, 6 deletions
src/duneminimise.cc
src/test-gradient-method.cc
+32
-32
32 additions, 32 deletions
src/test-gradient-method.cc
with
43 additions
and
43 deletions
src/duneevaluate.cc
+
5
−
5
View file @
386b8d0e
...
@@ -20,21 +20,21 @@ Evaluate x -> 1/2<Ax,x> - <b,x> + H(|x|) at y using DUNE\n") {
...
@@ -20,21 +20,21 @@ Evaluate x -> 1/2<Ax,x> - <b,x> + H(|x|) at y using DUNE\n") {
int
const
dim
=
2
;
int
const
dim
=
2
;
// {{{ The usual setup
// {{{ The usual setup
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
SampleFunction
f
;
Dune
::
SampleFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
// }}}
// }}}
Sample
Functional
::
SmallVector
our_point
;
Functional
::
SmallVector
our_point
;
Dune
::
octaveToDune
<
dim
>
(
point
,
our_point
);
Dune
::
octaveToDune
<
dim
>
(
point
,
our_point
);
return
octave_value
(
J
(
our_point
));
return
octave_value
(
J
(
our_point
));
}
}
This diff is collapsed.
Click to expand it.
src/duneminimise.cc
+
6
−
6
View file @
386b8d0e
...
@@ -20,24 +20,24 @@ Make a minimisation step of x -> 1/2<Ax,x> - <b,x> + H(|x|) using DUNE starting
...
@@ -20,24 +20,24 @@ Make a minimisation step of x -> 1/2<Ax,x> - <b,x> + H(|x|) using DUNE starting
int
const
dim
=
2
;
int
const
dim
=
2
;
// {{{ The usual setup
// {{{ The usual setup
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
SampleFunction
f
;
Dune
::
SampleFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
// }}}
// }}}
Sample
Functional
::
SmallVector
start
;
Functional
::
SmallVector
start
;
Dune
::
octaveToDune
<
dim
>
(
current
,
start
);
Dune
::
octaveToDune
<
dim
>
(
current
,
start
);
Sample
Functional
::
SmallVector
correction
;
Functional
::
SmallVector
correction
;
Dune
::
minimise
(
J
,
start
,
correction
);
Dune
::
minimise
(
J
,
start
,
correction
);
ColumnVector
ret
(
dim
);
ColumnVector
ret
(
dim
);
...
...
This diff is collapsed.
Click to expand it.
src/test-gradient-method.cc
+
32
−
32
View file @
386b8d0e
...
@@ -30,21 +30,21 @@ double functionTester(Dune::SampleFunctional<dim> J,
...
@@ -30,21 +30,21 @@ double functionTester(Dune::SampleFunctional<dim> J,
void
testSampleFunction
()
{
void
testSampleFunction
()
{
int
const
dim
=
2
;
int
const
dim
=
2
;
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
SampleFunction
f
;
Dune
::
SampleFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Sample
Functional
::
SmallVector
start
=
b
;
Functional
::
SmallVector
start
=
b
;
start
*=
17
;
start
*=
17
;
/*
/*
...
@@ -53,10 +53,10 @@ void testSampleFunction() {
...
@@ -53,10 +53,10 @@ void testSampleFunction() {
= 17*(6, 9.5) - (1, 2) + 2/sqrt(5) (1, 2)
= 17*(6, 9.5) - (1, 2) + 2/sqrt(5) (1, 2)
= (102 - 1 + 2/sqrt(5), 161.5 - 2 + 4/sqrt(5))
= (102 - 1 + 2/sqrt(5), 161.5 - 2 + 4/sqrt(5))
*/
*/
Sample
Functional
::
SmallVector
error
;
Functional
::
SmallVector
error
;
error
[
0
]
=
-
(
102
-
1
+
2
/
sqrt
(
5
));
error
[
0
]
=
-
(
102
-
1
+
2
/
sqrt
(
5
));
error
[
1
]
=
-
(
161.5
-
2
+
4
/
sqrt
(
5
));
error
[
1
]
=
-
(
161.5
-
2
+
4
/
sqrt
(
5
));
Sample
Functional
::
SmallVector
returned
;
Functional
::
SmallVector
returned
;
J
.
descentDirection
(
start
,
returned
);
J
.
descentDirection
(
start
,
returned
);
error
-=
returned
;
error
-=
returned
;
assert
(
error
.
two_norm
()
<
1e-10
);
// FIXME: 1e-10 sounds reasonable. Is it?
assert
(
error
.
two_norm
()
<
1e-10
);
// FIXME: 1e-10 sounds reasonable. Is it?
...
@@ -79,22 +79,22 @@ void testSampleFunction() {
...
@@ -79,22 +79,22 @@ void testSampleFunction() {
void
testSampleFunctionNonsmooth
()
{
void
testSampleFunctionNonsmooth
()
{
int
const
dim
=
2
;
int
const
dim
=
2
;
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
SampleFunction
f
;
Dune
::
SampleFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Sample
Functional
::
SmallVector
start
;
Functional
::
SmallVector
start
;
Sample
Functional
::
SmallVector
error
;
Functional
::
SmallVector
error
;
/*
/*
for x = b/|b|:
for x = b/|b|:
...
@@ -113,7 +113,7 @@ void testSampleFunctionNonsmooth() {
...
@@ -113,7 +113,7 @@ void testSampleFunctionNonsmooth() {
start
/=
(
b
.
two_norm
()
+
1e-12
);
start
/=
(
b
.
two_norm
()
+
1e-12
);
assert
(
start
.
two_norm
()
<
1
);
assert
(
start
.
two_norm
()
<
1
);
Sample
Functional
::
SmallVector
returned
;
Functional
::
SmallVector
returned
;
J
.
descentDirection
(
start
,
returned
);
J
.
descentDirection
(
start
,
returned
);
error
[
0
]
=
-
(
7
/
sqrt
(
5
)
-
1
);
error
[
0
]
=
-
(
7
/
sqrt
(
5
)
-
1
);
error
[
1
]
=
-
(
11.5
/
sqrt
(
5
)
-
2
);
error
[
1
]
=
-
(
11.5
/
sqrt
(
5
)
-
2
);
...
@@ -128,7 +128,7 @@ void testSampleFunctionNonsmooth() {
...
@@ -128,7 +128,7 @@ void testSampleFunctionNonsmooth() {
start
/=
(
b
.
two_norm
()
-
1e-12
);
// Make sure the norm is above 1;
start
/=
(
b
.
two_norm
()
-
1e-12
);
// Make sure the norm is above 1;
assert
(
start
.
two_norm
()
>
1
);
assert
(
start
.
two_norm
()
>
1
);
Sample
Functional
::
SmallVector
returned
;
Functional
::
SmallVector
returned
;
J
.
descentDirection
(
start
,
returned
);
J
.
descentDirection
(
start
,
returned
);
error
[
0
]
=
-
(
8
/
sqrt
(
5
)
-
1
);
error
[
0
]
=
-
(
8
/
sqrt
(
5
)
-
1
);
error
[
1
]
=
-
(
13.5
/
sqrt
(
5
)
-
2
);
error
[
1
]
=
-
(
13.5
/
sqrt
(
5
)
-
2
);
...
@@ -141,21 +141,21 @@ void testSampleFunctionNonsmooth() {
...
@@ -141,21 +141,21 @@ void testSampleFunctionNonsmooth() {
void
testTrivialFunction
()
{
void
testTrivialFunction
()
{
int
const
dim
=
2
;
int
const
dim
=
2
;
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
TrivialFunction
f
;
Dune
::
TrivialFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Sample
Functional
::
SmallVector
start
=
b
;
Functional
::
SmallVector
start
=
b
;
start
*=
17
;
start
*=
17
;
/*
/*
...
@@ -164,10 +164,10 @@ void testTrivialFunction() {
...
@@ -164,10 +164,10 @@ void testTrivialFunction() {
= 17*(6, 9.5) - (1, 2)
= 17*(6, 9.5) - (1, 2)
= (102 - 1, 161.5 - 2)
= (102 - 1, 161.5 - 2)
*/
*/
Sample
Functional
::
SmallVector
error
;
Functional
::
SmallVector
error
;
error
[
0
]
=
-
101
;
error
[
0
]
=
-
101
;
error
[
1
]
=
-
159.5
;
error
[
1
]
=
-
159.5
;
Sample
Functional
::
SmallVector
returned
;
Functional
::
SmallVector
returned
;
J
.
descentDirection
(
start
,
returned
);
J
.
descentDirection
(
start
,
returned
);
error
-=
returned
;
error
-=
returned
;
assert
(
error
.
two_norm
()
<
1e-10
);
// FIXME: 1e-10 sounds reasonable. Is it?
assert
(
error
.
two_norm
()
<
1e-10
);
// FIXME: 1e-10 sounds reasonable. Is it?
...
@@ -185,21 +185,21 @@ void testTrivialFunction() {
...
@@ -185,21 +185,21 @@ void testTrivialFunction() {
void
testHorribleFunction
()
{
void
testHorribleFunction
()
{
int
const
dim
=
2
;
int
const
dim
=
2
;
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
HorribleFunction
f
;
Dune
::
HorribleFunction
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Sample
Functional
::
SmallVector
start
=
b
;
Functional
::
SmallVector
start
=
b
;
start
*=
17
;
start
*=
17
;
double
const
ret1
=
functionTester
(
J
,
start
,
7
);
double
const
ret1
=
functionTester
(
J
,
start
,
7
);
...
@@ -220,21 +220,21 @@ void testHorribleFunction() {
...
@@ -220,21 +220,21 @@ void testHorribleFunction() {
void
testHorribleFunctionLogarithmic
()
{
void
testHorribleFunctionLogarithmic
()
{
int
const
dim
=
2
;
int
const
dim
=
2
;
typedef
Dune
::
SampleFunctional
<
dim
>
Sample
Functional
;
typedef
Dune
::
SampleFunctional
<
dim
>
Functional
;
Sample
Functional
::
SmallMatrix
A
;
Functional
::
SmallMatrix
A
;
A
[
0
][
0
]
=
3
;
A
[
0
][
0
]
=
3
;
A
[
0
][
1
]
=
1.5
;
A
[
0
][
1
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
0
]
=
1.5
;
A
[
1
][
1
]
=
4
;
A
[
1
][
1
]
=
4
;
Sample
Functional
::
SmallVector
b
;
Functional
::
SmallVector
b
;
b
[
0
]
=
1
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
b
[
1
]
=
2
;
Dune
::
HorribleFunctionLogarithmic
f
;
Dune
::
HorribleFunctionLogarithmic
f
;
Sample
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Functional
J
(
A
,
b
,
Dune
::
MyNonlinearity
<
dim
>
(
f
));
Sample
Functional
::
SmallVector
start
=
b
;
Functional
::
SmallVector
start
=
b
;
start
*=
17
;
start
*=
17
;
double
const
ret1
=
functionTester
(
J
,
start
,
6
);
double
const
ret1
=
functionTester
(
J
,
start
,
6
);
...
...
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