Function in prelude::math auto-imported

intersect

fn intersect<D, M>(Matrix<D> a, Matrix<D> b) -> Matrix<M>
Source: compiler/src/builtin_docs/prelude/math.hy

Returns a byte mask that is 1 where both matrices have a non-zero cell.

a and b must have the same shape. A cell counts as present when it is not 0 (NaN counts as present). The result is a Matrix of byte cells with the same shape; there is no scalar broadcast.

Parameters#

NameType
aMatrix<D>
bMatrix<D>

Returns#

Matrix<M>

Examples#

use tests::assert;
let a = matrix([[1, 0], [2, 3]]);
let b = matrix([[5, 6], [0, 7]]);
let m = intersect(a, b);
assert!(m[0][0] == 1 as byte);
assert!(m[0][1] == 0 as byte);
assert!(m[1][0] == 0 as byte);
assert!(m[1][1] == 1 as byte);

See also#

  • byte
  • Matrix
  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • floor: Returns the largest whole number less than or equal to x, as a float.
  • ceil: Returns the smallest whole number greater than or equal to x, as a float.
↑ ↓ navigate ↵ open