class_docstr: This is a multi-point Kalman Filter implementation of
  https://github.com/rlabbe/filterpy/blob/master/filterpy/kalman/kalman_filter.py,
  with a subset of functionality.
  
  All Kalman Filter matrices are stack on the X axis. This is to allow
  for optimal global accesses on the GPU.
  
  Parameters
  ----------
  dim_x : int
      Number of state variables for the Kalman filter. For example, if
      you are tracking the position and velocity of an object in two
      dimensions, dim_x would be 4.
      This is used to set the default size of P, Q, and u
  
  dim_z : int
      Number of of measurement inputs. For example, if the sensor
      provides you with position in (x,y), dim_z would be 2.
  
  dim_u : int (optional)
      Size of the control input, if it is being used.
      Default value of 0 indicates it is not used.
  
  points : int (optional)
      Number of Kalman Filter points to track.
  
  dtype : dtype (optional)
      Data type of compute.
  
  Attributes
  ----------
  x : array(points, dim_x, 1)
      Current state estimate. Any call to update() or predict() updates
      this variable.
  
  P : array(points, dim_x, dim_x)
      Current state covariance matrix. Any call to update() or predict()
      updates this variable.
  
  z : array(points, dim_z, 1)
      Last measurement used in update(). Read only.
  
  R : array(points, dim_z, dim_z)
      Measurement noise matrix
  
  Q : array(points, dim_x, dim_x)
      Process noise matrix
  
  F : array(points, dim_x, dim_x)
      State Transition matrix
  
  H : array(points, dim_z, dim_x)
      Measurement function
  
  _alpha_sq : float (points, 1, 1)
      Fading memory setting. 1.0 gives the normal Kalman filter, and
      values slightly larger than 1.0 (such as 1.02) give a fading
      memory effect - previous measurements have less influence on the
      filter's estimates. This formulation of the Fading memory filter
      (there are many) is due to Dan Simon [1]_.
  
  Examples
  --------
  Here is a filter that tracks position and velocity using a sensor that only
  reads position.
  
  First construct the object with the required dimensionality,
  number of points, and data type.
  
  .. code::
  
      import cupy as cp
      import numpy as np
  
      from cusignal import KalmanFilter
  
      points = 1024
      kf = KalmanFilter(dim_x=4, dim_z=2, points=points, dtype=cp.float64)
  
  Assign the initial value for the state (position and velocity)
  for all Kalman Filter points.
  
  .. code::
  
      initial_location = np.array(
          [[10.0, 10.0, 0.0, 0.0]], dtype=dt
      ).T  # x, y, v_x, v_y
      kf.x = cp.repeat(
          cp.asarray(initial_location[cp.newaxis, :, :]), points, axis=0
      )
  
  Define the state transition matrix for all Kalman Filter points:
  
      .. code::
  
          F = np.array(
              [
                  [1.0, 0.0, 1.0, 0.0],  # x = x0 + v_x*dt
                  [0.0, 1.0, 0.0, 1.0],  # y = y0 + v_y*dt
                  [0.0, 0.0, 1.0, 0.0],  # dx = v_x
                  [1.0, 0.0, 0.0, 1.0],
              ],  # dy = v_y
              dtype=dt,
          )
          kf.F = cp.repeat(cp.asarray(F[cp.newaxis, :, :]), points, axis=0)
  
  Define the measurement function for all Kalman Filter points:
  
      .. code::
  
          H = np.array(
              [[1.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 1.0]],
              dtype=dt,  # x_0  # y_0
          )
          kf.H = cp.repeat(cp.asarray(H[cp.newaxis, :, :]), points, axis=0)
  
  Define the covariance matrix for all Kalman Filter points:
  
      .. code::
  
          initial_estimate_error = np.eye(dim_x, dtype=dt) * np.array(
              [1.0, 1.0, 2.0, 2.0], dtype=dt
          )
          kf.P = cp.repeat(
              cp.asarray(initial_estimate_error[cp.newaxis, :, :]),
              points,
              axis=0,
          )
  
  Define the measurement noise  for all Kalman Filter points:
  
      .. code::
  
          measurement_noise = np.eye(dim_z, dtype=dt) * 0.01
          kf.R = cp.repeat(
              cp.asarray(measurement_noise[cp.newaxis, :, :]), points, axis=0
          )
  
  Define the process noise  for all Kalman Filter points:
  
      .. code::
          motion_noise = np.eye(dim_x, dtype=dt) * np.array(
              [10.0, 10.0, 10.0, 10.0], dtype=dt
          )
          kf.Q = cp.repeat(
              cp.asarray(motion_noise[cp.newaxis, :, :]), points, axis=0
          )
  
  Now just perform the standard predict/update loop:
  Note: This example just uses the same sensor reading for all points
  
      .. code::
  
          kf.predict()
          z = get_sensor_reading() (dim_z, 1)
          kf.z = cp.repeat(z[cp.newaxis, :, :], points, axis=0)
          kf.update()
  
  Results are in:
  
      .. code::
          kf.x[:, :, :]
  
  References
  ----------
  
  .. [1] Dan Simon. "Optimal State Estimation." John Wiley & Sons.
     p. 208-212. (2006)
  
  .. [2] Roger Labbe. "Kalman and Bayesian Filters in Python"
     https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
