external_function: modified to pass functions as string names as opposed to function handles to reduce number of calls to mexCallMatlab when use_dll option is invoked

time-shift
Houtan Bastani 2010-10-07 14:15:56 +02:00
parent dbbe177ed6
commit c19df582e0
3 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@ function d=hess_element(func,element1,element2,args)
% returns an entry of the finite differences approximation to the hessian of func
%
% INPUTS
% func [function handle] associated with the function
% func [function name] string with name of the function
% element1 [int] the indices showing the element within the hessian that should be returned
% element2 [int]
% args [cell array] arguments provided to func
@ -31,6 +31,8 @@ function d=hess_element(func,element1,element2,args)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
func = str2func(func);
h=10e-6;
p10 = args;
p01 = args;

View File

@ -3,7 +3,7 @@ function d=jacob_element(func,element,args)
% returns an entry of the finite differences approximation to the jacobian of func
%
% INPUTS
% func [function handle] associated with the function
% func [function name] string with name of the function
% element [int] the index showing the element within the jacobian that should be returned
% args [cell array] arguments provided to func
%
@ -30,6 +30,8 @@ function d=jacob_element(func,element,args)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
func = str2func(func);
h=10e-6;
pargs=args;
margs=args;

View File

@ -3963,8 +3963,8 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
if (first_deriv_symb_id == symb_id)
return;
else if (first_deriv_symb_id == eExtFunNotSet)
output << "TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << " = jacob_element(@"
<< datatree.symbol_table.getName(symb_id) << "," << inputIndex << ",{";
output << "TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << " = jacob_element('"
<< datatree.symbol_table.getName(symb_id) << "'," << inputIndex << ",{";
else
{
tef_terms[make_pair(first_deriv_symb_id, arguments)] = (int) tef_terms.size();
@ -4065,7 +4065,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
return;
else if (second_deriv_symb_id == eExtFunNotSet)
output << "TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2
<< " = hess_element(@" << datatree.symbol_table.getName(symb_id) << ","
<< " = hess_element('" << datatree.symbol_table.getName(symb_id) << "',"
<< inputIndex1 << "," << inputIndex2 << ",{";
else
{