From cafbab43921128cbed65d0e63bf57363636d40a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 17:28:19 +0200 Subject: [PATCH] Added cycle reduction routine (and logarithmic reduction routine) in the unitary tests suite. --- matlab/cycle_reduction.m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/matlab/cycle_reduction.m b/matlab/cycle_reduction.m index 04fca27a7..1449e2a52 100644 --- a/matlab/cycle_reduction.m +++ b/matlab/cycle_reduction.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %@info: @@ -43,7 +44,7 @@ function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %! @end deftypefn %@eod: -% Copyright (C) 2012 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % @@ -112,23 +113,39 @@ if (nargin == 5 && ~isempty(ch) ) end %@test:1 -%$ addpath ../matlab %$ -%$ % Set the dimension of the problem to be solved +%$ t = zeros(3,1); +%$ +%$ % Set the dimension of the problem to be solved. %$ n = 2000; +%$ %$ % Set the equation to be solved %$ A = eye(n); %$ B = diag(30*ones(n,1)); B(1,1) = 20; B(end,end) = 20; B = B - diag(10*ones(n-1,1),-1); B = B - diag(10*ones(n-1,1),1); %$ C = diag(15*ones(n,1)); C = C - diag(5*ones(n-1,1),-1); C = C - diag(5*ones(n-1,1),1); %$ %$ % Solve the equation with the cycle reduction algorithm -%$ tic, X1 = cycle_reduction(C,B,A,1e-7); toc +%$ try +%$ t=cputime; X1 = cycle_reduction(C,B,A,1e-7); elapsedtime = cputime-t; +%$ disp(['cputime for cycle reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(1) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Solve the equation with the logarithmic reduction algorithm -%$ tic, X2 = logarithmic_reduction(A,B,C,1e-16,100); toc +%$ try +%$ t=cputime; X2 = logarithmic_reduction(A,B,C,1e-16,100); elapsedtime = cputime-t; +%$ disp(['cputime for logarithmic reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(2) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Check the results. -%$ t(1) = dyn_assert(X1,X2,1e-12); +%$ if t(1) && t(2) +%$ t(3) = dyn_assert(X1,X2,1e-12); +%$ end %$ %$ T = all(t); %@eof:1 \ No newline at end of file