Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
509cc151
Commit
509cc151
authored
Jul 18, 2011
by
Houtan Bastani
Browse files
bug fix: getPowerDeriv not accessible from modfile.m
parent
80ea708d
Changes
4
Hide whitespace changes
Inline
Side-by-side
matlab/getPowerDeriv.m
0 → 100644
View file @
509cc151
function
dxp
=
getPowerDeriv
(
x
,
p
,
k
)
%function dxp=getPowerDeriv(x,p,k)
% The k-th derivative of x^p
%
% INPUTS
% x: base
% p: power
% k: derivative order
%
% OUTPUTS
% dxp: k-th derivative of x^p
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2011 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if
(
abs
(
x
)
<
1e-12
)
&&
(
p
>
0
)
&&
(
k
>=
p
)
&&
(
abs
(
p
-
round
(
p
))
<
1e-12
)
dxp
=
0
;
else
dxp
=
x
^
(
p
-
k
);
for
i
=
0
:
k
-
1
dxp
=
dxp
*
p
;
p
=
p
-
1
;
end
end
end
preprocessor/DataTree.cc
View file @
509cc151
...
...
@@ -660,10 +660,7 @@ DataTree::writePowerDerivCHeader(ostream &output) const
void
DataTree
::
writePowerDeriv
(
ostream
&
output
,
bool
use_dll
)
const
{
if
(
!
isBinaryOpUsed
(
oPowerDeriv
))
return
;
if
(
use_dll
)
if
(
use_dll
&&
isBinaryOpUsed
(
oPowerDeriv
))
output
<<
"/*"
<<
endl
<<
" * The k-th derivative of x^p"
<<
endl
<<
" */"
<<
endl
...
...
@@ -683,21 +680,4 @@ DataTree::writePowerDeriv(ostream &output, bool use_dll) const
<<
" return dxp;"
<<
endl
<<
" }"
<<
endl
<<
"}"
<<
endl
;
else
output
<<
endl
<<
"%"
<<
endl
<<
"% The k-th derivative of x^p"
<<
endl
<<
"%"
<<
endl
<<
"function dxp=getPowerDeriv(x,p,k)"
<<
endl
<<
" if (abs(x) < "
<<
NEAR_ZERO
<<
") && (p > 0) && (k >= p) && (abs(p - round(p)) < "
<<
NEAR_ZERO
<<
")"
<<
endl
<<
" dxp = 0;"
<<
endl
<<
" else"
<<
endl
<<
" dxp = x^(p-k);"
<<
endl
<<
" for i=0:k-1"
<<
endl
<<
" dxp = dxp*p;"
<<
endl
<<
" p = p-1;"
<<
endl
<<
" end"
<<
endl
<<
" end"
<<
endl
<<
"end"
<<
endl
;
}
preprocessor/DynamicModel.cc
View file @
509cc151
...
...
@@ -780,7 +780,6 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
break
;
}
output
<<
"end"
<<
endl
;
writePowerDeriv
(
output
,
false
);
output
.
close
();
}
}
...
...
@@ -1513,7 +1512,6 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
writeDynamicModel
(
mDynamicModelFile
,
false
);
mDynamicModelFile
<<
"end"
<<
endl
;
// Close *_dynamic function
writePowerDeriv
(
mDynamicModelFile
,
false
);
mDynamicModelFile
.
close
();
}
...
...
@@ -2022,7 +2020,6 @@ DynamicModel::writeSparseDynamicMFile(const string &dynamic_basename, const stri
mDynamicModelFile
<<
" oo_.endo_simul = y';
\n
"
;
mDynamicModelFile
<<
"return;
\n
"
;
mDynamicModelFile
<<
"end"
<<
endl
;
writePowerDeriv
(
mDynamicModelFile
,
false
);
mDynamicModelFile
.
close
();
...
...
@@ -3674,9 +3671,6 @@ DynamicModel::writeParamsDerivativesFile(const string &basename) const
paramsDerivsFile
<<
"end"
<<
endl
<<
"end"
<<
endl
;
writePowerDeriv
(
paramsDerivsFile
,
false
);
paramsDerivsFile
.
close
();
}
...
...
preprocessor/StaticModel.cc
View file @
509cc151
...
...
@@ -396,7 +396,6 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
break
;
}
output
<<
"end"
<<
endl
;
writePowerDeriv
(
output
,
false
);
output
.
close
();
}
}
...
...
@@ -1238,7 +1237,6 @@ StaticModel::writeStaticMFile(const string &func_name) const
output
<<
"end"
<<
endl
;
// Close the if nargout >= 3 statement
output
<<
"end"
<<
endl
;
// Close the *_static function
writePowerDeriv
(
output
,
false
);
output
.
close
();
}
...
...
@@ -1322,7 +1320,6 @@ StaticModel::writeStaticBlockMFSFile(const string &basename) const
}
output
<<
" end"
<<
endl
<<
"end"
<<
endl
;
writePowerDeriv
(
output
,
false
);
output
.
close
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment