Navigation

Operators and Keywords

Function List:

C++ API

typecast.cc File Reference

#include "mx-base.h"
#include "defun-dld.h"
#include "error.h"
#include "gripes.h"
#include "oct-obj.h"
#include "unwind-prot.h"

Include dependency graph for typecast.cc:


Functions

 DEFUN_DLD (typecast, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} typecast (@var{x}, @var{class})\n\ Returns a new array @var{y} resulting from interpreting the data of\n\ @var{x} in memory as data of the numeric class @var{class}. Both the class\n\ of @var{x} and @var{class} must be one of the built-in numeric classes:\n\ \n\ @example\n\ \"logical\"\n\ \"char\"\n\ \"int8\"\n\ \"int16\"\n\ \"int32\"\n\ \"int64\"\n\ \"uint8\"\n\ \"uint16\"\n\ \"uint32\"\n\ \"uint64\"\n\ \"double\"\n\ \"single\"\n\ \"double complex\"\n\ \"single complex\"\n\ @end example\n\ \n\ the last two are reserved for @var{class}; they indicate that a complex-valued result\n\ is requested. Complex arrays are stored in memory as consecutive pairs of real numbers.\n\ The sizes of integer types are given by their bit counts. Both logical and char are typically\n\ one byte wide; however, this is not guaranteed by C++. If your system is IEEE conformant,\n\ single and double should be 4 bytes and 8 bytes wide, respectively.\n\ \"logical\" is not allowed for @var{class}.\n\ If the input is a row vector, the return value is a row vector, otherwise it is a column vector.\n\ If the bit length of @var{x} is not divisible by that of @var{class}, an error occurs.\n\ @seealso{bitunpack,bitpack}\n\ \n\ An example of the use of typecast on a little-endian machine is\n\ \n\ @example\n\ @group\n\ @var{x} = uint16 ([1, 65535]);\n\ typecast (@var{x}, 'uint8')\n\ @result{} [ 0, 1, 255, 255]\n\ @end group\n\ @end example\n\ @seealso{cast, swapbytes}\n\ @end deftypefn")
template<class ArrayType >
ArrayType do_bitpack (const boolNDArray &bitp)
 DEFUN_DLD (bitpack, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{y} =} bitpack (@var{x}, @var{class})\n\ Returns a new array @var{y} resulting from interpreting a logical array @var{x}\n\ as raw bit pattern for data of the numeric class @var{class}. @var{class} must be\n\ one of the built-in numeric classes:\n\ \n\ @example\n\ \"char\"\n\ \"int8\"\n\ \"int16\"\n\ \"int32\"\n\ \"int64\"\n\ \"uint8\"\n\ \"uint16\"\n\ \"uint32\"\n\ \"uint64\"\n\ \"double\"\n\ \"single\"\n\ @end example\n\ \n\ The number of elements of @var{x} should be divisible by the bit length of @var{class}.\n\ If it is not, excess bits are discarded. Bits come in increasing order of significance, i.e.\n\ @code{x(1)} is bit 0, @code{x(2)} is bit 1, etc.\n\ The result is a row vector if @var{x} is a row vector, otherwise it is a column vector.\n\ @seealso{bitunpack,typecast,bitget,bitset}\n\ @end deftypefn")
template<class ArrayType >
boolNDArray do_bitunpack (const ArrayType &array)
 DEFUN_DLD (bitunpack, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{y} =} bitpack (@var{x})\n\ Returns a logical array @var{y} corresponding to the raw bit pattern of @var{x}.\n\ @var{x} must belong to one of the built-in numeric classes:\n\ \n\ @example\n\ \"char\"\n\ \"int8\"\n\ \"int16\"\n\ \"int32\"\n\ \"int64\"\n\ \"uint8\"\n\ \"uint16\"\n\ \"uint32\"\n\ \"uint64\"\n\ \"double\"\n\ \"single\"\n\ @end example\n\ \n\ The result is a row vector if @var{x} is a row vector, otherwise it is a column vector.\n\ @seealso{bitpack,typecast,bitget,bitset}\n\ @end deftypefn")

Function Documentation

DEFUN_DLD ( bitunpack  ,
args   
)

DEFUN_DLD ( bitpack  ,
args   
)

DEFUN_DLD ( typecast  ,
args   
)

template<class ArrayType >
ArrayType do_bitpack ( const boolNDArray bitp  )  [inline]

template<class ArrayType >
boolNDArray do_bitunpack ( const ArrayType &  array  )  [inline]