Apply a logarithmic scale to a unit

saf_log_unit is a function defined in unit.c.

Synopsis:

int saf_log_unit(SAF_ParMode pmode, SAF_Unit *unit, double logbase, double logcoef)

Formal Arguments:

  • unit: The unit which is being translated by OFFSET.
  • logbase: The base of the logarithm
  • logcoef: The amount by which to multiply the unit after taking the log.

Description: Some units of measure use a logarithmic scale. An example is decibels. This function sets the base for the logarithm. A logbase of zero implies a linear scale and is the default for all units. This function should only be called after any calls to saf_multiply_unit and saf_offset_unit for unit.

1
 U' = LOGCOEF *log* UNIT

where log is to the base logbase.

Preconditions:

  • pmode must be valid. (low-cost)
  • unit must be a valid unit handle. (low-cost)
  • logbase must be non-negative. (low-cost)
  • logcoef must be non-zero if a logarithmic scale is used. (low-cost)

Return Value: This function returns some non-negative value on success; otherwise, it either returns a negative value or raises an exception, depending on the error handling property of the library.

See Also: