-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpathtransform.m
More file actions
25 lines (21 loc) · 870 Bytes
/
pathtransform.m
File metadata and controls
25 lines (21 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function [F,J,domerr] = pathtransform(x,jacflag)
% PATHTRANSFORM Allows to pass a model to the solver PATH
%
% The MCP solver PATH does not accept anonymous function or supplementary
% arguments, so the function PATHTRANSFORM is used as model argument for PATH
% and the original model, along with its supplementary arguments, is passed as
% an anonymous function in a global variable (eqtosolve).
% Copyright (C) 2011-2013 Christophe Gouel
% Licensed under the Expat license, see LICENSE.txt
global eqtosolve
if (jacflag)
[F,J] = eqtosolve(x);
isdomerrJ = any((isinf(J) | (imag(J)~=0) | isnan(J)),2);
else
F = eqtosolve(x);
J = [];
isdomerrJ = zeros(size(F));
end
%% Calculation of number of ex-post domain errors
isdomerrF = isinf(F) | (imag(F)~=0) | isnan(F);
domerr = sum(any([isdomerrF isdomerrJ],2));