0001 function dt = datatypes
0002
0003
0004
0005
0006
0007
0008
0009
0010 persistent dtype
0011 if isempty(dtype),
0012 t = true;
0013 f = false;
0014 table = {...
0015 0 ,'UNKNOWN' ,'uint8' ,@uint8 ,1,1 ,t,t,f
0016 1 ,'BINARY' ,'uint1' ,@logical,1,1/8,t,t,f
0017 256 ,'INT8' ,'int8' ,@int8 ,1,1 ,t,f,t
0018 2 ,'UINT8' ,'uint8' ,@uint8 ,1,1 ,t,t,t
0019 4 ,'INT16' ,'int16' ,@int16 ,1,2 ,t,f,t
0020 512 ,'UINT16' ,'uint16' ,@uint16 ,1,2 ,t,t,t
0021 8 ,'INT32' ,'int32' ,@int32 ,1,4 ,t,f,t
0022 768 ,'UINT32' ,'uint32' ,@uint32 ,1,4 ,t,t,t
0023 1024,'INT64' ,'int64' ,@int64 ,1,8 ,t,f,f
0024 1280,'UINT64' ,'uint64' ,@uint64 ,1,8 ,t,t,f
0025 16 ,'FLOAT32' ,'float32' ,@single ,1,4 ,f,f,t
0026 64 ,'FLOAT64' ,'double' ,@double ,1,8 ,f,f,t
0027 1536,'FLOAT128' ,'float128',@crash ,1,16 ,f,f,f
0028 32 ,'COMPLEX64' ,'float32' ,@single ,2,4 ,f,f,f
0029 1792,'COMPLEX128','double' ,@double ,2,8 ,f,f,f
0030 2048,'COMPLEX256','float128',@crash ,2,16 ,f,f,f
0031 128 ,'RGB24' ,'uint8' ,@uint8 ,3,1 ,t,t,f};
0032 dtype = struct(...
0033 'code' ,table(:,1),...
0034 'label' ,table(:,2),...
0035 'prec' ,table(:,3),...
0036 'conv' ,table(:,4),...
0037 'nelem' ,table(:,5),...
0038 'size' ,table(:,6),...
0039 'isint' ,table(:,7),...
0040 'unsigned' ,table(:,8),...
0041 'min',-Inf,'max',Inf',...
0042 'supported',table(:,9));
0043 for i=1:length(dtype),
0044 if dtype(i).isint
0045 if dtype(i).unsigned
0046 dtype(i).min = 0;
0047 dtype(i).max = 2^(8*dtype(i).size)-1;
0048 else
0049 dtype(i).min = -2^(8*dtype(i).size-1);
0050 dtype(i).max = 2^(8*dtype(i).size-1)-1;
0051 end;
0052 end;
0053 end;
0054 end;
0055
0056 dt = dtype;