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 multiplyingmultiplierinto it.coef: A real coefficient multiplied intounitmultiplier: The optional multiplicand unitpower: The power to whichmultiplieris raised before multiplying it intounit
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:
pmodemust be valid. (low-cost)unitmust be a valid unit handle. (low-cost)unitmust have a zero offset (the default). (low-cost)unitmust not have a logarithm base assigned (the default). (low-cost)coefmust be positive. (low-cost)multipliermust be a valid unit handle if supplied. (low-cost)multipliermust have a zero offset if supplied. (low-cost)multipliermust 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:
- saf_declare_unit: 21.1: Declare a new unit
- saf_divide_unit: 21.3: Divide a unit into a unit definition
- Units: Introduction for current chapter