fpq package — fpq 0.12.0 documentation

# fpq package

## Submodules

## fpq.fp module

`fpq.fp.` `decode_d3d_snorm_to_fp`(x, *, dtype=<class 'numpy.float32'>, nbits=None)

  Decode signed normalized integers to floating-points.

  Parameters

    - x – The type should be np.uint, or an array in np.uint.

    - dtype – The type should be np.float.

    - nbits – The number of bits to use.

  Returns

    The resulting floating-points.

`fpq.fp.` `decode_ogl_snorm_to_fp`(x, *, dtype=<class 'numpy.float32'>, nbits=None)

  Decode signed normalized integers to floating-points.

  Parameters

    - x – The type should be np.uint, or an array in np.uint.

    - dtype – The type should be np.float.

    - nbits – The number of bits to use.

  Returns

    The resulting floating-points.

`fpq.fp.` `decode_std_snorm_to_fp`(x, *, dtype=<class 'numpy.float32'>, nbits=None)

  Decode signed normalized integers to floating-points.

  Parameters

    - x – The type should be np.uint, or an array in np.uint.

    - dtype – The type should be np.float.

    - nbits – The number of bits to use.

  Returns

    The resulting floating-points.

  Examples

      >>> fp = np.float32(-1.)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_snorm_to_fp(enc, dtype=np.float32, nbits=16)

      >>> fp = np.array([-1.0, -0.5, 0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_snorm_to_fp(enc, dtype=np.float32, nbits=16)

      >>> fp = np.array([[-1.0, -0.5, 0., 0.5, 1.], [1.0, 0.5, 0., -0.5, -1.]], dtype=np.float32)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_snorm_to_fp(enc, dtype=np.float32, nbits=16)

`fpq.fp.` `decode_std_unorm_to_fp`(x, *, dtype=<class 'numpy.float32'>, nbits=None)

  Decode unsigned normalized integers to floating-points.

  Parameters

    - x – The type should be np.uint, or an array in np.uint.

    - dtype – The type should be np.float.

    - nbits – The number of bits to use.

  Returns

    The resulting floating-points.

  Examples

      >>> fp = np.float32(1.)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_unorm_to_fp(enc, dtype=np.float32, nbits=16)

      >>> fp = np.array([0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_unorm_to_fp(enc, dtype=np.float32, nbits=16)

      >>> fp = np.array([[0., 0.5, 1.], [1., 0.5, 0.]], dtype=np.float32)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)
      >>> dec = decode_std_unorm_to_fp(enc, dtype=np.float32, nbits=16)

`fpq.fp.` `decode_uint_to_fp`(x, *, nbits=None)

  Decode unsigned integers to floating-points.

  Parameters

    - x – The type should be np.uint, or an array in np.uint.

    - nbits – The number of bits to use.

  Returns

    The resulting floating-points.

  Examples

      >>> fp = np.float32(1.)
      >>> enc = encode_fp_to_uint(fp, nbits=20)
      >>> dec = decode_uint_to_fp(enc, nbits=20)

      >>> fp = np.array([0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_uint(fp, nbits=20)
      >>> dec = decode_uint_to_fp(enc, nbits=20)

      >>> fp = np.array([[0., 0.5, 1.], [1., 0.5, 0.]], dtype=np.float32)
      >>> enc = encode_fp_to_uint(fp, nbits=20)
      >>> dec = decode_uint_to_fp(enc, nbits=20)

`fpq.fp.` `encode_fp_to_d3d_snorm`(x, *, dtype=<class 'numpy.uint8'>, nbits=None)

  Encode floating-points to signed normalized integers.

  Parameters

    - x – The type should be np.float, or an array in np.float.

    - dtype – The type should be np.uint.

    - nbits – The number of bits to use.

  Returns

    The resulting unsigned normalized integers.

`fpq.fp.` `encode_fp_to_ogl_snorm`(x, *, dtype=<class 'numpy.uint8'>, nbits=None)

  Encode floating-points to signed normalized integers.

  Parameters

    - x – The type should be np.float, or an array in np.float.

    - dtype – The type should be np.uint.

    - nbits – The number of bits to use.

  Returns

    The resulting unsigned normalized integers.

`fpq.fp.` `encode_fp_to_std_snorm`(x, *, dtype=<class 'numpy.uint8'>, nbits=None)

  Encode floating-points to signed normalized integers.

  Parameters

    - x – The type should be np.float, or an array in np.float.

    - dtype – The type should be np.uint.

    - nbits – The number of bits to use.

  Returns

    The resulting unsigned normalized integers.

  Examples

      >>> fp = np.float32(-1.)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)

      >>> fp = np.array([-1.0, -0.5, 0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)

      >>> fp = np.array([[-1.0, -0.5, 0., 0.5, 1.], [1.0, 0.5, 0., -0.5, -1.]], dtype=np.float32)
      >>> enc = encode_fp_to_std_snorm(fp, dtype=np.uint16, nbits=16)

`fpq.fp.` `encode_fp_to_std_unorm`(x, *, dtype=<class 'numpy.uint8'>, nbits=None)

  Encode floating-points to unsigned normalized integers.

  Parameters

    - x – The type should be np.float, or an array in np.float.

    - dtype – The type should be np.uint.

    - nbits – The number of bits to use.

  Returns

    The resulting unsigned normalized integers.

  Examples

      >>> fp = np.float32(1.)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)

      >>> fp = np.array([0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)

      >>> fp = np.array([[0., 0.5, 1.], [1., 0.5, 0.]], dtype=np.float32)
      >>> enc = encode_fp_to_std_unorm(fp, dtype=np.uint16, nbits=16)

`fpq.fp.` `encode_fp_to_uint`(x, *, nbits=None)

  Encode floating-points to unsigned integers.

  Parameters

    - x – The type should be np.float, or an array in np.float.

    - nbits – The number of bits to use.

  Returns

    The resulting unsigned integers.

  Examples

      >>> fp = np.float32(1.)
      >>> enc = encode_fp_to_uint(fp, nbits=20)

      >>> fp = np.array([0., 0.5, 1.], dtype=np.float32)
      >>> enc = encode_fp_to_uint(fp, nbits=20)

      >>> fp = np.array([[0., 0.5, 1.], [1., 0.5, 0.]], dtype=np.float32)
      >>> enc = encode_fp_to_uint(fp, nbits=20)

## fpq.numba_wrapper module

`fpq.numba_wrapper.` `avoid_mapping_to_py_types`(name_or_function=None)

  Avoid mapping to Python types.

`fpq.numba_wrapper.` `avoid_non_supported_types`(name_or_function=None)

  Avoid non-supported types.

`fpq.numba_wrapper.` `jit`(*args, **kwargs)

## fpq.quaternion module

`fpq.quaternion.` `decode_uint_to_quat`(q, *, dtype=<class 'numpy.float64'>, decoder=<function decode_std_snorm_to_fp>)

  Decode unsigned integers to Quaternions.

  Parameters

    - q – Should be represented by uint, or an array of them.

    - dtype – The type should be floating point types.

    - decoder – This is a function decodes an unsigned integer to a floating point.

  Returns

    The resulting Quaternions.

  Examples

      >>> q = np.array([1., 0., 0., 0.], dtype=np.float64)
      >>> enc = encode_quat_to_uint(q, dtype=np.uint64)
      >>> decode_uint_to_quat(enc, dtype=np.float64)

`fpq.quaternion.` `encode_quat_to_uint`(q, *, dtype=<class 'numpy.uint64'>, encoder=<function encode_fp_to_std_snorm>)

  Encode Quaternions to unsigned integers.

  Parameters

    - q – Should be represented by four components of float, or an array of them.

    - dtype – The type should be unsigned integer types.

    - encoder – This is a function encodes a floating point to an unsigned integer.

  Returns

    The resulting unsigned integers.

  Examples

      >>> q = np.array([1., 0., 0., 0.], dtype=np.float64)
      >>> encode_quat_to_uint(q, dtype=np.uint64)

## fpq.utils module

`fpq.utils.` `get_max_component_indices`(x)

  Returns the indices of the maximum components.

  Parameters

    x – Input array.

  Returns

    The resulting indices.

`fpq.utils.` `remap`(x, src_min, src_max, dst_min, dst_max)

  Maps values from [src_min, src_max] to [dst_min, dst_max].

  Parameters

    - x – The incoming value to be converted.

    - src_min – Lower bound of the value current range.

    - src_max – Upper bound of the value current range.

    - dst_min – Lower bound of the value target range.

    - dst_max – Upper bound of the value target range.

  Returns

    The resulting value.

`fpq.utils.` `remove_component`(x, *, indices)

  Removes components at the specified indices.

  Parameters

    - x – Input array.

    - indices – Indices refers to components to remove from x.

  Returns

    Returns a new array excluded by indices.

`fpq.utils.` `rint`(x, out=None)

  Wrapper function for numpy.rint.

## fpq.vector module

`fpq.vector.` `calc_breakdown_of_uint`(dtype, nbits)

  Calculate a breakdown of an unsigned integer.

`fpq.vector.` `decode_uint_to_vec`(v, *, dtype=<class 'numpy.float64'>, nbits=20, decoder=<function decode_std_snorm_to_fp>)

  Decode unsigned integers to vectors.

  Parameters

    - v – Should be represented by uint, or an array of them.

    - dtype – The type should be floating point types.

    - nbits – The number of bits to use.

    - decoder – This is a function decodes an unsigned integer to a floating point.

  Returns

    The resulting vectors.

  Examples

      >>> v = np.array([1., 2., 3.], dtype=np.float64)
      >>> enc = encode_vec_to_uint(v, dtype=np.uint64, nbits=20)
      >>> decode_uint_to_vec(enc, dtype=np.float64, nbits=20)

`fpq.vector.` `encode_vec_to_uint`(v, *, dtype=<class 'numpy.uint64'>, nbits=20, encoder=<function encode_fp_to_std_snorm>)

  Encode vectors to unsigned integers.

  Parameters

    - v – Should be represented by three components of float, or an array of them.

    - dtype – The type should be unsigned integer types.

    - nbits – The number of bits to use.

    - encoder – This is a function encodes a floating point to an unsigned integer.

  Returns

    The resulting unsigned integers.

  Examples

      >>> v = np.array([1., 2., 3.], dtype=np.float64)
      >>> encode_vec_to_uint(v, dtype=np.uint64, nbits=20)

`fpq.vector.` `is_valid_format`(dtype_f, dtype_u, nbits)

`fpq.vector.` `l2norm`(v)

  Calculates the L2 norm.

## Module contents