#include "str-vec.h"
#include "quit.h"
#include "defun.h"
#include "error.h"
#include "ov.h"
#include "ov-uint64.h"
#include "ov-uint32.h"
#include "ov-uint16.h"
#include "ov-uint8.h"
#include "ov-int64.h"
#include "ov-int32.h"
#include "ov-int16.h"
#include "ov-int8.h"
#include "ov-scalar.h"
#include "ov-re-mat.h"
#include "ov-bool.h"
Go to the source code of this file.
Defines | |
#define | BITOP(OP, FNAME) |
#define | BITOPX(OP, FNAME, RET) |
#define | DO_BITSHIFT(T) |
#define | DO_SBITSHIFT(T, N) |
#define | DO_UBITSHIFT(T, N) |
Functions | |
static int64_t | bitshift (double a, int n, int64_t mask) |
static int64_t | bitshift (float a, int n, int64_t mask) |
DEFUN (intmin, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} intmin (@var{type})\n\ Return the smallest integer that can be represented in an integer type.\n\ The variable @var{type} can be\n\ \n\ @table @code\n\ @item int8\n\ signed 8-bit integer.\n\ \n\ @item int16\n\ signed 16-bit integer.\n\ \n\ @item int32\n\ signed 32-bit integer.\n\ \n\ @item int64\n\ signed 64-bit integer.\n\ \n\ @item uint8\n\ unsigned 8-bit integer.\n\ \n\ @item uint16\n\ unsigned 16-bit integer.\n\ \n\ @item uint32\n\ unsigned 32-bit integer.\n\ \n\ @item uint64\n\ unsigned 64-bit integer.\n\ @end table\n\ \n\ The default for @var{type} is @code{uint32}.\n\ @seealso{intmax, bitmax}\n\ @end deftypefn") | |
DEFUN (intmax, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} intmax (@var{type})\n\ Return the largest integer that can be represented in an integer type.\n\ The variable @var{type} can be\n\ \n\ @table @code\n\ @item int8\n\ signed 8-bit integer.\n\ \n\ @item int16\n\ signed 16-bit integer.\n\ \n\ @item int32\n\ signed 32-bit integer.\n\ \n\ @item int64\n\ signed 64-bit integer.\n\ \n\ @item uint8\n\ unsigned 8-bit integer.\n\ \n\ @item uint16\n\ unsigned 16-bit integer.\n\ \n\ @item uint32\n\ unsigned 32-bit integer.\n\ \n\ @item uint64\n\ unsigned 64-bit integer.\n\ @end table\n\ \n\ The default for @var{type} is @code{uint32}.\n\ @seealso{intmin, bitmax}\n\ @end deftypefn") | |
DEFUN (bitmax, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitmax ()\n\ @deftypefnx {Built-in Function} {} bitmax (\"double\")\n\ @deftypefnx {Built-in Function} {} bitmax (\"single\")\n\ Return the largest integer that can be represented within a floating point\n\ value. The default class is \"double\", but \"single\" is a valid option.\n\ On IEEE-754 compatible systems, @code{bitmax} is @w{@math{2^{53} - 1}}.\n\ @end deftypefn") | |
DEFUN (bitshift, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitshift (@var{a}, @var{k})\n\ @deftypefnx {Built-in Function} {} bitshift (@var{a}, @var{k}, @var{n})\n\ Return a @var{k} bit shift of @var{n}-digit unsigned\n\ integers in @var{a}. A positive @var{k} leads to a left shift;\n\ A negative value to a right shift. If @var{n} is omitted it defaults\n\ to log2(bitmax)+1.\n\ @var{n} must be in the range [1,log2(bitmax)+1] usually [1,33].\n\ \n\ @example\n\ @group\n\ bitshift (eye (3), 1)\n\ @result{}\n\ @group\n\ 2 0 0\n\ 0 2 0\n\ 0 0 2\n\ @end group\n\ \n\ bitshift (10, [-2, -1, 0, 1, 2])\n\ @result{} 2 5 10 20 40\n\ @c FIXME -- restore this example when third arg is allowed to be an array.\n\ @c\n\ @c\n\ @c bitshift ([1, 10], 2, [3,4])\n\ @c @result{} 4 8\n\ @end group\n\ @end example\n\ @seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, bitmax}\n\ @end deftypefn") | |
DEFUN (bitand, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitand (@var{x}, @var{y})\n\ Return the bitwise AND of non-negative integers.\n\ @var{x}, @var{y} must be in the range [0,bitmax]\n\ @seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\ @end deftypefn") | |
DEFUN (bitor, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitor (@var{x}, @var{y})\n\ Return the bitwise OR of non-negative integers.\n\ @var{x}, @var{y} must be in the range [0,bitmax]\n\ @seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\ @end deftypefn") | |
DEFUN (bitxor, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitxor (@var{x}, @var{y})\n\ Return the bitwise XOR of non-negative integers.\n\ @var{x}, @var{y} must be in the range [0,bitmax]\n\ @seealso{bitand, bitor, bitset, bitget, bitcmp, bitshift, bitmax}\n\ @end deftypefn") | |
DEFUN (sizemax, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} sizemax ()\n\ Return the largest value allowed for the size of an array.\n\ If Octave is compiled with 64-bit indexing, the result is of class int64,\n\ otherwise it is of class int32. The maximum array size is slightly\n\ smaller than the maximum value allowable for the relevant class as reported\n\ by @code{intmax}.\n\ @seealso{intmax}\n\ @end deftypefn") |
#define BITOP | ( | OP, | ||
FNAME | ||||
) |
Definition at line 82 of file bitfcns.cc.
Referenced by DEFUN().
#define BITOPX | ( | OP, | ||
FNAME, | ||||
RET | ||||
) |
Definition at line 48 of file bitfcns.cc.
#define DO_BITSHIFT | ( | T | ) |
Definition at line 331 of file bitfcns.cc.
Referenced by DEFUN().
#define DO_SBITSHIFT | ( | T, | ||
N | ||||
) |
do \ { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ mask = 0; \ mask = mask | octave_ ## T :: min (); /* FIXME: 2's complement only? */ \ DO_BITSHIFT (T); \ } \ while (0)
Definition at line 393 of file bitfcns.cc.
Referenced by DEFUN().
#define DO_UBITSHIFT | ( | T, | ||
N | ||||
) |
do \ { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ mask = 0; \ DO_BITSHIFT (T); \ } \ while (0)
Definition at line 379 of file bitfcns.cc.
Referenced by DEFUN().
Definition at line 298 of file bitfcns.cc.
Referenced by bitshift().
Definition at line 313 of file bitfcns.cc.
References bitshift().
DEFUN | ( | intmin | , | |
args | ||||
) |
Definition at line 617 of file bitfcns.cc.
References error(), min(), and print_usage().
DEFUN | ( | intmax | , | |
args | ||||
) |
Definition at line 547 of file bitfcns.cc.
References error(), max(), and print_usage().
DEFUN | ( | bitmax | , | |
args | ||||
) |
Definition at line 515 of file bitfcns.cc.
References error(), and print_usage().
DEFUN | ( | bitshift | , | |
args | ||||
) |
Definition at line 408 of file bitfcns.cc.
References octave_value::array_value(), octave_value::class_name(), DO_BITSHIFT, DO_SBITSHIFT, DO_UBITSHIFT, error(), error_state, and print_usage().
DEFUN | ( | bitand | , | |
args | ||||
) |
Definition at line 264 of file bitfcns.cc.
References BITOP.
DEFUN | ( | bitor | , | |
args | ||||
) |
Definition at line 275 of file bitfcns.cc.
References BITOP.
DEFUN | ( | bitxor | , | |
args | ||||
) |
Definition at line 286 of file bitfcns.cc.
References BITOP.
DEFUN | ( | sizemax | , | |
args | ||||
) |
Definition at line 687 of file bitfcns.cc.
References dim_vector::dim_max(), and print_usage().