106 lines
3.4 KiB
JavaScript
106 lines
3.4 KiB
JavaScript
import { bitAndBigNumber } from '../../utils/bignumber/bitwise.js';
|
|
import { createAlgorithm02 } from '../../type/matrix/utils/algorithm02.js';
|
|
import { createAlgorithm11 } from '../../type/matrix/utils/algorithm11.js';
|
|
import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13.js';
|
|
import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14.js';
|
|
import { createAlgorithm06 } from '../../type/matrix/utils/algorithm06.js';
|
|
import { factory } from '../../utils/factory.js';
|
|
import { bitAndNumber } from '../../plain/number/index.js';
|
|
var name = 'bitAnd';
|
|
var dependencies = ['typed', 'matrix', 'equalScalar'];
|
|
export var createBitAnd = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
var {
|
|
typed,
|
|
matrix,
|
|
equalScalar
|
|
} = _ref;
|
|
var algorithm02 = createAlgorithm02({
|
|
typed,
|
|
equalScalar
|
|
});
|
|
var algorithm06 = createAlgorithm06({
|
|
typed,
|
|
equalScalar
|
|
});
|
|
var algorithm11 = createAlgorithm11({
|
|
typed,
|
|
equalScalar
|
|
});
|
|
var algorithm13 = createAlgorithm13({
|
|
typed
|
|
});
|
|
var algorithm14 = createAlgorithm14({
|
|
typed
|
|
});
|
|
/**
|
|
* Bitwise AND two values, `x & y`.
|
|
* For matrices, the function is evaluated element wise.
|
|
*
|
|
* Syntax:
|
|
*
|
|
* math.bitAnd(x, y)
|
|
*
|
|
* Examples:
|
|
*
|
|
* math.bitAnd(53, 131) // returns number 1
|
|
*
|
|
* math.bitAnd([1, 12, 31], 42) // returns Array [0, 8, 10]
|
|
*
|
|
* See also:
|
|
*
|
|
* bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift
|
|
*
|
|
* @param {number | BigNumber | Array | Matrix} x First value to and
|
|
* @param {number | BigNumber | Array | Matrix} y Second value to and
|
|
* @return {number | BigNumber | Array | Matrix} AND of `x` and `y`
|
|
*/
|
|
|
|
return typed(name, {
|
|
'number, number': bitAndNumber,
|
|
'BigNumber, BigNumber': bitAndBigNumber,
|
|
'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
|
|
return algorithm06(x, y, this, false);
|
|
},
|
|
'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
|
|
return algorithm02(y, x, this, true);
|
|
},
|
|
'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
|
|
return algorithm02(x, y, this, false);
|
|
},
|
|
'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
|
|
return algorithm13(x, y, this);
|
|
},
|
|
'Array, Array': function ArrayArray(x, y) {
|
|
// use matrix implementation
|
|
return this(matrix(x), matrix(y)).valueOf();
|
|
},
|
|
'Array, Matrix': function ArrayMatrix(x, y) {
|
|
// use matrix implementation
|
|
return this(matrix(x), y);
|
|
},
|
|
'Matrix, Array': function MatrixArray(x, y) {
|
|
// use matrix implementation
|
|
return this(x, matrix(y));
|
|
},
|
|
'SparseMatrix, any': function SparseMatrixAny(x, y) {
|
|
return algorithm11(x, y, this, false);
|
|
},
|
|
'DenseMatrix, any': function DenseMatrixAny(x, y) {
|
|
return algorithm14(x, y, this, false);
|
|
},
|
|
'any, SparseMatrix': function anySparseMatrix(x, y) {
|
|
return algorithm11(y, x, this, true);
|
|
},
|
|
'any, DenseMatrix': function anyDenseMatrix(x, y) {
|
|
return algorithm14(y, x, this, true);
|
|
},
|
|
'Array, any': function ArrayAny(x, y) {
|
|
// use matrix implementation
|
|
return algorithm14(matrix(x), y, this, false).valueOf();
|
|
},
|
|
'any, Array': function anyArray(x, y) {
|
|
// use matrix implementation
|
|
return algorithm14(matrix(y), x, this, true).valueOf();
|
|
}
|
|
});
|
|
}); |