FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/src/function/logical/and.js at develop · rvramesh/mathjs · GitHub
rvramesh
/
mathjs
Public
forked from
josdejong/mathjs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mathjs
/
src
/
function
/
logical
/
and.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
146 lines (126 loc) · 4 KB
Breadcrumbs
mathjs
/
src
/
function
/
logical
/
and.js
Copy path
File metadata and controls
146 lines (126 loc) · 4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
{
andNumber
}
from
'../../plain/number/index.js'
const
name
=
'and'
const
dependencies
=
[
'typed'
,
'matrix'
,
'equalScalar'
,
'zeros'
,
'not'
]
export
const
createAnd
=
/* #__PURE__ */
factory
(
name
,
dependencies
,
(
{
typed
,
matrix
,
equalScalar
,
zeros
,
not
}
)
=>
{
const
algorithm02
=
createAlgorithm02
(
{
typed
,
equalScalar
}
)
const
algorithm06
=
createAlgorithm06
(
{
typed
,
equalScalar
}
)
const
algorithm11
=
createAlgorithm11
(
{
typed
,
equalScalar
}
)
const
algorithm13
=
createAlgorithm13
(
{
typed
}
)
const
algorithm14
=
createAlgorithm14
(
{
typed
}
)
/**
* Logical `and`. Test whether two values are both defined with a nonzero/nonempty value.
* For matrices, the function is evaluated element wise.
*
* Syntax:
*
* math.and(x, y)
*
* Examples:
*
* math.and(2, 4) // returns true
*
* a = [2, 0, 0]
* b = [3, 7, 0]
* c = 0
*
* math.and(a, b) // returns [true, false, false]
* math.and(a, c) // returns [false, false, false]
*
* See also:
*
* not, or, xor
*
*
@param
{
number | BigNumber | Complex | Unit | Array | Matrix
} x First value to check
*
@param
{
number | BigNumber | Complex | Unit | Array | Matrix
} y Second value to check
*
@return
{
boolean | Array | Matrix
}
* Returns true when both inputs are defined with a nonzero/nonempty value.
*/
return
typed
(
name
,
{
'number, number'
:
andNumber
,
'Complex, Complex'
:
function
(
x
,
y
)
{
return
(
x
.
re
!==
0
||
x
.
im
!==
0
)
&&
(
y
.
re
!==
0
||
y
.
im
!==
0
)
}
,
'BigNumber, BigNumber'
:
function
(
x
,
y
)
{
return
!
x
.
isZero
(
)
&&
!
y
.
isZero
(
)
&&
!
x
.
isNaN
(
)
&&
!
y
.
isNaN
(
)
}
,
'Unit, Unit'
:
function
(
x
,
y
)
{
return
this
(
x
.
value
||
0
,
y
.
value
||
0
)
}
,
'SparseMatrix, SparseMatrix'
:
function
(
x
,
y
)
{
return
algorithm06
(
x
,
y
,
this
,
false
)
}
,
'SparseMatrix, DenseMatrix'
:
function
(
x
,
y
)
{
return
algorithm02
(
y
,
x
,
this
,
true
)
}
,
'DenseMatrix, SparseMatrix'
:
function
(
x
,
y
)
{
return
algorithm02
(
x
,
y
,
this
,
false
)
}
,
'DenseMatrix, DenseMatrix'
:
function
(
x
,
y
)
{
return
algorithm13
(
x
,
y
,
this
)
}
,
'Array, Array'
:
function
(
x
,
y
)
{
// use matrix implementation
return
this
(
matrix
(
x
)
,
matrix
(
y
)
)
.
valueOf
(
)
}
,
'Array, Matrix'
:
function
(
x
,
y
)
{
// use matrix implementation
return
this
(
matrix
(
x
)
,
y
)
}
,
'Matrix, Array'
:
function
(
x
,
y
)
{
// use matrix implementation
return
this
(
x
,
matrix
(
y
)
)
}
,
'SparseMatrix, any'
:
function
(
x
,
y
)
{
// check scalar
if
(
not
(
y
)
)
{
// return zero matrix
return
zeros
(
x
.
size
(
)
,
x
.
storage
(
)
)
}
return
algorithm11
(
x
,
y
,
this
,
false
)
}
,
'DenseMatrix, any'
:
function
(
x
,
y
)
{
// check scalar
if
(
not
(
y
)
)
{
// return zero matrix
return
zeros
(
x
.
size
(
)
,
x
.
storage
(
)
)
}
return
algorithm14
(
x
,
y
,
this
,
false
)
}
,
'any, SparseMatrix'
:
function
(
x
,
y
)
{
// check scalar
if
(
not
(
x
)
)
{
// return zero matrix
return
zeros
(
x
.
size
(
)
,
x
.
storage
(
)
)
}
return
algorithm11
(
y
,
x
,
this
,
true
)
}
,
'any, DenseMatrix'
:
function
(
x
,
y
)
{
// check scalar
if
(
not
(
x
)
)
{
// return zero matrix
return
zeros
(
x
.
size
(
)
,
x
.
storage
(
)
)
}
return
algorithm14
(
y
,
x
,
this
,
true
)
}
,
'Array, any'
:
function
(
x
,
y
)
{
// use matrix implementation
return
this
(
matrix
(
x
)
,
y
)
.
valueOf
(
)
}
,
'any, Array'
:
function
(
x
,
y
)
{
// use matrix implementation
return
this
(
x
,
matrix
(
y
)
)
.
valueOf
(
)
}
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL