sizeof

PURPOSE ^

SIZEOF Get the size in bytes for an element of the specified type

SYNOPSIS ^

function sz = sizeof( type )

DESCRIPTION ^

SIZEOF Get the size in bytes for an element of the specified type

   bytes = gpubench.sizeof(typename) returns the number of bytes required
   for a single real value of the specified type.

   Examples:
   >> gpubench.sizeof('double')
   ans = 8
   >> gpubench.sizeof('single')
   ans = 4

   See also: gpuBench

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sz = sizeof( type )
0002 %SIZEOF Get the size in bytes for an element of the specified type
0003 %
0004 %   bytes = gpubench.sizeof(typename) returns the number of bytes required
0005 %   for a single real value of the specified type.
0006 %
0007 %   Examples:
0008 %   >> gpubench.sizeof('double')
0009 %   ans = 8
0010 %   >> gpubench.sizeof('single')
0011 %   ans = 4
0012 %
0013 %   See also: gpuBench
0014 
0015 %   Copyright 2011 The MathWorks, Inc.
0016 
0017 switch upper(type)
0018     case {'INT8','UINT8','LOGICAL'}
0019         sz = 1;
0020     case {'INT16','UINT16'}
0021         sz = 2;
0022     case {'INT32','UINT32'}
0023         sz = 4;
0024     case {'INT64','UINT64'}
0025         sz = 8;
0026     case 'SINGLE'
0027         sz = 4;
0028     case 'DOUBLE'
0029         sz = 8;
0030     otherwise
0031         error( 'SizeOf:BadType', 'Unknown type ''%s''.', type );
0032 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.