mround

fun mround(x: DoubleArray, granularity: DoubleArray?): DoubleArray

contributed by Andrew Gibson round the 1D array x to a multiple of granularity (double[]) note that 0 or null granularity values are interpreted as "no rounding"

Return

  • 1 1D array of elements i s.t. xi is rounded to granularityi

Parameters

x
  • the input

granularity
  • the granularity to which to round x


fun mround(x: DoubleArray, granularity: Double): DoubleArray

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,

mround(3.1459, granularity = 0.25) = 3.25 mround(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