Help with kron compatibility

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with kron compatibility

Rik-4
Could someone with access to Matlab run the following code?

x = kron(uint8[2 3;4 5], ones(2,2,'uint8'));
class (x)
y = kron(uint8[2 3;4 5], ones(2,2,'int16'))
class (y)

I'm trying to check bug #46316 and whether kron changes all inputs to
doubles for computation.

--Rik

Reply | Threaded
Open this post in threaded view
|

Re: Help with kron compatibility

Alois Schloegl-7
On 2018-08-06 20:50, Rik wrote:
> x = kron(uint8[2 3;4 5], ones(2,2,'uint8'));
> class (x)
> y = kron(uint8[2 3;4 5], ones(2,2,'int16'))
> class (y)


Dear Rik ,


It seems there are some paranthesis missing, I guess you meant

...uint8([2 3;4 5])...

I checked  R2018a, R2016b, R2013a, and the results are:

----------------


>> version

ans =

    '9.4.0.813654 (R2018a)'

>> x = kron(uint8([2 3;4 5]), ones(2,2,'uint8'));
>> class (x)

ans =

    'uint8'

>> y = kron(uint8([2 3;4 5]), ones(2,2,'int16'))
Error using .*
Integers can only be combined with integers of the same class, or scalar
doubles.

Error in kron (line 34)
   K = reshape(A.*B,[ma*mb na*nb]);
 
>> class (y)
Undefined function or variable 'y'.
 


----------------


>> version

ans =

9.1.0.441655 (R2016b)

>> x = kron(uint8([2 3;4 5]), ones(2,2,'uint8'));
>> class (x)

ans =

uint8

>> y = kron(uint8([2 3;4 5]), ones(2,2,'int16'))
Error using .*
Integers can only be combined with integers of the same class, or scalar
doubles.

Error in kron (line 34)
   K = reshape(A.*B,[ma*mb na*nb]);

>> class (y)
Undefined function or variable 'y'.



----------------

>> version

ans =

8.1.0.604 (R2013a)

>> x = kron(uint8([2 3;4 5]), ones(2,2,'uint8'));
>> class (x)

ans =

uint8

>> y = kron(uint8([2 3;4 5]), ones(2,2,'int16'))
Error using .*
Integers can only be combined with integers of the same class, or scalar
doubles.

Error in kron (line 34)
   K = A(ia,ja).*B(ib,jb);
 
>> class (y)
Undefined function or variable 'y'.



Reply | Threaded
Open this post in threaded view
|

Re: Help with kron compatibility

Rik-4
On 08/06/2018 12:35 PM, Alois Schloegl wrote:

> On 2018-08-06 20:50, Rik wrote:
>> x = kron(uint8[2 3;4 5], ones(2,2,'uint8'));
>> class (x)
>> y = kron(uint8[2 3;4 5], ones(2,2,'int16'))
>> class (y)
>
> Dear Rik ,
>
>
> It seems there are some paranthesis missing, I guess you meant
>
> ...uint8([2 3;4 5])...

Oops, I was in a hurry and should have checked the code more carefully. 
But yes, that was what I intended.  It seems like kron does preserve the
class of the input in the output.  If that is the case then mixed floating
point, integer cases probably result in an integer output.  Could you try
this last test?

x = kron (uint8 ([2 3;4 5]), ones(2,2));
class (x)

I suspect it will be uint8 rather than double.

--Rik