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
89d10adb
Commit
89d10adb
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use the VirtualFunction class
parent
d82261c9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/finitescalarincreasingconvexfunction.hh
+8
-4
8 additions, 4 deletions
src/finitescalarincreasingconvexfunction.hh
src/mynonlinearity.hh
+5
-1
5 additions, 1 deletion
src/mynonlinearity.hh
with
13 additions
and
5 deletions
src/finitescalarincreasingconvexfunction.hh
+
8
−
4
View file @
89d10adb
...
...
@@ -3,17 +3,21 @@
#ifndef FINITE_SCALAR_INCREASING_CONVEX_FUNCTION_HH
#define FINITE_SCALAR_INCREASING_CONVEX_FUNCTION_HH
#include
<dune/common/function.hh>
namespace
Dune
{
class
FiniteScalarIncreasingConvexFunction
{
class
FiniteScalarIncreasingConvexFunction
:
public
VirtualFunction
<
double
,
double
>
{
public:
virtual
double
operator
()(
const
double
s
)
const
=
0
;
virtual
double
leftDifferential
(
const
double
s
)
const
=
0
;
virtual
double
rightDifferential
(
const
double
s
)
const
=
0
;
};
class
SampleFunction
:
public
FiniteScalarIncreasingConvexFunction
{
public:
double
operator
()(
const
double
s
)
const
{
return
(
s
<
1
)
?
s
:
(
2
*
s
-
1
);
}
void
evaluate
(
const
double
&
x
,
double
&
y
)
const
{
y
=
(
x
<
1
)
?
x
:
(
2
*
x
-
1
);
}
double
leftDifferential
(
const
double
s
)
const
{
return
(
s
<=
1
)
?
1
:
2
;
}
...
...
@@ -22,7 +26,7 @@ class SampleFunction : public FiniteScalarIncreasingConvexFunction {
class
TrivialFunction
:
public
FiniteScalarIncreasingConvexFunction
{
public:
double
operator
()(
const
double
)
const
{
return
0
;
}
void
evaluate
(
const
double
&
x
,
double
&
y
)
const
{
y
=
0
;
}
double
leftDifferential
(
const
double
)
const
{
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
src/mynonlinearity.hh
+
5
−
1
View file @
89d10adb
...
...
@@ -22,7 +22,11 @@ class MyNonlinearity {
typedef
SmallVector
VectorType
;
typedef
SmallMatrix
MatrixType
;
double
operator
()(
VectorType
const
x
)
const
{
return
func_
(
x
.
two_norm
());
}
double
operator
()(
VectorType
const
x
)
const
{
double
ret
;
func_
.
evaluate
(
x
.
two_norm
(),
ret
);
return
ret
;
}
// directional subdifferential: at u on the line u + t*v
// u and v are assumed to be non-zero
...
...
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