Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
Dynare
dynare
Commits
2c450c79
Commit
2c450c79
authored
12 years ago
by
MichelJuillard
Browse files
Options
Downloads
Patches
Plain Diff
cycle reduction: return error codes for over- and under-determined
dynamic systems
parent
edf826f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/cycle_reduction.m
+33
-23
33 additions, 23 deletions
matlab/cycle_reduction.m
with
33 additions
and
23 deletions
matlab/cycle_reduction.m
+
33
−
23
View file @
2c450c79
...
...
@@ -63,38 +63,48 @@ function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch)
max_it
=
300
;
it
=
0
;
info
=
0
;
crit
=
1
+
cvg_tol
;
A_0
=
A1
;
X
=
[]
;
crit
=
Inf
;
A0_0
=
A0
;
A1_0
=
A1
;
A2_0
=
A2
;
if
(
nargin
==
5
&&
~
isempty
(
ch
)
)
A1_0
=
A1
;
A2_0
=
A2
;
end
n
=
length
(
A0
);
id
=
1
:
n
;
id0
=
1
:
n
;
id2
=
id0
+
n
;
while
crit
>
cvg_tol
&&
it
<
max_it
;
tmp
=
[
A2_0
;
A0_0
]
/
A1_0
;
TMP
=
tmp
*
A0_0
;
A2_1
=
-
tmp
(
id
,
:
)
*
A2_0
;
A_1
=
A_0
-
TMP
(
id
,
:
);
A1_1
=
A1_0
-
tmp
(
n
+
id
,
:
)
*
A2_0
-
TMP
(
id
,
:
);
crit
=
sum
(
sum
(
abs
(
A0_0
)));
A_0
=
A_1
;
A0_0
=
-
TMP
(
n
+
id
,
:
);
A1_0
=
A1_1
;
A2_0
=
A2_1
;
cont
=
1
;
while
cont
crit
>
cvg_tol
&&
it
<
max_it
&&
~
isnan
(
crit
)
tmp
=
([
A0
;
A2
]
/
A1
)
*
[
A0
A2
];
A1
=
A1
-
tmp
(
id0
,
id2
)
-
tmp
(
id2
,
id0
);
A0
=
-
tmp
(
id0
,
id0
);
A2
=
-
tmp
(
id2
,
id2
);
crit
=
norm
(
A0
,
1
);
if
crit
<
cvg_tol
%
keep
iterating
until
condition
on
A2
is
met
if
norm
(
A2
,
1
)
<
cvg_tol
cont
=
0
;
end
elseif
isnan
(
crit
)
||
it
==
max_it
if
crit
<
cvg_tol
info
(
1
)
=
4
;
info
(
2
)
=
log
(
norm
(
A2
,
1
))
else
info
(
1
)
=
3
;
info
(
2
)
=
log
(
norm
(
A1
,
1
))
end
return
end
it
=
it
+
1
;
end
if
it
==
max_it
disp
([
'
convergence
not
achieved
after
'
int2str
(
it
)
'
iterations
'
]);
info
=
1
;
end
X
=
-
A_0
\
A0
;
X
=
-
A1
\
A0_0
;
if
(
nargin
==
5
&&
~
isempty
(
ch
)
)
%
check
the
solution
res
=
A0
+
A1
*
X
+
A2
*
X
*
X
;
res
=
A0
_0
+
A1
_0
*
X
+
A2
_0
*
X
*
X
;
if
(
sum
(
sum
(
abs
(
res
)))
>
cvg_tol
)
disp
([
'
the
norm
residual
of
the
residu
'
num2str
(
res
)
'
compare
to
the
tolerance
criterion
'
num2str
(
cvg_tol
)]);
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