1 | 'use strict'
|
2 |
|
3 | const isInteger = require('../../utils/number').isInteger
|
4 | const bigBitOr = require('../../utils/bignumber/bitOr')
|
5 |
|
6 | function factory (type, config, load, typed) {
|
7 | const latex = require('../../utils/latex')
|
8 |
|
9 | const matrix = load(require('../../type/matrix/function/matrix'))
|
10 |
|
11 | const algorithm01 = load(require('../../type/matrix/utils/algorithm01'))
|
12 | const algorithm04 = load(require('../../type/matrix/utils/algorithm04'))
|
13 | const algorithm10 = load(require('../../type/matrix/utils/algorithm10'))
|
14 | const algorithm13 = load(require('../../type/matrix/utils/algorithm13'))
|
15 | const algorithm14 = load(require('../../type/matrix/utils/algorithm14'))
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | const bitOr = typed('bitOr', {
|
41 |
|
42 | 'number, number': function (x, y) {
|
43 | if (!isInteger(x) || !isInteger(y)) {
|
44 | throw new Error('Integers expected in function bitOr')
|
45 | }
|
46 |
|
47 | return x | y
|
48 | },
|
49 |
|
50 | 'BigNumber, BigNumber': bigBitOr,
|
51 |
|
52 | 'SparseMatrix, SparseMatrix': function (x, y) {
|
53 | return algorithm04(x, y, bitOr)
|
54 | },
|
55 |
|
56 | 'SparseMatrix, DenseMatrix': function (x, y) {
|
57 | return algorithm01(y, x, bitOr, true)
|
58 | },
|
59 |
|
60 | 'DenseMatrix, SparseMatrix': function (x, y) {
|
61 | return algorithm01(x, y, bitOr, false)
|
62 | },
|
63 |
|
64 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
65 | return algorithm13(x, y, bitOr)
|
66 | },
|
67 |
|
68 | 'Array, Array': function (x, y) {
|
69 |
|
70 | return bitOr(matrix(x), matrix(y)).valueOf()
|
71 | },
|
72 |
|
73 | 'Array, Matrix': function (x, y) {
|
74 |
|
75 | return bitOr(matrix(x), y)
|
76 | },
|
77 |
|
78 | 'Matrix, Array': function (x, y) {
|
79 |
|
80 | return bitOr(x, matrix(y))
|
81 | },
|
82 |
|
83 | 'SparseMatrix, any': function (x, y) {
|
84 | return algorithm10(x, y, bitOr, false)
|
85 | },
|
86 |
|
87 | 'DenseMatrix, any': function (x, y) {
|
88 | return algorithm14(x, y, bitOr, false)
|
89 | },
|
90 |
|
91 | 'any, SparseMatrix': function (x, y) {
|
92 | return algorithm10(y, x, bitOr, true)
|
93 | },
|
94 |
|
95 | 'any, DenseMatrix': function (x, y) {
|
96 | return algorithm14(y, x, bitOr, true)
|
97 | },
|
98 |
|
99 | 'Array, any': function (x, y) {
|
100 |
|
101 | return algorithm14(matrix(x), y, bitOr, false).valueOf()
|
102 | },
|
103 |
|
104 | 'any, Array': function (x, y) {
|
105 |
|
106 | return algorithm14(matrix(y), x, bitOr, true).valueOf()
|
107 | }
|
108 | })
|
109 |
|
110 | bitOr.toTex = {
|
111 | 2: `\\left(\${args[0]}${latex.operators['bitOr']}\${args[1]}\\right)`
|
112 | }
|
113 |
|
114 | return bitOr
|
115 | }
|
116 |
|
117 | exports.name = 'bitOr'
|
118 | exports.factory = factory
|