cross

Contents

cross#

class brainunit.linalg.cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None, **kwargs)#

Return the cross product of two (arrays of) vectors.

The cross product of a and b in \(R^3\) is a vector perpendicular to both a and b. The resulting unit is a.unit * b.unit.

Parameters:
  • a (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Components of the first vector(s).

  • b (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Components of the second vector(s).

  • axisa (int) – Axis of a that defines the vector(s). By default, the last axis.

  • axisb (int) – Axis of b that defines the vector(s). By default, the last axis.

  • axisc (int) – Axis of c containing the cross product vector(s). Ignored if both input vectors have dimension 2. By default, the last axis.

  • axis (int | None) – If defined, the axis of a, b and c that defines the vector(s) and cross product(s). Overrides axisa, axisb and axisc.

Returns:

c – Vector cross product(s). The resulting unit is a.unit * b.unit.

Return type:

saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex

Examples

>>> import saiunit as u
>>> a = u.math.array([1.0, 0.0, 0.0]) * u.meter
>>> b = u.math.array([0.0, 1.0, 0.0]) * u.second
>>> u.math.cross(a, b)  # unit is meter * second