Multiply a unit into a unit definition

saf_multiply_unit is a function defined in unit.c.

Synopsis:

int saf_multiply_unit(SAF_ParMode pmode, SAF_Unit *unit, double coef, SAF_Unit *multiplier, int power)

Formal Arguments:

  • unit: The unit which is being modified by multiplying multiplier into it.
  • coef: A real coefficient multiplied into unit
  • multiplier: The optional multiplicand unit
  • power: The power to which multiplier is raised before multiplying it into unit

Description: After creating a new unit with saf_declare_unit, the unit is defined by multiplying scaled powers of other units into it, one per call to this function. A division by multiplier can be accomplished by supplying a negative power, although coef is always multiplied into U. Essentially, the result is:

1
 UNIT' = UNIT * COEF * (MULTIPLIER ^ POWER)

If multiplier is NULL then it is assumed to be unity. In other words, the scale factor can be adjusted for the unit by calling this function with only a coef value.

Preconditions:

  • pmode must be valid. (low-cost)
  • unit must be a valid unit handle. (low-cost)
  • unit must have a zero offset (the default). (low-cost)
  • unit must not have a logarithm base assigned (the default). (low-cost)
  • coef must be positive. (low-cost)
  • multiplier must be a valid unit handle if supplied. (low-cost)
  • multiplier must have a zero offset if supplied. (low-cost)
  • multiplier must not use a logarithmic scale if supplied. (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: