simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

bitAnd.js (3802B)


      1 "use strict";
      2 
      3 Object.defineProperty(exports, "__esModule", {
      4   value: true
      5 });
      6 exports.createBitAnd = void 0;
      7 
      8 var _bitwise = require("../../utils/bignumber/bitwise.js");
      9 
     10 var _algorithm = require("../../type/matrix/utils/algorithm02.js");
     11 
     12 var _algorithm2 = require("../../type/matrix/utils/algorithm11.js");
     13 
     14 var _algorithm3 = require("../../type/matrix/utils/algorithm13.js");
     15 
     16 var _algorithm4 = require("../../type/matrix/utils/algorithm14.js");
     17 
     18 var _algorithm5 = require("../../type/matrix/utils/algorithm06.js");
     19 
     20 var _factory = require("../../utils/factory.js");
     21 
     22 var _index = require("../../plain/number/index.js");
     23 
     24 var name = 'bitAnd';
     25 var dependencies = ['typed', 'matrix', 'equalScalar'];
     26 var createBitAnd = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
     27   var typed = _ref.typed,
     28       matrix = _ref.matrix,
     29       equalScalar = _ref.equalScalar;
     30   var algorithm02 = (0, _algorithm.createAlgorithm02)({
     31     typed: typed,
     32     equalScalar: equalScalar
     33   });
     34   var algorithm06 = (0, _algorithm5.createAlgorithm06)({
     35     typed: typed,
     36     equalScalar: equalScalar
     37   });
     38   var algorithm11 = (0, _algorithm2.createAlgorithm11)({
     39     typed: typed,
     40     equalScalar: equalScalar
     41   });
     42   var algorithm13 = (0, _algorithm3.createAlgorithm13)({
     43     typed: typed
     44   });
     45   var algorithm14 = (0, _algorithm4.createAlgorithm14)({
     46     typed: typed
     47   });
     48   /**
     49    * Bitwise AND two values, `x & y`.
     50    * For matrices, the function is evaluated element wise.
     51    *
     52    * Syntax:
     53    *
     54    *    math.bitAnd(x, y)
     55    *
     56    * Examples:
     57    *
     58    *    math.bitAnd(53, 131)               // returns number 1
     59    *
     60    *    math.bitAnd([1, 12, 31], 42)       // returns Array [0, 8, 10]
     61    *
     62    * See also:
     63    *
     64    *    bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
     65    *
     66    * @param  {number | BigNumber | Array | Matrix} x First value to and
     67    * @param  {number | BigNumber | Array | Matrix} y Second value to and
     68    * @return {number | BigNumber | Array | Matrix} AND of `x` and `y`
     69    */
     70 
     71   return typed(name, {
     72     'number, number': _index.bitAndNumber,
     73     'BigNumber, BigNumber': _bitwise.bitAndBigNumber,
     74     'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
     75       return algorithm06(x, y, this, false);
     76     },
     77     'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
     78       return algorithm02(y, x, this, true);
     79     },
     80     'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
     81       return algorithm02(x, y, this, false);
     82     },
     83     'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
     84       return algorithm13(x, y, this);
     85     },
     86     'Array, Array': function ArrayArray(x, y) {
     87       // use matrix implementation
     88       return this(matrix(x), matrix(y)).valueOf();
     89     },
     90     'Array, Matrix': function ArrayMatrix(x, y) {
     91       // use matrix implementation
     92       return this(matrix(x), y);
     93     },
     94     'Matrix, Array': function MatrixArray(x, y) {
     95       // use matrix implementation
     96       return this(x, matrix(y));
     97     },
     98     'SparseMatrix, any': function SparseMatrixAny(x, y) {
     99       return algorithm11(x, y, this, false);
    100     },
    101     'DenseMatrix, any': function DenseMatrixAny(x, y) {
    102       return algorithm14(x, y, this, false);
    103     },
    104     'any, SparseMatrix': function anySparseMatrix(x, y) {
    105       return algorithm11(y, x, this, true);
    106     },
    107     'any, DenseMatrix': function anyDenseMatrix(x, y) {
    108       return algorithm14(y, x, this, true);
    109     },
    110     'Array, any': function ArrayAny(x, y) {
    111       // use matrix implementation
    112       return algorithm14(matrix(x), y, this, false).valueOf();
    113     },
    114     'any, Array': function anyArray(x, y) {
    115       // use matrix implementation
    116       return algorithm14(matrix(y), x, this, true).valueOf();
    117     }
    118   });
    119 });
    120 exports.createBitAnd = createBitAnd;