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
3025a14e
Commit
3025a14e
authored
Mar 25, 2013
by
Sébastien Villemot
Browse files
Adapt for removal of luinc in MATLAB R2013a
parent
3079ad49
Changes
5
Hide whitespace changes
Inline
Side-by-side
matlab/dynare_config.m
View file @
3025a14e
...
...
@@ -89,6 +89,11 @@ if ~exist('OCTAVE_VERSION') && matlab_ver_less_than('7.4')
addpath
([
dynareroot
'/missing/bsxfun'
])
end
% ilu is missing in old versions of MATLAB and in Octave
if
exist
(
'OCTAVE_VERSION'
)
||
matlab_ver_less_than
(
'7.4'
)
addpath
([
dynareroot
'/missing/ilu'
])
end
% nanmean is in Octave Forge Statistics package and in MATLAB Statistics
% toolbox
if
(
exist
(
'OCTAVE_VERSION'
)
&&
~
user_has_octave_forge_package
(
'statistics'
))
...
...
...
matlab/missing/ilu/ilu.m
0 → 100644
View file @
3025a14e
function
[
L
,
U
,
P
]
=
ilu
(
A
,
setup
)
% Partially implement function ilu using the (now deprecated) luinc
% Copyright (C) 2013 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
nargout
~=
2
error
(
'Only two output arguments supported'
)
end
if
nargin
~=
2
error
(
'Only two input arguments supported'
)
end
if
isfield
(
setup
,
'type'
)
if
setup
.
type
~=
'ilutp'
error
([
'Unsupported type: '
setup
.
type
])
end
end
if
isfield
(
setup
,
'milu'
)
if
setup
.
milu
==
'off'
setup
.
milu
=
0
;
else
error
([
'Unsupported milu: '
setup
.
milu
])
end
end
[
L
,
U
]
=
luinc
(
A
,
setup
);
end
matlab/solve_one_boundary.m
View file @
3025a14e
...
...
@@ -55,7 +55,7 @@ function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ...
% none.
%
% Copyright (C) 1996-201
2
Dynare Team
% Copyright (C) 1996-201
3
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -77,7 +77,7 @@ Blck_size=size(y_index_eq,2);
g2
=
[];
g3
=
[];
correcting_factor
=
0.01
;
lu
inc_
tol
=
1e-10
;
i
lu
_setup
.
drop
tol
=
1e-10
;
max_resa
=
1e100
;
reduced
=
0
;
if
(
forward_backward
)
...
...
@@ -316,7 +316,7 @@ for it_=start:incr:finish
disp
(
'steady: GMRES '
);
end
while
(
flag1
>
0
)
[
L1
,
U1
]
=
lu
inc
(
g1
,
lu
inc_tol
);
[
L1
,
U1
]
=
i
lu
(
g1
,
i
lu
_setup
);
[
dx
,
flag1
]
=
gmres
(
g1
,
-
r
,
Blck_size
,
1e-6
,
Blck_size
,
L1
,
U1
);
if
(
flag1
>
0
||
reduced
)
if
(
flag1
==
1
)
...
...
@@ -326,7 +326,7 @@ for it_=start:incr:finish
elseif
(
flag1
==
3
)
disp
([
'Error in simul: GMRES stagnated (Two consecutive iterates were the same.), in block'
num2str
(
Block_Num
,
'%3d'
)]);
end
;
lu
inc_
tol
=
lu
inc_
tol
/
10
;
i
lu
_setup
.
drop
tol
=
i
lu
_setup
.
drop
tol
/
10
;
reduced
=
0
;
else
ya
=
ya
+
lambda
*
dx
;
...
...
@@ -343,7 +343,7 @@ for it_=start:incr:finish
disp
(
'steady: BiCGStab'
);
end
while
(
flag1
>
0
)
[
L1
,
U1
]
=
lu
inc
(
g1
,
lu
inc_tol
);
[
L1
,
U1
]
=
i
lu
(
g1
,
i
lu
_setup
);
phat
=
ya
-
U1
\
(
L1
\
r
);
if
(
is_dynamic
)
y
(
it_
,
y_index_eq
)
=
phat
;
...
...
@@ -370,7 +370,7 @@ for it_=start:incr:finish
elseif
(
flag1
==
3
)
disp
([
'Error in simul: GMRES stagnated (Two consecutive iterates were the same.), in block'
num2str
(
Block_Num
,
'%3d'
)]);
end
;
lu
inc_
tol
=
lu
inc_
tol
/
10
;
i
lu
_setup
.
drop
tol
=
i
lu
_setup
.
drop
tol
/
10
;
reduced
=
0
;
else
ya
=
ya
+
lambda
*
dx
;
...
...
matlab/solve_two_boundaries.m
View file @
3025a14e
...
...
@@ -43,7 +43,7 @@ function y = solve_two_boundaries(fname, y, x, params, steady_state, y_index, nz
% none.
%
% Copyright (C) 1996-201
1
Dynare Team
% Copyright (C) 1996-201
3
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -67,7 +67,7 @@ g2 = [];
g3
=
[];
Blck_size
=
size
(
y_index
,
2
);
correcting_factor
=
0.01
;
lu
inc_
tol
=
1e-10
;
i
lu
_setup
.
drop
tol
=
1e-10
;
max_resa
=
1e100
;
Jacobian_Size
=
Blck_size
*
(
y_kmin
+
y_kmax_l
+
periods
);
g1
=
spalloc
(
Blck_size
*
periods
,
Jacobian_Size
,
nze
*
periods
);
...
...
@@ -198,7 +198,7 @@ while ~(cvg==1 || iter>maxit_),
flag1
=
1
;
while
(
flag1
>
0
)
if
preconditioner
==
2
[
L1
,
U1
]
=
lu
inc
(
g1a
,
lu
inc_tol
);
[
L1
,
U1
]
=
i
lu
(
g1a
,
i
lu
_setup
);
elseif
preconditioner
==
3
Size
=
Blck_size
;
gss1
=
g1a
(
Size
+
1
:
2
*
Size
,
Size
+
1
:
2
*
Size
)
+
g1a
(
Size
+
1
:
2
*
Size
,
2
*
Size
+
1
:
3
*
Size
);
...
...
@@ -233,7 +233,7 @@ while ~(cvg==1 || iter>maxit_),
elseif
(
flag1
==
3
)
disp
([
'Error in simul: GMRES stagnated (Two consecutive iterates were the same.), in block'
num2str
(
Block_Size
,
'%3d'
)]);
end
;
lu
inc_
tol
=
lu
inc_
tol
/
10
;
i
lu
_setup
.
drop
tol
=
i
lu
_setup
.
drop
tol
/
10
;
reduced
=
0
;
else
dx
=
za
-
ya
;
...
...
@@ -271,7 +271,7 @@ while ~(cvg==1 || iter>maxit_),
elseif
(
flag1
==
3
)
disp
([
'Error in simul: GMRES stagnated (Two consecutive iterates were the same.), in block'
num2str
(
Block_Size
,
'%3d'
)]);
end
;
lu
inc_
tol
=
lu
inc_
tol
/
10
;
i
lu
_setup
.
drop
tol
=
i
lu
_setup
.
drop
tol
/
10
;
reduced
=
0
;
else
dx
=
za
-
ya
;
...
...
mex/sources/bytecode/SparseMatrix.cc
View file @
3025a14e
/*
* Copyright (C) 2007-201
2
Dynare Team
* Copyright (C) 2007-201
3
Dynare Team
*
* This file is part of Dynare.
*
...
...
@@ -4589,11 +4589,15 @@ dynSparseMatrix::Solve_Matlab_GMRES(mxArray *A_m, mxArray *b_m, int Size, double
throw
FatalExceptionHandling
(
tmp
.
str
());
#endif
size_t
n
=
mxGetM
(
A_m
);
const
char
*
field_names
[]
=
{
"droptol"
};
mwSize
dims
[
1
]
=
{
1
};
mxArray
*
Setup
=
mxCreateStructArray
(
1
,
dims
,
1
,
field_names
);
mxSetFieldByNumber
(
Setup
,
0
,
0
,
mxCreateDoubleScalar
(
lu_inc_tol
));
mxArray
*
lhs0
[
2
];
mxArray
*
rhs0
[
2
];
rhs0
[
0
]
=
A_m
;
rhs0
[
1
]
=
mxCreateDoubleScalar
(
lu_inc_tol
)
;
mexCallMATLAB
(
2
,
lhs0
,
2
,
rhs0
,
"lu
inc
"
);
rhs0
[
1
]
=
Setup
;
mexCallMATLAB
(
2
,
lhs0
,
2
,
rhs0
,
"
i
lu"
);
mxArray
*
L1
=
lhs0
[
0
];
mxArray
*
U1
=
lhs0
[
1
];
/*[za,flag1] = gmres(g1a,b,Blck_size,1e-6,Blck_size*periods,L1,U1);*/
...
...
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