There are two main ways to make physical quantities: the function
make-pq, and the reader macro
ANTIK-USER> (make-pq 24.5d0 'm/s) #_24.500000000000000d0_m/s ANTIK-USER> #_24.5_m/s #_24.500000000000000d0_m/s
To get the magnitude and units of a physical quantity, use
pqval. It returns three values: the magnitude, units, and whether a single unit expression applies to all elements of the grid magnitude:
ANTIK-USER> (pqval #_24.5_m/s) 24.5 (/ METER SECOND) T ANTIK-USER> (pqval #m(#_1.0_km #_2.0_s #_3.0_kg)) #m(1000.000000000000000d0 2.000000000000000d0 3.000000000000000d0) #(METER SECOND KILOGRAM) NIL
A quantity with a dimension and possibly a unit, e.g. length or meter.
- obj is a pdq and units have the same dimension as obj,
- obj is zero and zeros-have-any-dimension is
- obj and units represent a dimensionless quantity,
- obj and units are grids of the same length, and for each pair of corresponding elements, one of the above is true.
Make a physical dimension quantity (PDQ). Allow for the possiblity that magnitude is already a
pdq; in this case, check that the physical dimension is correct, and pass it on. This can be used as a way of assigning default units to a number. Unitless dimensions (e.g., 'length) are interpeted as units in the :system-of-units. If scalar-dimension is
tand magnitude is not a scalar, the unit-expression applies to each element of the magnitude. Otherwise it must be a grid or list of the shape as the magnitude.