This is the latest (main) BeagleBoard documentation. If you are looking for stable releases, use the drop-down menu on the bottom-left and select the desired version.

Function rc_filter_alloc

Function Documentation

int rc_filter_alloc(rc_filter_t *f, rc_vector_t num, rc_vector_t den, double dt)

Allocate memory for a discrete-time filter & populates it with the transfer function coefficients provided in vectors num and den.

The memory in num and den is duplicated so those vectors can be reused or freed after allocating a filter without fear of disturbing the function of the filter. Argument dt is the timestep in seconds at which the user expects to operate the filter. The length of demonimator den must be at least as large as numerator num to avoid describing an improper transfer function. If rc_filter_t pointer f points to an existing filter then the old filter’s contents are freed safely to avoid memory leaks. We suggest initializing filter f with rc_filter_empty before calling this function if it is not a global variable to ensure it does not accidentally contain invlaid contents such as null pointers. The filter’s order is derived from the length of the denominator polynomial.

Parameters
  • f[out] Pointer to user’s rc_filter_t struct

  • num[in] The numerator vector

  • den[in] The denomenator vector

  • dt[in] Timestep in seconds

Returns

0 on success or -1 on failure.