diff options
Diffstat (limited to 'modules/umfpack/tests')
28 files changed, 1329 insertions, 0 deletions
diff --git a/modules/umfpack/tests/nonreg_tests/bug_10626.dia.ref b/modules/umfpack/tests/nonreg_tests/bug_10626.dia.ref new file mode 100755 index 000000000..2c6ebe2cf --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_10626.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10626 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10626 +// +// <-- Short Description --> +// taucs_chdel(), umf_ludel() returned an error +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +Lup = umf_lufact(A); +umf_ludel(); +assert_checkequal(lasterror(), []); +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +b = [0 ; 0; 0; 0; 6]; +Cp = taucs_chfact(A); +taucs_chdel(); +assert_checkequal(lasterror(), []); diff --git a/modules/umfpack/tests/nonreg_tests/bug_10626.tst b/modules/umfpack/tests/nonreg_tests/bug_10626.tst new file mode 100755 index 000000000..180f4a2f6 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_10626.tst @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10626 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10626 +// +// <-- Short Description --> +// taucs_chdel(), umf_ludel() returned an error + +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +Lup = umf_lufact(A); +umf_ludel(); +assert_checkequal(lasterror(), []); + +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +b = [0 ; 0; 0; 0; 6]; +Cp = taucs_chfact(A); +taucs_chdel(); +assert_checkequal(lasterror(), []); diff --git a/modules/umfpack/tests/nonreg_tests/bug_5016.dia.ref b/modules/umfpack/tests/nonreg_tests/bug_5016.dia.ref new file mode 100755 index 000000000..b5db0ce48 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_5016.dia.ref @@ -0,0 +1,45 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 5016 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5016 +// +// <-- Short Description --> +// condestsp could yield different results when repeated calls were performed. +A = [ +1.7478328000000000752578 -0.1903736000000000039289 1.3090182999999999680085 -1.3628348999999999602295 0.3444064000000000014268 +0.2762794000000000083084 -1.0118259000000000558117 1.1937549000000000631871 -0.3618465000000000153513 1.417060200000000103060 +-1.0079914000000000928736 -1.2770016 -0.9433875999999999928392 -0.1351713999999999971102 -0.1938765000000000071623 +-0.4281269999999999797957 -1.5414133000000000972562 0.5169858000000000508578 0.9329383999999999455000 -1.2854697999999999957765 +-0.5434953999999999618709 -0.3191552999999999751246 0.8207168000000000240846 -1.0325953999999999410875 -1.1262562000000000406175 +] + A = + + 1.7478328 - 0.1903736 1.3090183 - 1.3628349 0.3444064 + 0.2762794 - 1.0118259 1.1937549 - 0.3618465 1.4170602 + - 1.0079914 - 1.2770016 - 0.9433876 - 0.1351714 - 0.1938765 + - 0.428127 - 1.5414133 0.5169858 0.9329384 - 1.2854698 + - 0.5434954 - 0.3191553 0.8207168 - 1.0325954 - 1.1262562 +function c = cond1 ( A ) + SA = sparse ( A ); + c = condestsp ( SA ); +endfunction +refCond = 7.0462354; +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); diff --git a/modules/umfpack/tests/nonreg_tests/bug_5016.tst b/modules/umfpack/tests/nonreg_tests/bug_5016.tst new file mode 100755 index 000000000..8e1c7ab3e --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_5016.tst @@ -0,0 +1,41 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 5016 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5016 +// +// <-- Short Description --> +// condestsp could yield different results when repeated calls were performed. + +A = [ +1.7478328000000000752578 -0.1903736000000000039289 1.3090182999999999680085 -1.3628348999999999602295 0.3444064000000000014268 +0.2762794000000000083084 -1.0118259000000000558117 1.1937549000000000631871 -0.3618465000000000153513 1.417060200000000103060 +-1.0079914000000000928736 -1.2770016 -0.9433875999999999928392 -0.1351713999999999971102 -0.1938765000000000071623 +-0.4281269999999999797957 -1.5414133000000000972562 0.5169858000000000508578 0.9329383999999999455000 -1.2854697999999999957765 +-0.5434953999999999618709 -0.3191552999999999751246 0.8207168000000000240846 -1.0325953999999999410875 -1.1262562000000000406175 +] +function c = cond1 ( A ) + SA = sparse ( A ); + c = condestsp ( SA ); +endfunction + +refCond = 7.0462354; + +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); +Cond = cond1 ( A ); +assert_checkalmostequal(Cond, refCond, [], 1d-6); diff --git a/modules/umfpack/tests/nonreg_tests/bug_7754.dia.ref b/modules/umfpack/tests/nonreg_tests/bug_7754.dia.ref new file mode 100755 index 000000000..f859e8480 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_7754.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7754 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7754 +// +// <-- Short Description --> +// umfpack did not work with Scilab 5.3.0-beta-2 on Windows. +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +if execstr("x = umfpack(A, ""\"", b);", "errcatch") <> 0 then bugmes();quit;end diff --git a/modules/umfpack/tests/nonreg_tests/bug_7754.tst b/modules/umfpack/tests/nonreg_tests/bug_7754.tst new file mode 100755 index 000000000..a7e10c4b2 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_7754.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7754 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7754 +// +// <-- Short Description --> +// umfpack did not work with Scilab 5.3.0-beta-2 on Windows. + +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +if execstr("x = umfpack(A, ""\"", b);", "errcatch") <> 0 then pause, end + diff --git a/modules/umfpack/tests/nonreg_tests/bug_8824.dia.ref b/modules/umfpack/tests/nonreg_tests/bug_8824.dia.ref new file mode 100755 index 000000000..7144996a2 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_8824.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 8824 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8824 +// +// <-- Short Description --> +// taucs_chfact returns a segfault (not the case in mode nwni) +stacksize("max"); +N=512; +h = 1/(N+1); +x = h:h:1-h; +y = x; +[X,Y] = ndgrid(x,y); +F = (-2*(%pi^2))*(cos((2*%pi)*X) .*(sin(%pi*Y) .^2) + (sin(%pi*X).^2).*cos((2*%pi)*Y)); +b = (h^2)*F(:); +s = [-1*ones(1,N-1) 2*ones(1,N) -1*ones(1,N-1)]'; +i = [2:N 1:N 1:N-1]'; +j = [1:N-1 1:N 2:N ]'; +ij = [i j]; +T = sparse(ij,s); +I = speye(N,N); +A = I .*. T + T .*. I; +assert_checktrue(execstr("hchol=taucs_chfact(A)","errcatch")==0); +assert_checktrue(execstr("taucs_chsolve(hchol,b)","errcatch")==0); +assert_checktrue(execstr("taucs_chdel(hchol)","errcatch")==0); diff --git a/modules/umfpack/tests/nonreg_tests/bug_8824.tst b/modules/umfpack/tests/nonreg_tests/bug_8824.tst new file mode 100755 index 000000000..f0ee498b3 --- /dev/null +++ b/modules/umfpack/tests/nonreg_tests/bug_8824.tst @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 8824 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8824 +// +// <-- Short Description --> +// taucs_chfact returns a segfault (not the case in mode nwni) + +stacksize("max"); +N=512; +h = 1/(N+1); +x = h:h:1-h; +y = x; +[X,Y] = ndgrid(x,y); +F = (-2*(%pi^2))*(cos((2*%pi)*X) .*(sin(%pi*Y) .^2) + (sin(%pi*X).^2).*cos((2*%pi)*Y)); +b = (h^2)*F(:); +s = [-1*ones(1,N-1) 2*ones(1,N) -1*ones(1,N-1)]'; +i = [2:N 1:N 1:N-1]'; +j = [1:N-1 1:N 2:N ]'; +ij = [i j]; +T = sparse(ij,s); +I = speye(N,N); +A = I .*. T + T .*. I; + +assert_checktrue(execstr("hchol=taucs_chfact(A)","errcatch")==0); +assert_checktrue(execstr("taucs_chsolve(hchol,b)","errcatch")==0); +assert_checktrue(execstr("taucs_chdel(hchol)","errcatch")==0); diff --git a/modules/umfpack/tests/unit_tests/condestsp.dia.ref b/modules/umfpack/tests/unit_tests/condestsp.dia.ref new file mode 100755 index 000000000..bf5e7b376 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/condestsp.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyright (C) 2008 - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +warning("off"); +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +K1 = condestsp(A); +if norm(K1,39.385965) < 1E-6 then bugmes();quit;end +// verif by direct computation +K1e = norm(A,1)*norm(inv(full(A)),1); +if norm(K1e,39.385965) < 1E-6 then bugmes();quit;end +if K1e <> K1 then bugmes();quit;end +// another example +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/arc130.rua"); +K1 = condestsp(A); +if round(K1) <> 10798708075 then bugmes();quit;end +// this example is not so big so that we can do the verif +K1e = norm(A,1)*norm(inv(full(A)),1); +if round(K1e) <> 10798708075 then bugmes();quit;end +if round(K1) <> round(K1e) then bugmes();quit;end +// if you have already the lu factors condestsp(A,Lup) is faster +// because lu factors are then not computed inside condestsp +Lup = umf_lufact(A); +K1 = condestsp(A,Lup); +if round(K1) <> 10798708075 then bugmes();quit;end +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/condestsp.tst b/modules/umfpack/tests/unit_tests/condestsp.tst new file mode 100755 index 000000000..abbe9478c --- /dev/null +++ b/modules/umfpack/tests/unit_tests/condestsp.tst @@ -0,0 +1,42 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyright (C) 2008 - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +warning("off"); + +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +K1 = condestsp(A); +if norm(K1,39.385965) < 1E-6 then pause, end + +// verif by direct computation +K1e = norm(A,1)*norm(inv(full(A)),1); +if norm(K1e,39.385965) < 1E-6 then pause, end +if K1e <> K1 then pause, end + +// another example +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/arc130.rua"); +K1 = condestsp(A); +if round(K1) <> 10798708075 then pause, end + +// this example is not so big so that we can do the verif +K1e = norm(A,1)*norm(inv(full(A)),1); +if round(K1e) <> 10798708075 then pause, end +if round(K1) <> round(K1e) then pause, end + +// if you have already the lu factors condestsp(A,Lup) is faster +// because lu factors are then not computed inside condestsp +Lup = umf_lufact(A); +K1 = condestsp(A,Lup); +if round(K1) <> 10798708075 then pause, end + +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/res_with_prec.dia.ref b/modules/umfpack/tests/unit_tests/res_with_prec.dia.ref new file mode 100755 index 000000000..c7bbe046c --- /dev/null +++ b/modules/umfpack/tests/unit_tests/res_with_prec.dia.ref @@ -0,0 +1,14 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +C_ptr = taucs_chfact(A); +b = rand(size(A,1),1); +x0 = taucs_chsolve(C_ptr, b); +firstNorm=norm(A*x0 - b); +secondNorm=norm(res_with_prec(A, x0, b)); +if firstNorm < secondNorm then bugmes();quit;end diff --git a/modules/umfpack/tests/unit_tests/res_with_prec.tst b/modules/umfpack/tests/unit_tests/res_with_prec.tst new file mode 100755 index 000000000..b105d29fc --- /dev/null +++ b/modules/umfpack/tests/unit_tests/res_with_prec.tst @@ -0,0 +1,16 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +C_ptr = taucs_chfact(A); +b = rand(size(A,1),1); +x0 = taucs_chsolve(C_ptr, b); +firstNorm=norm(A*x0 - b); +secondNorm=norm(res_with_prec(A, x0, b)); +if firstNorm < secondNorm then pause, end diff --git a/modules/umfpack/tests/unit_tests/taucs_chfact.dia.ref b/modules/umfpack/tests/unit_tests/taucs_chfact.dia.ref new file mode 100755 index 000000000..62e6e9833 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/taucs_chfact.dia.ref @@ -0,0 +1,35 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +// Example #1 : a small linear test system +// whom solution must be [1;2;3;4;5] +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +b = [0 ; 0; 0; 0; 6]; +Cp = taucs_chfact(A); +x = taucs_chsolve(Cp,b); +if round(x) <> [ 1; 2; 3; 4; 5 ] then bugmes();quit;end +// don't forget to clear memory with +taucs_chdel(Cp) +// Example #2 a real example +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +// compute the factorization +Cp = taucs_chfact(A); +b = rand(size(A,1),1); // a random rhs +// use taucs_chsolve for solving Ax=b +x = taucs_chsolve(Cp,b); +firstNorm=norm(A*x - b); +// the same with one iterative refinement step +x = taucs_chsolve(Cp,b,A); +secondNorm=norm(A*x - b); +if norm(firstNorm,secondNorm) < 1E-7 then bugmes();quit;end +// don't forget to clear memory +taucs_chdel(Cp) diff --git a/modules/umfpack/tests/unit_tests/taucs_chfact.tst b/modules/umfpack/tests/unit_tests/taucs_chfact.tst new file mode 100755 index 000000000..773f1df88 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/taucs_chfact.tst @@ -0,0 +1,41 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +// Example #1 : a small linear test system +// whom solution must be [1;2;3;4;5] +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +b = [0 ; 0; 0; 0; 6]; +Cp = taucs_chfact(A); +x = taucs_chsolve(Cp,b); +if round(x) <> [ 1; 2; 3; 4; 5 ] then pause, end + +// don't forget to clear memory with +taucs_chdel(Cp) + +// Example #2 a real example +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +// compute the factorization +Cp = taucs_chfact(A); +b = rand(size(A,1),1); // a random rhs +// use taucs_chsolve for solving Ax=b +x = taucs_chsolve(Cp,b); +firstNorm=norm(A*x - b); +// the same with one iterative refinement step +x = taucs_chsolve(Cp,b,A); +secondNorm=norm(A*x - b); + +if norm(firstNorm,secondNorm) < 1E-7 then pause, end + +// don't forget to clear memory +taucs_chdel(Cp) diff --git a/modules/umfpack/tests/unit_tests/taucs_chget.dia.ref b/modules/umfpack/tests/unit_tests/taucs_chget.dia.ref new file mode 100755 index 000000000..fdd54bf82 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/taucs_chget.dia.ref @@ -0,0 +1,41 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- TEST WITH GRAPHIC --> +// Example #1 : a small linear test system +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +Cp = taucs_chfact(A); +[Ct, p] = taucs_chget(Cp); +full(A(p,p) - Ct'*Ct); // this must be near the null matrix +taucs_chdel(Cp); +// Example #2 a real example +stacksize(3000000); // the last PlotSparse need memory +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +// compute the factorization +Cptr = taucs_chfact(A); +// retrieve the factor at scilab level +[Ct, p] = taucs_chget(Cptr); +// plot the initial matrix +xset("window",0) ; clf(); +PlotSparse(A) ; xtitle("Initial matrix A (bcsstk24.rsa)"); +// plot the permuted matrix +B = A(p,p); +xset("window",1) ; clf(); +PlotSparse(B) ; xtitle("Permuted matrix B = A(p,p)"); +// plot the upper triangle Ct +xset("window",2) ; clf(); +PlotSparse(Ct) ; xtitle("The pattern of Ct (A(p,p) = C*Ct)"); +// retrieve cnz +[OK, n, cnz] = taucs_chinfo(Cptr); +// cnz is superior to the realnumber of non zeros elements of C : +cnz_exact = nnz(Ct); +// don't forget to clear memory +taucs_chdel(Cptr); diff --git a/modules/umfpack/tests/unit_tests/taucs_chget.tst b/modules/umfpack/tests/unit_tests/taucs_chget.tst new file mode 100755 index 000000000..e3d8f100d --- /dev/null +++ b/modules/umfpack/tests/unit_tests/taucs_chget.tst @@ -0,0 +1,44 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- TEST WITH GRAPHIC --> + +// Example #1 : a small linear test system +A = sparse( [ 2 -1 0 0 0; + -1 2 -1 0 0; + 0 -1 2 -1 0; + 0 0 -1 2 -1; + 0 0 0 -1 2] ); +Cp = taucs_chfact(A); +[Ct, p] = taucs_chget(Cp); +full(A(p,p) - Ct'*Ct); // this must be near the null matrix +taucs_chdel(Cp); + +// Example #2 a real example +stacksize(3000000); // the last PlotSparse need memory +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/bcsstk24.rsa"); +// compute the factorization +Cptr = taucs_chfact(A); +// retrieve the factor at scilab level +[Ct, p] = taucs_chget(Cptr); +// plot the initial matrix +xset("window",0) ; clf(); +PlotSparse(A) ; xtitle("Initial matrix A (bcsstk24.rsa)"); +// plot the permuted matrix +B = A(p,p); +xset("window",1) ; clf(); +PlotSparse(B) ; xtitle("Permuted matrix B = A(p,p)"); +// plot the upper triangle Ct +xset("window",2) ; clf(); +PlotSparse(Ct) ; xtitle("The pattern of Ct (A(p,p) = C*Ct)"); +// retrieve cnz +[OK, n, cnz] = taucs_chinfo(Cptr); +// cnz is superior to the realnumber of non zeros elements of C : +cnz_exact = nnz(Ct); +// don't forget to clear memory +taucs_chdel(Cptr); diff --git a/modules/umfpack/tests/unit_tests/umf_lufact.dia.ref b/modules/umfpack/tests/unit_tests/umf_lufact.dia.ref new file mode 100755 index 000000000..62d4faa56 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_lufact.dia.ref @@ -0,0 +1,48 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyrigth (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +assert_checkfalse(execstr("umf_lufact()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_lufact", 1); +assert_checkerror("umf_lufact()", refMsg); +assert_checkfalse(execstr("umf_lufact(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umf_lufact", 1); +assert_checkerror("umf_lufact(1)", refMsg); +// this is the small linear test system from UMFPACK +// whom solution must be [1;2;3;4;5] +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +Lup = umf_lufact(A); +x = umf_lusolve(Lup,b); +assert_checkalmostequal(x, [1 2 3 4 5]'); +// solve now A'x=b +x = umf_lusolve(Lup,b,"A''x=b"); +assert_checkequal(norm(A'*x-b), 0) + ans = + + T +// don't forget to clear memory with +umf_ludel(Lup) +// a real (but small) example +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/arc130.rua"); +// compute the factorization +Lup = umf_lufact(A); +b = rand(size(A,1),1); // a random rhs +// use umf_lusolve for solving Ax=b +x = umf_lusolve(Lup,b); +firstNorm=norm(A*x - b); +// now the same thing with iterative refiment +x = umf_lusolve(Lup,b,"Ax=b",A); +secondNorm=norm(A*x - b); +assert_checkfalse(firstNorm <> secondNorm); +// don't forget to clear memory +umf_ludel(Lup) diff --git a/modules/umfpack/tests/unit_tests/umf_lufact.tst b/modules/umfpack/tests/unit_tests/umf_lufact.tst new file mode 100755 index 000000000..4c4498af5 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_lufact.tst @@ -0,0 +1,56 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyrigth (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +assert_checkfalse(execstr("umf_lufact()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_lufact", 1); +assert_checkerror("umf_lufact()", refMsg); + +assert_checkfalse(execstr("umf_lufact(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umf_lufact", 1); +assert_checkerror("umf_lufact(1)", refMsg); + +// this is the small linear test system from UMFPACK +// whom solution must be [1;2;3;4;5] +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +Lup = umf_lufact(A); +x = umf_lusolve(Lup,b); + +assert_checkalmostequal(x, [1 2 3 4 5]'); + +// solve now A'x=b +x = umf_lusolve(Lup,b,"A''x=b"); +assert_checkequal(norm(A'*x-b), 0) + +// don't forget to clear memory with +umf_ludel(Lup) + +// a real (but small) example +// first load a sparse matrix +[A] = ReadHBSparse(SCI+"/modules/umfpack/examples/arc130.rua"); +// compute the factorization +Lup = umf_lufact(A); +b = rand(size(A,1),1); // a random rhs +// use umf_lusolve for solving Ax=b +x = umf_lusolve(Lup,b); +firstNorm=norm(A*x - b); + +// now the same thing with iterative refiment +x = umf_lusolve(Lup,b,"Ax=b",A); +secondNorm=norm(A*x - b); + +assert_checkfalse(firstNorm <> secondNorm); + +// don't forget to clear memory +umf_ludel(Lup) diff --git a/modules/umfpack/tests/unit_tests/umf_luget.dia.ref b/modules/umfpack/tests/unit_tests/umf_luget.dia.ref new file mode 100755 index 000000000..cd8923a72 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_luget.dia.ref @@ -0,0 +1,52 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +assert_checkfalse(execstr("umf_luget()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_luget", 1); +assert_checkerror("umf_luget()", refMsg); +assert_checkfalse(execstr("umf_luget(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_luget", 1); +assert_checkerror("umf_luget(1)", refMsg); +// this is the test matrix from UMFPACK +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), 9); +assert_checkequal(nnz(U), 9); +assert_checkfalse(or(p <> [ 3; 4; 1; 5; 2 ])); +assert_checkfalse(or(q <> [ 4; 3; 1; 5; 2 ])); +assert_checkfalse(or(R <> [ 5; 13; 6; 1; 7 ])); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +B(p,q) - L*U; // must be a (quasi) nul matrix +assert_checkequal(nnz(L*U), 13); +assert_checkequal(nnz(B(p,q)), 12); +umf_ludel(Lup); // clear memory +// the same with a complex matrix +A = sparse( [ 2+%i 3+2*%i 0 0 0; + 3-%i 0 4+%i 0 6-3*%i; + 0 -1+%i -3+6*%i 2-%i 0; + 0 0 1-5*%i 0 0; + 0 4 2-%i 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), 9); +assert_checkequal(nnz(U), 9); +assert_checkfalse(or(p <> [ 3; 4; 1; 5; 2 ])); +assert_checkfalse(or(q <> [ 4; 3; 1; 5; 2 ])); +assert_checkfalse(or(R <> [ 8; 18; 14; 6; 8 ])); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +B(p,q) - L*U; // must be a (quasi) nul matrix +assert_checkequal(nnz(B(p,q)), 12); +assert_checkequal(nnz(L*U), 13); +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/umf_luget.tst b/modules/umfpack/tests/unit_tests/umf_luget.tst new file mode 100755 index 000000000..ced508716 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_luget.tst @@ -0,0 +1,67 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +assert_checkfalse(execstr("umf_luget()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_luget", 1); +assert_checkerror("umf_luget()", refMsg); + +assert_checkfalse(execstr("umf_luget(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_luget", 1); +assert_checkerror("umf_luget(1)", refMsg); + +// this is the test matrix from UMFPACK + +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); + +assert_checkequal(nnz(L), 9); +assert_checkequal(nnz(U), 9); + +assert_checkfalse(or(p <> [ 3; 4; 1; 5; 2 ])); +assert_checkfalse(or(q <> [ 4; 3; 1; 5; 2 ])); +assert_checkfalse(or(R <> [ 5; 13; 6; 1; 7 ])); + +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +B(p,q) - L*U; // must be a (quasi) nul matrix + +assert_checkequal(nnz(L*U), 13); +assert_checkequal(nnz(B(p,q)), 12); + +umf_ludel(Lup); // clear memory + +// the same with a complex matrix +A = sparse( [ 2+%i 3+2*%i 0 0 0; + 3-%i 0 4+%i 0 6-3*%i; + 0 -1+%i -3+6*%i 2-%i 0; + 0 0 1-5*%i 0 0; + 0 4 2-%i 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); + +assert_checkequal(nnz(L), 9); +assert_checkequal(nnz(U), 9); + +assert_checkfalse(or(p <> [ 3; 4; 1; 5; 2 ])); +assert_checkfalse(or(q <> [ 4; 3; 1; 5; 2 ])); +assert_checkfalse(or(R <> [ 8; 18; 14; 6; 8 ])); + +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +B(p,q) - L*U; // must be a (quasi) nul matrix +assert_checkequal(nnz(B(p,q)), 12); +assert_checkequal(nnz(L*U), 13); + +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/umf_luinfo.dia.ref b/modules/umfpack/tests/unit_tests/umf_luinfo.dia.ref new file mode 100755 index 000000000..02604026c --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_luinfo.dia.ref @@ -0,0 +1,33 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - Bruno PINCON +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +assert_checkfalse(execstr("umf_luinfo()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_luinfo", 1); +assert_checkerror("umf_luinfo()", refMsg); +assert_checkfalse(execstr("umf_luinfo(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_luinfo", 1); +assert_checkerror("umf_luinfo(1)", refMsg); +// this is the test matrix from UMFPACK +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +Lup = umf_lufact(A); +[OK, nrow, ncol, lnz, unz, udiag_nz, it] = umf_luinfo(Lup); // OK must be %t, nrow=ncol = 5, +assert_checkequal(OK, %t); +assert_checkequal(nrow, 5); +assert_checkequal(ncol, 5); +assert_checkequal(lnz, 9); +assert_checkequal(unz, 9); +assert_checkequal(udiag_nz, 5); +assert_checkequal(it, 0); +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), lnz); +assert_checkequal(nnz(U), unz); +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/umf_luinfo.tst b/modules/umfpack/tests/unit_tests/umf_luinfo.tst new file mode 100755 index 000000000..4d4a1122e --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_luinfo.tst @@ -0,0 +1,39 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - Bruno PINCON +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +assert_checkfalse(execstr("umf_luinfo()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umf_luinfo", 1); +assert_checkerror("umf_luinfo()", refMsg); + +assert_checkfalse(execstr("umf_luinfo(1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_luinfo", 1); +assert_checkerror("umf_luinfo(1)", refMsg); + +// this is the test matrix from UMFPACK +A = sparse( [ 2 3 0 0 0; + 3 0 4 0 6; + 0 -1 -3 2 0; + 0 0 1 0 0; + 0 4 2 0 1] ); +Lup = umf_lufact(A); +[OK, nrow, ncol, lnz, unz, udiag_nz, it] = umf_luinfo(Lup); // OK must be %t, nrow=ncol = 5, + +assert_checkequal(OK, %t); +assert_checkequal(nrow, 5); +assert_checkequal(ncol, 5); +assert_checkequal(lnz, 9); +assert_checkequal(unz, 9); +assert_checkequal(udiag_nz, 5); +assert_checkequal(it, 0); + +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), lnz); +assert_checkequal(nnz(U), unz); +umf_ludel(Lup) // clear memory diff --git a/modules/umfpack/tests/unit_tests/umf_lusolve.dia.ref b/modules/umfpack/tests/unit_tests/umf_lusolve.dia.ref new file mode 100755 index 000000000..7c6527664 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_lusolve.dia.ref @@ -0,0 +1,48 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// unit tests for umf_lusolve function +// ============================================================================= +assert_checkfalse(execstr("umf_lusolve()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "umf_lusolve", 2, 4); +assert_checkerror("umf_lusolve()", refMsg); +assert_checkfalse(execstr("umf_lusolve(1,1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_lusolve", 1); +assert_checkerror("umf_lusolve(1,1)", refMsg); +B = rand(3,3)*%i; +Lup = umf_lufact(sparse(B)) + Lup = + +assert_checkfalse(execstr("umf_lusolve(Lup, speye(3,3))" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real or complex column vector or matrix expected.\n"), "umf_lusolve", 2); +assert_checkerror("umf_lusolve(Lup, speye(3,3))", refMsg); +assert_checkfalse(execstr("umf_lusolve(Lup, eye(3,3), ""Cx=d"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong input argument #%d: ''%s'' or ''%s'' expected.\n"), "umf_lusolve", 3, "Ax=b", "A''x=b"); +assert_checkerror("umf_lusolve(Lup, eye(3,3), ""Cx=d"")", refMsg); +assert_checkfalse(execstr("umf_lusolve(Lup, eye(3,3), ""Ax=b"", ""titi"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umf_lusolve", 4); +assert_checkerror("umf_lusolve(Lup, eye(3,3), ""Ax=b"", ""titi"")", refMsg); +x = umf_lusolve(Lup, eye(3,3)); +assert_checkalmostequal(x, inv(B)) + ans = + + T +umf_ludel(Lup) +spB = sparse(B); +Lup = umf_lufact(spB); +b = ones(size(spB,1),1); +// use umf_lusolve for solving Ax=b +x = umf_lusolve(Lup,b); +firstNorm=norm(spB*x - b); +// now the same thing with iterative refiment +x = umf_lusolve(Lup,b,"Ax=b",spB); +secondNorm=norm(spB*x - b); +assert_checkalmostequal(firstNorm, secondNorm) + ans = + + T +umf_ludel(Lup) diff --git a/modules/umfpack/tests/unit_tests/umf_lusolve.tst b/modules/umfpack/tests/unit_tests/umf_lusolve.tst new file mode 100755 index 000000000..4dd76f43a --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umf_lusolve.tst @@ -0,0 +1,51 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// unit tests for umf_lusolve function +// ============================================================================= + +assert_checkfalse(execstr("umf_lusolve()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "umf_lusolve", 2, 4); +assert_checkerror("umf_lusolve()", refMsg); + +assert_checkfalse(execstr("umf_lusolve(1,1)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A pointer expected.\n"), "umf_lusolve", 1); +assert_checkerror("umf_lusolve(1,1)", refMsg); + +B = rand(3,3)*%i; +Lup = umf_lufact(sparse(B)) +assert_checkfalse(execstr("umf_lusolve(Lup, speye(3,3))" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A real or complex column vector or matrix expected.\n"), "umf_lusolve", 2); +assert_checkerror("umf_lusolve(Lup, speye(3,3))", refMsg); + +assert_checkfalse(execstr("umf_lusolve(Lup, eye(3,3), ""Cx=d"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong input argument #%d: ''%s'' or ''%s'' expected.\n"), "umf_lusolve", 3, "Ax=b", "A''x=b"); +assert_checkerror("umf_lusolve(Lup, eye(3,3), ""Cx=d"")", refMsg); + +assert_checkfalse(execstr("umf_lusolve(Lup, eye(3,3), ""Ax=b"", ""titi"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umf_lusolve", 4); +assert_checkerror("umf_lusolve(Lup, eye(3,3), ""Ax=b"", ""titi"")", refMsg); + +x = umf_lusolve(Lup, eye(3,3)); +assert_checkalmostequal(x, inv(B)) +umf_ludel(Lup) + +spB = sparse(B); +Lup = umf_lufact(spB); +b = ones(size(spB,1),1); +// use umf_lusolve for solving Ax=b +x = umf_lusolve(Lup,b); +firstNorm=norm(spB*x - b); + +// now the same thing with iterative refiment +x = umf_lusolve(Lup,b,"Ax=b",spB); +secondNorm=norm(spB*x - b); + +assert_checkalmostequal(firstNorm, secondNorm) +umf_ludel(Lup) diff --git a/modules/umfpack/tests/unit_tests/umfpack.dia.ref b/modules/umfpack/tests/unit_tests/umfpack.dia.ref new file mode 100755 index 000000000..59f4f17ec --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umfpack.dia.ref @@ -0,0 +1,85 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +assert_checkfalse(execstr("umfpack()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umfpack", 3); +assert_checkerror("umfpack()", refMsg); +assert_checkfalse(execstr("umfpack(speye(3,3), 2, 2)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "umfpack", 2); +assert_checkerror("umfpack(speye(3,3), 2, 2)", refMsg); +assert_checkfalse(execstr("umfpack(1, ""\"", 2)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umfpack", 1); +assert_checkerror("umfpack(1, ""\"", 2)", refMsg); +assert_checkfalse(execstr("umfpack(speye(3,3), ""\"", %s)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "umfpack", 3); +assert_checkerror("umfpack(speye(3,3), ""\"", %s)", refMsg); +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +x = umfpack(A,"\",b); +assert_checkalmostequal(x, [1 2 3 4 5]'); +// test the other form x A = b +b = [8 20 13 6 17]; +x = umfpack(b,"/",A); // solution must be [1 2 3 4 5] +assert_checkalmostequal(x, [1 2 3 4 5]); +// test multiple rhs +b = rand(5,3); +x = umfpack(A,"\",b); +assert_checkfalse(norm(A*x-b) < %eps); +// test multiple rhs for x A = b +b = rand(3,5); +x = umfpack(b,"/",A); +assert_checkfalse(norm(x*A - b) > %eps); +// solve a complex system +A = sparse( [ 2+%i 3+2*%i 0 0 0; +3-%i 0 4+%i 0 6-3*%i; +0 -1+%i -3+6*%i 2-%i 0; +0 0 1-5*%i 0 0; +0 4 2-%i 0 1] ); +b = [ 3+13*%i ; 58+32*%i ; -19+13*%i ; 18-12*%i ; 22+16*%i ]; +x = umfpack(A,"\",b); // x must be [1+i; 2+2i; 3+3i; 4 + 4i; 5+5i] +assert_checkfalse(norm(x - [1+%i; 2+2*%i; 3+3*%i; 4 + 4*%i; 5+5*%i]) < %eps); +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +Lup = umf_lufact(A); +[OK, nrow, ncol, lnz, unz, udiag_nz, it] = umf_luinfo(Lup); // OK must be %t, nrow=ncol = 5, +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), lnz); +assert_checkequal(nnz(U), unz); +umf_ludel(Lup); // clear memory +// this is the test matrix from UMFPACK +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +// must be a (quasi) nul matrix +assert_checkfalse(norm(B(p,q) - L*U) > %eps); +umf_ludel(Lup);// clear memory +// the same with a complex matrix +A = sparse( [ 2+%i 3+2*%i 0 0 0; +3-%i 0 4+%i 0 6-3*%i; +0 -1+%i -3+6*%i 2-%i 0; +0 0 1-5*%i 0 0; +0 4 2-%i 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +// must be a (quasi) nul matrix +assert_checkfalse(norm(B(p,q) - L*U) > %eps); +umf_ludel(Lup); // clear memory diff --git a/modules/umfpack/tests/unit_tests/umfpack.tst b/modules/umfpack/tests/unit_tests/umfpack.tst new file mode 100755 index 000000000..6f7a8adc3 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/umfpack.tst @@ -0,0 +1,107 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Bruno PINCON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +assert_checkfalse(execstr("umfpack()" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "umfpack", 3); +assert_checkerror("umfpack()", refMsg); + +assert_checkfalse(execstr("umfpack(speye(3,3), 2, 2)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"), "umfpack", 2); +assert_checkerror("umfpack(speye(3,3), 2, 2)", refMsg); + +assert_checkfalse(execstr("umfpack(1, ""\"", 2)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A sparse matrix expected.\n"), "umfpack", 1); +assert_checkerror("umfpack(1, ""\"", 2)", refMsg); + +assert_checkfalse(execstr("umfpack(speye(3,3), ""\"", %s)" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong type for input argument #%d: A matrix expected.\n"), "umfpack", 3); +assert_checkerror("umfpack(speye(3,3), ""\"", %s)", refMsg); + +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +b = [8 ; 45; -3; 3; 19]; +x = umfpack(A,"\",b); + +assert_checkalmostequal(x, [1 2 3 4 5]'); + +// test the other form x A = b +b = [8 20 13 6 17]; +x = umfpack(b,"/",A); // solution must be [1 2 3 4 5] + +assert_checkalmostequal(x, [1 2 3 4 5]); + +// test multiple rhs +b = rand(5,3); +x = umfpack(A,"\",b); + +assert_checkfalse(norm(A*x-b) < %eps); + +// test multiple rhs for x A = b +b = rand(3,5); +x = umfpack(b,"/",A); +assert_checkfalse(norm(x*A - b) > %eps); + +// solve a complex system +A = sparse( [ 2+%i 3+2*%i 0 0 0; +3-%i 0 4+%i 0 6-3*%i; +0 -1+%i -3+6*%i 2-%i 0; +0 0 1-5*%i 0 0; +0 4 2-%i 0 1] ); +b = [ 3+13*%i ; 58+32*%i ; -19+13*%i ; 18-12*%i ; 22+16*%i ]; +x = umfpack(A,"\",b); // x must be [1+i; 2+2i; 3+3i; 4 + 4i; 5+5i] + +assert_checkfalse(norm(x - [1+%i; 2+2*%i; 3+3*%i; 4 + 4*%i; 5+5*%i]) < %eps); + +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +Lup = umf_lufact(A); +[OK, nrow, ncol, lnz, unz, udiag_nz, it] = umf_luinfo(Lup); // OK must be %t, nrow=ncol = 5, +[L,U,p,q,R] = umf_luget(Lup); +assert_checkequal(nnz(L), lnz); +assert_checkequal(nnz(U), unz); + +umf_ludel(Lup); // clear memory + + + +// this is the test matrix from UMFPACK +A = sparse( [ 2 3 0 0 0; +3 0 4 0 6; +0 -1 -3 2 0; +0 0 1 0 0; +0 4 2 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +// must be a (quasi) nul matrix +assert_checkfalse(norm(B(p,q) - L*U) > %eps); +umf_ludel(Lup);// clear memory + + +// the same with a complex matrix +A = sparse( [ 2+%i 3+2*%i 0 0 0; +3-%i 0 4+%i 0 6-3*%i; +0 -1+%i -3+6*%i 2-%i 0; +0 0 1-5*%i 0 0; +0 4 2-%i 0 1] ); +Lup = umf_lufact(A); +[L,U,p,q,R] = umf_luget(Lup); +B = A; +for i=1:5, B(i,:) = B(i,:)/R(i); end // apply the row scaling +// must be a (quasi) nul matrix +assert_checkfalse(norm(B(p,q) - L*U) > %eps); + +umf_ludel(Lup); // clear memory diff --git a/modules/umfpack/tests/unit_tests/utm300.dia.ref b/modules/umfpack/tests/unit_tests/utm300.dia.ref new file mode 100755 index 000000000..c63512047 --- /dev/null +++ b/modules/umfpack/tests/unit_tests/utm300.dia.ref @@ -0,0 +1,90 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ +// <-- CLI SHELL MODE --> +// Check value provided here: +// http://math.nist.gov/MatrixMarket/data/SPARSKIT/tokamak/utm300.html +warning("off"); +[A, dsc]=ReadHBSparse(SCI+"/modules/umfpack/examples/utm300.rua"); +if dsc <> "utm300" then bugmes();quit;end +[nl,nc] = size(A) + nc = + + 300. + nl = + + 300. +if nl <> 300 then bugmes();quit;end +if nc <> 300 then bugmes();quit;end +if nnz(A) <> 3155 then bugmes();quit;end +// Diagonal +if nnz(diag(A)) <> 300 then bugmes();quit;end +// A-A' +if nnz(A-A') <> 4382 then bugmes();quit;end +// Heaviest diagonals +offsets = [ 0 -50 50 1 -1 -5 5 2 -2 -4 ]; +nonzerosExpected = [ 300 190 186 180 166 159 158 150 134 113 ]; +for j=1:length(offsets) + if nnz(diag(A, offsets(j))) <> nonzerosExpected(j) then bugmes();quit;end +end +// TODO add the rest of information +[ij]=spget(A); +e=ij(:,1)-ij(:,2); +// Bandwidths average |i-j| +m=ceil(mean(abs(e))); +if m <> 21 then bugmes();quit;end +// Bandwidths std.dev. +d=ceil(stdev(abs(e))); +if d <> 23 then bugmes();quit;end +lastinrow=[find(diff(ij(:,1))>0) size(ij,1)]; +rowlength=diff([0 lastinrow]); +// Row Data +[longest,indlongest]=max(rowlength); +if longest <> 33 then bugmes();quit;end +if indlongest <> 116 then bugmes();quit;end +[shortest,indshortest]=min(rowlength); +if shortest <> 1 then bugmes();quit;end +if indshortest <> 3 then bugmes();quit;end +// Average nonzeros per row +m=ceil(mean(rowlength)); +if m <> 11 then bugmes();quit;end +d=round(stdev(rowlength)*10)/10; +if d <> 7.7 then bugmes();quit;end +// Column Data +ji=gsort(ij(:,[2 1]),"lr","i"); +lastincol=[find(diff(ji(:,1))>0) size(ji,1)]; +collength=diff([0 lastincol]); +[longest,indlongest]=max(collength); +if longest <> 22 then bugmes();quit;end +if indlongest <> 59 then bugmes();quit;end +[shortest,indshortest]=min(collength); +if shortest <> 1 then bugmes();quit;end +if indshortest <> 16 then bugmes();quit;end +m=ceil(mean(collength)); +if m <> 11 then bugmes();quit;end +d=round(stdev(collength)*10)/10; +if d <> 7.1 then bugmes();quit;end +// Profile Storage +lastinrow=[find(diff(ij(:,1))>0) size(ij,1)]; +rowbounds= [ij([1 lastinrow(1:$-1)+1],2) ij(lastinrow,2)]; +rowindex=ij(lastinrow,1); +rowbandwidth=rowbounds-rowindex*ones(1,2); +lowband=[-rowbandwidth(find(rowbandwidth(:,1)<=0),1) +-rowbandwidth(find(rowbandwidth(:,2)<=0),2)]; +uppband=[rowbandwidth(find(rowbandwidth(:,1)>=0),1) +rowbandwidth(find(rowbandwidth(:,2)>=0),2)]; +// lower bandwidth => max +minlow=max(lowband); +if minlow <> 74 then bugmes();quit;end +// lower bandwidth => min +maxlow=min(lowband); +if maxlow <> 0 then bugmes();quit;end +// upper bandwidth => max +maxupp=max(uppband); +if maxupp <> 66 then bugmes();quit;end +// upper bandwidth => min +minupp=min(uppband); +if minupp <> 0 then bugmes();quit;end diff --git a/modules/umfpack/tests/unit_tests/utm300.tst b/modules/umfpack/tests/unit_tests/utm300.tst new file mode 100755 index 000000000..7b461057c --- /dev/null +++ b/modules/umfpack/tests/unit_tests/utm300.tst @@ -0,0 +1,112 @@ +// ============================================================================ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================ + +// <-- CLI SHELL MODE --> + +// Check value provided here: +// http://math.nist.gov/MatrixMarket/data/SPARSKIT/tokamak/utm300.html +warning("off"); + +[A, dsc]=ReadHBSparse(SCI+"/modules/umfpack/examples/utm300.rua"); +if dsc <> "utm300" then pause, end + +[nl,nc] = size(A) +if nl <> 300 then pause, end +if nc <> 300 then pause, end +if nnz(A) <> 3155 then pause, end + +// Diagonal +if nnz(diag(A)) <> 300 then pause, end + +// A-A' +if nnz(A-A') <> 4382 then pause, end + +// Heaviest diagonals +offsets = [ 0 -50 50 1 -1 -5 5 2 -2 -4 ]; +nonzerosExpected = [ 300 190 186 180 166 159 158 150 134 113 ]; + +for j=1:length(offsets) + if nnz(diag(A, offsets(j))) <> nonzerosExpected(j) then pause, end +end + +// TODO add the rest of information + +[ij]=spget(A); +e=ij(:,1)-ij(:,2); + +// Bandwidths average |i-j| +m=ceil(mean(abs(e))); +if m <> 21 then pause, end + +// Bandwidths std.dev. +d=ceil(stdev(abs(e))); +if d <> 23 then pause, end + +lastinrow=[find(diff(ij(:,1))>0) size(ij,1)]; +rowlength=diff([0 lastinrow]); + +// Row Data +[longest,indlongest]=max(rowlength); +if longest <> 33 then pause, end +if indlongest <> 116 then pause, end + +[shortest,indshortest]=min(rowlength); +if shortest <> 1 then pause, end +if indshortest <> 3 then pause, end + +// Average nonzeros per row +m=ceil(mean(rowlength)); +if m <> 11 then pause, end + +d=round(stdev(rowlength)*10)/10; +if d <> 7.7 then pause, end + +// Column Data +ji=gsort(ij(:,[2 1]),"lr","i"); +lastincol=[find(diff(ji(:,1))>0) size(ji,1)]; +collength=diff([0 lastincol]); + +[longest,indlongest]=max(collength); +if longest <> 22 then pause, end +if indlongest <> 59 then pause, end + +[shortest,indshortest]=min(collength); +if shortest <> 1 then pause, end +if indshortest <> 16 then pause, end + +m=ceil(mean(collength)); +if m <> 11 then pause, end + +d=round(stdev(collength)*10)/10; +if d <> 7.1 then pause, end + +// Profile Storage +lastinrow=[find(diff(ij(:,1))>0) size(ij,1)]; +rowbounds= [ij([1 lastinrow(1:$-1)+1],2) ij(lastinrow,2)]; +rowindex=ij(lastinrow,1); +rowbandwidth=rowbounds-rowindex*ones(1,2); +lowband=[-rowbandwidth(find(rowbandwidth(:,1)<=0),1) +-rowbandwidth(find(rowbandwidth(:,2)<=0),2)]; +uppband=[rowbandwidth(find(rowbandwidth(:,1)>=0),1) +rowbandwidth(find(rowbandwidth(:,2)>=0),2)]; + +// lower bandwidth => max +minlow=max(lowband); +if minlow <> 74 then pause, end + +// lower bandwidth => min +maxlow=min(lowband); +if maxlow <> 0 then pause, end + +// upper bandwidth => max +maxupp=max(uppband); +if maxupp <> 66 then pause, end + +// upper bandwidth => min +minupp=min(uppband); +if minupp <> 0 then pause, end + |