From ad8236ca5e2af3a06d1e8ae079788fd4b88ac6bc Mon Sep 17 00:00:00 2001 From: Charlotte HECQUET Date: Wed, 25 Sep 2013 18:06:22 +0200 Subject: [PATCH] * Bug #11996 fixed - Extend eye() to hypermatrix. Change-Id: I7bd0f8a011529411b5f3b133caa3c8a51ce61c2e --- scilab/CHANGES_5.5.X | 2 ++ .../sci_gateway/fortran/sci_f_eye.f | 3 ++- scilab/modules/overloading/macros/%hm_eye.sci | 21 ++++++++++++++++++++ .../tests/nonreg_tests/bug_11996.dia.ref | 18 +++++++++++++++++ .../overloading/tests/nonreg_tests/bug_11996.tst | 20 +++++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 scilab/modules/overloading/macros/%hm_eye.sci create mode 100644 scilab/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref create mode 100644 scilab/modules/overloading/tests/nonreg_tests/bug_11996.tst diff --git a/scilab/CHANGES_5.5.X b/scilab/CHANGES_5.5.X index 54037e8..7c73e18 100644 --- a/scilab/CHANGES_5.5.X +++ b/scilab/CHANGES_5.5.X @@ -137,6 +137,8 @@ Scilab Bug Fixes * Bug #11680 fixed - GUI functions in Scilab 5.4.X were much slower than in Scilab 5.3.3. +* Bug #11996 fixed - eye extended to hypermatrix. + * Bug #12334 fixed - Mark color in legend was invalid. * Bug #12485 fixed - xchange returned bad values with log scale. diff --git a/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_eye.f b/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_eye.f index 0e939e8..0520870 100644 --- a/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_eye.f +++ b/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_eye.f @@ -24,7 +24,8 @@ c return endif if(rhs.gt.2) then - call error(42) + call setfunnam(ids(1,pt+1),'%hm_eye',7) + fun=-1 return endif diff --git a/scilab/modules/overloading/macros/%hm_eye.sci b/scilab/modules/overloading/macros/%hm_eye.sci new file mode 100644 index 0000000..9dcb1bd --- /dev/null +++ b/scilab/modules/overloading/macros/%hm_eye.sci @@ -0,0 +1,21 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +function M=%hm_eye(varargin) + nv=size(varargin); + for k=1:nv + if (type(varargin(k)) <> 1 & type(varargin(k)) <> 8) | size(varargin(k), "*") <> 1 then + error(msprintf(_("%s: Wrong type for input argument #%d: An integer value expected.\n"), "eye", k)) + end + dims(k)=int(varargin(k)); + end + + A=[1, dims(3:$)']; + M = matrix(repmat(eye(dims(1), dims(2)), A), dims); +endfunction diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref b/scilab/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref new file mode 100644 index 0000000..1c53fa7 --- /dev/null +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- Non-regression test for bug 11996 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11996 +// +// <-- Short Description --> +// Extend eye() to hypermatrix +ref(:,:,1,1) = eye(6,6); +ref(:,:,2,2) = eye(6,6); +ref(:,:,2,1) = eye(6,6); +ref(:,:,1,2) = eye(6,6); +assert_checkequal(eye(6,6,2,2), ref); diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_11996.tst b/scilab/modules/overloading/tests/nonreg_tests/bug_11996.tst new file mode 100644 index 0000000..f3b26cc --- /dev/null +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_11996.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- Non-regression test for bug 11996 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11996 +// +// <-- Short Description --> +// Extend eye() to hypermatrix + +ref(:,:,1,1) = eye(6,6); +ref(:,:,2,2) = eye(6,6); +ref(:,:,2,1) = eye(6,6); +ref(:,:,1,2) = eye(6,6); +assert_checkequal(eye(6,6,2,2), ref); -- 1.7.9.5