gRound

Contributed by Andrew Gibson round the 1D array x to a multiple of granularity ``(double[])``

@param x - the input @param granularity - the granularity to which to round x @return - 1 1D array of elements i, such that. ``x[i]`` is rounded to ``granularity[i]``


Contributed by Andrew Gibson round a 1D array x to a multiple of a scalar granularity value note that 0 or null granularity values are interpreted as "no rounding"

Granularity represents the finest division of the measurement scale. For example, a 12-inch rule that has inches divided into 4 quarters has a granularity of 1/4 or 0.25. The function rounds the supplied double to the nearest multiple of the granularity.

For example,

gRound(3.1459, granularity = 0.25) = 3.25 gRound(3.0459, granularity = 0.25) = 3.0

See this stack overflow post for further information.

Return

  • 1D array the same size as x

Parameters

x
  • input[]

granularity
  • Double