management of hypermatrix in repmat. 49/11549/2
Cedric Delamarre [Mon, 20 May 2013 08:13:06 +0000 (10:13 +0200)]
test_run("elementary_functions","bug_12045",["no_check_error_output"]);

Change-Id: If684fde00218ab41c9df4900131a5dab18cd9b3c

scilab/modules/elementary_functions/macros/repmat.sci
scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.dia.ref
scilab/modules/elementary_functions/tests/nonreg_tests/bug_12045.tst

index 50fb250..295f44e 100644 (file)
@@ -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
index e0a4cc5..3b0c58d 100644 (file)
@@ -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));
index 8fd154a..27e1a8f 100644 (file)
@@ -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));