# psychopy.tools.mathtools.length¶

psychopy.tools.mathtools.length(v, squared=False, out=None, dtype=None)[source]

Get the length of a vector.

Parameters
• v (array_like) – Vector to normalize, can be Nx2, Nx3, or Nx4. If a 2D array is specified, rows are treated as separate vectors.

• squared (bool, optional) – If True the squared length is returned. The default is False.

• out (ndarray, optional) – Optional output array. Must be same shape and dtype as the expected output if out was not specified.

• dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns

Length of vector v.

Return type

float or ndarray