function y = reinterpretcast(u,T)
%REINTERPRETCAST Convert fixed-point data types without changing underlying data
%
%    MATLAB Code Generation Library function.
%
%    See also embedded.fi/reinterpretcast

%   Copyright 2008-2014 The MathWorks, Inc.
%#codegen

% This is a helper function for code generation to know how to propagate
% sizes before it has resolved that the input is a fi object and should
% call fi's method in toolbox/eml/lib/fixedpoint/@embedded/@fi.
if eml_ambiguous_types
    y = coder.ignoreConst(zeros(size(u)));
elseif isinteger(u)
    switch class(u)
      case 'int8'
        temp = fi(u,1,8,0);
      case 'int16'
        temp = fi(u,1,16,0);
      case 'int32'
        temp = fi(u,1,32,0);
      case 'int64'
        temp = fi(u,1,64,0);
      case 'uint8'
        temp = fi(u,0,8,0);
      case 'uint16'
        temp = fi(u,0,16,0);
      case 'uint32'
        temp = fi(u,0,32,0);
      case 'uint64'
        temp = fi(u,0,64,0);
      otherwise
        eml_invariant(false, 'fixed:bitsxx:invalidDataType','reinterpretcast',class(u));
    end
    y = reinterpretcast(temp, T);
else
    eml_invariant(false, 'fixed:bitsxx:invalidDataType','reinterpretcast',class(u));
end
