From b02c83a92662782048a20387930f55a2e51807ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Wed, 11 Jul 2012 17:00:38 +0200
Subject: [PATCH] Added unitary test.

Comparison of the solutions returned by the cyclic reduction and logarithmic reduction algorithm. Note
that in the case considered here the logarithmic reduction algorithm is faster.
---
 matlab/cycle_reduction.m | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/matlab/cycle_reduction.m b/matlab/cycle_reduction.m
index 67153d0c3b..572c52e613 100644
--- a/matlab/cycle_reduction.m
+++ b/matlab/cycle_reduction.m
@@ -98,4 +98,26 @@ if (nargin == 5 && ~isempty(ch) )
     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
-end
\ No newline at end of file
+end
+
+%@test:1
+%$ addpath ../matlab
+%$
+%$ % 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
+%$
+%$ % Solve the equation with the logarithmic reduction algorithm
+%$ tic, X2 = logarithmic_reduction(A,B,C,1e-16,100); toc
+%$
+%$ % Check the results.
+%$ t(1) = dyn_assert(X1,X2,1e-12);
+%$
+%$ T = all(t);
+%@eof:1
\ No newline at end of file
-- 
GitLab