Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Johannes Pfeifer
dynare
Commits
f4508a6c
Commit
f4508a6c
authored
4 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Revert "update jacob_element & hess_element for vector arguments"
This reverts commit
1975e467
.
parent
47affc94
Branches
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
matlab/hess_element.m
+16
-18
16 additions, 18 deletions
matlab/hess_element.m
matlab/jacob_element.m
+7
-8
7 additions, 8 deletions
matlab/jacob_element.m
with
23 additions
and
26 deletions
matlab/hess_element.m
+
16
−
18
View file @
f4508a6c
function
d
=
hess_element
(
func
,
arg1
,
arg2
,
elem1
,
elem2
,
args
)
% function d=hess_element(func,
arg1,arg2,
elem1,elem2,args)
function
d
=
hess_element
(
func
,
elem
ent
1
,
elem
ent
2
,
args
)
% function d=hess_element(func,elem
ent
1,elem
ent
2,args)
% returns an entry of the finite differences approximation to the hessian of func
%
% INPUTS
% func [function name] string with name of the function
% arg1 [int] the indices showing the element within the hessian that should be returned
% arg2 [int]
% elem1 [int] vector index 1
% elem2 [int] vector index 2
% element1 [int] the indices showing the element within the hessian that should be returned
% element2 [int]
% args [cell array] arguments provided to func
%
% OUTPUTS
% d [double] the (
arg1,arg
2) entry of the hessian
% d [double] the (
element1,element
2) entry of the hessian
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -33,7 +31,7 @@ function d=hess_element(func,arg1,arg2,elem1,elem2,args)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
arg
1
<=
length
(
args
)
&&
arg
2
<=
length
(
args
));
assert
(
element
1
<=
length
(
args
)
&&
element
2
<=
length
(
args
));
func
=
str2func
(
func
);
...
...
@@ -45,21 +43,21 @@ m01 = args;
p11
=
args
;
m11
=
args
;
p10
{
arg1
}(
elem1
)
=
p10
{
arg1
}(
elem1
)
+
h
;
m10
{
arg1
}(
elem1
)
=
m10
{
arg1
}(
elem1
)
-
h
;
p10
{
element1
}
=
p10
{
element1
}
+
h
;
m10
{
element1
}
=
m10
{
element1
}
-
h
;
p11
{
arg1
}(
elem1
)
=
p11
{
arg1
}(
elem1
)
+
h
;
m11
{
arg1
}(
elem1
)
=
m11
{
arg1
}(
elem1
)
-
h
;
p11
{
element1
}
=
p11
{
element1
}
+
h
;
m11
{
element1
}
=
m11
{
element1
}
-
h
;
p01
{
element2
}
=
p01
{
element2
}
+
h
;
m01
{
element2
}
=
m01
{
element2
}
-
h
;
p01
{
arg2
}(
elem2
)
=
p01
{
arg2
}(
elem2
)
+
h
;
m01
{
arg2
}(
elem2
)
=
m01
{
arg2
}(
elem2
)
-
h
;
p11
{
arg2
}(
elem2
)
=
p11
{
arg2
}(
elem2
)
+
h
;
m11
{
arg2
}(
elem2
)
=
m11
{
arg2
}(
elem2
)
-
h
;
p11
{
element2
}
=
p11
{
element2
}
+
h
;
m11
{
element2
}
=
m11
{
element2
}
-
h
;
% From Abramowitz and Stegun. Handbook of Mathematical Functions (1965)
% formulas 25.3.24 and 25.3.27 p. 884
if
arg1
==
arg
2
if
element1
==
element
2
d
=
(
16
*
func
(
p10
{:})
...
+
16
*
func
(
m10
{:})
...
-
30
*
func
(
args
{:})
...
...
...
This diff is collapsed.
Click to expand it.
matlab/jacob_element.m
+
7
−
8
View file @
f4508a6c
function
d
=
jacob_element
(
func
,
arg
,
elem
,
args
)
% function d=jacob_element(func,
arg,
elem,args)
function
d
=
jacob_element
(
func
,
elem
ent
,
args
)
% function d=jacob_element(func,elem
ent
,args)
% returns an entry of the finite differences approximation to the jacobian of func
%
% INPUTS
% func [function name] string with name of the function
% arg [int] the index showing the elem within the jacobian that should be returned
% elem [int] vector index
% element [int] the index showing the element within the jacobian that should be returned
% args [cell array] arguments provided to func
%
% OUTPUTS
% d [double] jacobian[elem]
% d [double] jacobian[elem
ent
]
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -31,15 +30,15 @@ function d=jacob_element(func,arg,elem,args)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
arg
<=
length
(
args
));
assert
(
element
<=
length
(
args
));
func
=
str2func
(
func
);
h
=
1e-6
;
margs
=
args
;
args
{
arg
}(
elem
)
=
args
{
arg
}(
elem
)
+
h
;
margs
{
arg
}(
elem
)
=
margs
{
arg
}(
elem
)
-
h
;
args
{
element
}
=
args
{
element
}
+
h
;
margs
{
element
}
=
margs
{
element
}
-
h
;
d
=
(
func
(
args
{:})
-
func
(
margs
{:}))/(
2
*
h
);
end
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