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
72098d6b
Commit
72098d6b
authored
13 years ago
by
Elias Pipping
Committed by
Elias Pipping
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Rename gradient methods:
SmoothGrad -> smoothGradient PlusGrad -> upperGradient MinusGrad -> lowerGradient
parent
e00524bb
No related branches found
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
+9
-9
9 additions, 9 deletions
src/samplefunctional.hh
with
9 additions
and
9 deletions
src/samplefunctional.hh
+
9
−
9
View file @
72098d6b
...
@@ -31,7 +31,7 @@ class SampleFunctional {
...
@@ -31,7 +31,7 @@ class SampleFunctional {
SmallVector
descentDirection
(
const
SmallVector
x
)
const
{
SmallVector
descentDirection
(
const
SmallVector
x
)
const
{
if
(
x
==
SmallVector
(
0.0
))
{
if
(
x
==
SmallVector
(
0.0
))
{
SmallVector
d
=
S
moothGrad
(
x
);
SmallVector
d
=
s
moothGrad
ient
(
x
);
// Decline of the smooth part in the negative gradient direction
// Decline of the smooth part in the negative gradient direction
double
smoothDecline
=
-
(
d
*
d
);
double
smoothDecline
=
-
(
d
*
d
);
double
nonlinearDecline
=
double
nonlinearDecline
=
...
@@ -41,8 +41,8 @@ class SampleFunctional {
...
@@ -41,8 +41,8 @@ class SampleFunctional {
return
(
combinedDecline
<
0
)
?
d
:
SmallVector
(
0.0
);
return
(
combinedDecline
<
0
)
?
d
:
SmallVector
(
0.0
);
}
}
SmallVector
const
pg
=
PlusGrad
(
x
);
SmallVector
const
pg
=
upperGradient
(
x
);
SmallVector
const
mg
=
MinusGrad
(
x
);
SmallVector
const
mg
=
lowerGradient
(
x
);
SmallVector
ret
;
SmallVector
ret
;
// TODO: collinearity checks suck
// TODO: collinearity checks suck
if
(
pg
*
x
==
pg
.
two_norm
()
*
x
.
two_norm
()
&&
if
(
pg
*
x
==
pg
.
two_norm
()
*
x
.
two_norm
()
&&
...
@@ -53,7 +53,7 @@ class SampleFunctional {
...
@@ -53,7 +53,7 @@ class SampleFunctional {
}
else
if
(
pg
*
x
<=
0
&&
mg
*
x
<=
0
)
{
}
else
if
(
pg
*
x
<=
0
&&
mg
*
x
<=
0
)
{
ret
=
mg
;
ret
=
mg
;
}
else
{
}
else
{
ret
=
project
(
S
moothGrad
(
x
),
x
);
ret
=
project
(
s
moothGrad
ient
(
x
),
x
);
}
}
ret
*=
-
1
;
ret
*=
-
1
;
return
ret
;
return
ret
;
...
@@ -66,21 +66,21 @@ class SampleFunctional {
...
@@ -66,21 +66,21 @@ class SampleFunctional {
Function
func_
;
Function
func_
;
// Gradient of the smooth part
// Gradient of the smooth part
SmallVector
S
moothGrad
(
const
SmallVector
x
)
const
{
SmallVector
s
moothGrad
ient
(
const
SmallVector
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
PlusGrad
(
const
SmallVector
x
)
const
{
SmallVector
upperGradient
(
const
SmallVector
x
)
const
{
SmallVector
y
=
S
moothGrad
(
x
);
SmallVector
y
=
s
moothGrad
ient
(
x
);
y
.
axpy
(
func_
.
rightDifferential
(
x
.
two_norm
())
/
x
.
two_norm
(),
x
);
y
.
axpy
(
func_
.
rightDifferential
(
x
.
two_norm
())
/
x
.
two_norm
(),
x
);
return
y
;
return
y
;
}
}
SmallVector
MinusGrad
(
const
SmallVector
x
)
const
{
SmallVector
lowerGradient
(
const
SmallVector
x
)
const
{
SmallVector
y
=
S
moothGrad
(
x
);
SmallVector
y
=
s
moothGrad
ient
(
x
);
y
.
axpy
(
func_
.
leftDifferential
(
x
.
two_norm
())
/
x
.
two_norm
(),
x
);
y
.
axpy
(
func_
.
leftDifferential
(
x
.
two_norm
())
/
x
.
two_norm
(),
x
);
return
y
;
return
y
;
}
}
...
...
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