docstr: Add a new measurement (z) to the Kalman filter.
  
  Parameters
  ----------
  z : array(points, dim_z, 1)
      measurement for this update. z can be a scalar if dim_z is 1,
      otherwise it must be convertible to a column vector.
      If you pass in a value of H, z must be a column vector the
      of the correct size.
  
  R : array(points, dim_z, dim_z), scalar, or None
      Optionally provide R to override the measurement noise for this
      one call, otherwise  self.R will be used.
  
  H : array(points, dim_z, dim_x), or None
  
      Optionally provide H to override the measurement function for this
      one call, otherwise self.H will be used.
docstr_tok: ["Add","a","new","measurement","(","z",")","to","the","Kalman","filter",".","Parameters","--","--","--","--","--","z",":","array","(","points",",","dim_z",",","1",")","measurement","for","this","update",".","z","can","be","a","scalar","if","dim_z","is","1",",","otherwise","it","must","be","convertible","to","a","column","vector",".","If","you","pass","in","a","value","of","H",",","z","must","be","a","column","vector","the","of","the","correct","size",".","R",":","array","(","points",",","dim_z",",","dim_z",")",",","scalar",",","or","None","Optionally","provide","R","to","override","the","measurement","noise","for","this","one","call",",","otherwise","self.R","will","be","used",".","H",":","array","(","points",",","dim_z",",","dim_x",")",",","or","None","Optionally","provide","H","to","override","the","measurement","function","for","this","one","call",",","otherwise","self.H","will","be","used","."]
code: def update(self, z, R=None, H=None):
      """
      Add a new measurement (z) to the Kalman filter.
  
      Parameters
      ----------
      z : array(points, dim_z, 1)
          measurement for this update. z can be a scalar if dim_z is 1,
          otherwise it must be convertible to a column vector.
          If you pass in a value of H, z must be a column vector the
          of the correct size.
  
      R : array(points, dim_z, dim_z), scalar, or None
          Optionally provide R to override the measurement noise for this
          one call, otherwise  self.R will be used.
  
      H : array(points, dim_z, dim_x), or None
  
          Optionally provide H to override the measurement function for this
          one call, otherwise self.H will be used.
      """
  
      if z is None:
          return
  
      if R is None:
          R = self.R
      elif cp.isscalar(R):
          R = cp.repeat(
              (cp.identity(self.dim_z, dtype=self.x.dtype) * R)[
                  cp.newaxis, :, :
              ],
              self.points,
              axis=0,
          )
      else:
          R = cp.asarray(R)
  
      if H is None:
          H = self.H
      else:
          H = cp.asarray(H)
  
      z = cp.asarray(z)
  
      self.update_kernel(
          self.x,
          z,
          H,
          self.P,
          R,
      )
  
imports: import cupy
  from ..utils.helper_tools import _get_numSM, _print_atts
  from .None import _filters_cuda
label_desc: Use image node_id 3 for calling the KalmanFilter obj's underlying member method code with example usage: obj.update(z, R, H) without return types