From: Cedric Delamarre Date: Mon, 20 May 2013 08:13:06 +0000 (+0200) Subject: management of hypermatrix in repmat. X-Git-Tag: 6.0.0-alpha-1~1765 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=68d998586a1bed8079ad69043a7eaa1b767fbd3b management of hypermatrix in repmat. test_run("elementary_functions","bug_12045",["no_check_error_output"]); Change-Id: If684fde00218ab41c9df4900131a5dab18cd9b3c --- diff --git a/scilab/modules/elementary_functions/macros/repmat.sci b/scilab/modules/elementary_functions/macros/repmat.sci index 50fb250..295f44e 100644 --- a/scilab/modules/elementary_functions/macros/repmat.sci +++ b/scilab/modules/elementary_functions/macros/repmat.sci @@ -38,7 +38,7 @@ function B = repmat(A,varargin) if typeof(A)=="rational" then B=rlist(repmat(A.num,varargin(:)),repmat(A.den,varargin(:)),A.dt) return - elseif typeof(A)<>"hypermat" then + else execstr('B=%'+typeof(A)+"_repmat(A,varargin(:))") return end @@ -99,7 +99,7 @@ function B = repmat(A,varargin) I(i)=ind; end - if typeof(A) == 'hypermat' | (size(varargin(1),"*") <> 1 & size(varargin(1)) <3) then // Works if A is hypermat but not for int8,int16 matrix + if nda > 2 | (size(varargin(1),"*") <> 1 & size(varargin(1)) <3) then // Works if A is hypermat but not for int8,int16 matrix B=A(I(:)); else // Works for int8, int16... matrix but not for hypermat if rhs ==2 then @@ -113,7 +113,7 @@ function B = repmat(A,varargin) for i=1:size(varargin(1),2) varargin(i)=varargin_temp(1)(i); end - else + else error(msprintf(_("%s: Wrong size for input argument #%d: a vector expected.\n"),"repmat",2)); end end @@ -146,7 +146,7 @@ function B = repmat(A,varargin) end J=J'; A_final=A_base(J); - B=mlist(["hm", "dims", "entries"], matrix(dims,1,-1), matrix(A_final,-1,1)); + B=matrix(A_final, dims); end end end diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.dia.ref index e0a4cc5..3b0c58d 100644 --- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.dia.ref +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.dia.ref @@ -22,9 +22,9 @@ A_int16=int16(A); A_uint16=uint16(A); A_int32=int32(A); A_uint32=uint32(A); -assert_checkequal(repmat(A_int8,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint8,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_int16,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint16,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_int32,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint32,1,1,2),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int8,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint8,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int16,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint16,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int32,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint32,1,1,2)),repmat(A,1,1,2)); diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.tst index 8fd154a..27e1a8f 100644 --- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.tst +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.tst @@ -24,9 +24,9 @@ A_uint16=uint16(A); A_int32=int32(A); A_uint32=uint32(A); -assert_checkequal(repmat(A_int8,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint8,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_int16,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint16,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_int32,1,1,2),repmat(A,1,1,2)); -assert_checkequal(repmat(A_uint32,1,1,2),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int8,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint8,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int16,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint16,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_int32,1,1,2)),repmat(A,1,1,2)); +assert_checkequal(double(repmat(A_uint32,1,1,2)),repmat(A,1,1,2));