Returns a vector containing the results of performing a logical operation between a and b, using the truth table specified by c.
d=vec_logical(a, b, c)
The following table describes the types of the returned value and the function arguments.
d | a | b | c |
---|---|---|---|
vector4double | vector4double | vector4double | int, a value in the range of [0x0, 0xF] |
The value of each element of the result is the result of the logical operation between the corresponding elements of a and b, using the truth table specified by c.
The following table shows how to read the truth table in c for the nth element of a and b.
a[n] | b[n] | Binary result |
---|---|---|
False | False | c0 |
True | False | c1 |
False | True | c2 |
True | True | c3 |
The result value is calculated from the binary result.
Binary result | Result value |
---|---|
0 | 1.0 (True) |
1 | -1.0 (False) |
If (a[n] < 0.0) AND (b[n] < 0.0)
If (c0 EQ 0), d[n]= -1.0
Else d[n]= 1.0
If (a[n] ≥ 0.0) AND (b[n] < 0.0)
If (c1 EQ 0), d[n]= -1.0
Else d[n]= 1.0
If (a[n] < 0.0) AND (b[n] ≥ 0.0)
If (c2 EQ 0), d[n]= -1.0
Else d[n]= 1.0
If (a[n] ≥ 0.0) AND (b[n] ≥ 0.0)
If (c3 EQ 0), d[n]= -1.0
Else d[n]= 1.0
You can use the values for c from the following table to replicate some usual logical operators.
Binary | c | Operator |
---|---|---|
0001 | 0x1 | AND |
0110 | 0x6 | XOR |
0111 | 0x7 | OR |
1000 | 0x8 | NOR |
1110 | 0xE | NAND |