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
9ade0fac
Commit
9ade0fac
authored
12 years ago
by
Elias Pipping
Committed by
Elias Pipping
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make the test suite work again
parent
19dec53f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test-gradient-method-nicefunction.hh
+115
-0
115 additions, 0 deletions
src/test-gradient-method-nicefunction.hh
src/test-gradient-method.cc
+1
-0
1 addition, 0 deletions
src/test-gradient-method.cc
with
116 additions
and
0 deletions
src/test-gradient-method-nicefunction.hh
0 → 100644
+
115
−
0
View file @
9ade0fac
#include
<dune/tectonic/nicefunction.hh>
namespace
Dune
{
class
MyFunction
:
public
NiceFunction
{
double
virtual
second_deriv
(
double
)
const
{
assert
(
false
);
return
0
;
}
double
virtual
regularity
(
double
)
const
{
assert
(
false
);
return
0
;
}
};
class
LinearFunction
:
public
MyFunction
{
public:
LinearFunction
(
double
a
)
:
coefficient
(
a
)
{}
void
virtual
evaluate
(
double
const
&
x
,
double
&
y
)
const
{
y
=
coefficient
*
x
;
}
double
virtual
leftDifferential
(
double
s
)
const
{
return
coefficient
;
}
double
virtual
rightDifferential
(
double
s
)
const
{
return
coefficient
;
}
double
virtual
second_deriv
(
double
)
const
{
return
0
;
}
double
virtual
regularity
(
double
s
)
const
{
return
0
;
}
private
:
double
const
coefficient
;
};
template
<
int
slope
>
class
SampleFunction
:
public
MyFunction
{
public:
void
virtual
evaluate
(
double
const
&
x
,
double
&
y
)
const
{
y
=
(
x
<
1
)
?
x
:
(
slope
*
(
x
-
1
)
+
1
);
}
double
virtual
leftDifferential
(
double
s
)
const
{
return
(
s
<=
1
)
?
1
:
slope
;
}
double
virtual
rightDifferential
(
double
s
)
const
{
return
(
s
<
1
)
?
1
:
slope
;
}
};
class
SteepFunction
:
public
MyFunction
{
public:
void
virtual
evaluate
(
double
const
&
x
,
double
&
y
)
const
{
y
=
100
*
x
;
}
double
virtual
leftDifferential
(
double
s
)
const
{
return
100
;
}
double
virtual
rightDifferential
(
double
s
)
const
{
return
100
;
}
};
// slope in [n-1,n] is n
class
HorribleFunction
:
public
MyFunction
{
public:
void
virtual
evaluate
(
double
const
&
x
,
double
&
y
)
const
{
double
const
fl
=
floor
(
x
);
double
const
sum
=
fl
*
(
fl
+
1
)
/
2
;
y
=
sum
+
(
fl
+
1
)
*
(
x
-
fl
);
}
double
virtual
leftDifferential
(
double
x
)
const
{
double
const
fl
=
floor
(
x
);
if
(
x
-
fl
<
1e-14
)
return
fl
;
else
return
fl
+
1
;
}
double
virtual
rightDifferential
(
double
x
)
const
{
double
const
c
=
ceil
(
x
);
if
(
c
-
x
<
1e-14
)
return
c
+
1
;
else
return
c
;
}
};
// slope in [n-1,n] is log(n+1)
class
HorribleFunctionLogarithmic
:
public
MyFunction
{
public:
void
virtual
evaluate
(
double
const
&
x
,
double
&
y
)
const
{
y
=
0
;
size_t
const
fl
=
floor
(
x
);
for
(
size_t
i
=
1
;
i
<=
fl
;)
y
+=
std
::
log
(
++
i
);
// factorials grow to fast so we compute this incrementally
y
+=
std
::
log
(
fl
+
2
)
*
(
x
-
fl
);
}
double
virtual
leftDifferential
(
double
x
)
const
{
double
const
fl
=
floor
(
x
);
if
(
x
-
fl
<
1e-14
)
return
std
::
log
(
fl
+
1
);
else
return
std
::
log
(
fl
+
2
);
}
double
virtual
rightDifferential
(
double
x
)
const
{
double
const
c
=
ceil
(
x
);
if
(
c
-
x
<
1e-14
)
return
std
::
log
(
c
+
2
);
else
return
std
::
log
(
c
+
1
);
}
};
}
This diff is collapsed.
Click to expand it.
src/test-gradient-method.cc
+
1
−
0
View file @
9ade0fac
...
...
@@ -11,6 +11,7 @@
#include
<dune/tnnmg/problem-classes/bisection.hh>
#include
<dune/tectonic/samplefunctional.hh>
#include
"test-gradient-method-nicefunction.hh"
template
<
int
dim
>
double
functionTester
(
Dune
::
SampleFunctional
<
dim
>
J
,
...
...
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