Next: , Previous: About physical dimension, Up: Physical dimension

#### 5.3.2 Making physical dimension quantities

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
```
— Class: antik:physical-quantity

Class precedence list: `physical-quantity, standard-object, t`

A quantity with a dimension and possibly a unit, e.g. length or meter.

— Function: antik:check-dimension obj units &optional errorp zeros-have-any-dimension

`t` if one of these cases hold:

• obj is a pdq and units have the same dimension as obj,
• obj is zero and zeros-have-any-dimension is `t`,
• 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.

— Function: antik:make-pq magnitude unit-expression &optional sysunits scalar-dimension

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. If sysunits is specified, unitless dimensions (e.g., 'length) are interpeted as units in that system. If scalar-dimension is `t` and 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.

— Function: antik:new-units pq &optional sysunits-additional-units stream

Format the physical dimension quantity in units different than the default. Note that sysunits-additional-units must be a list.

— Generic Function: antik:pqval pq &rest sysunits-additional-units

Get the numerical value and the units of the physical dimension quantity. Returns the magnitude, the units, and whether units are the same for each element of a sequence or grid.

— Macro: antik:with-pq physical-quantities &body body

Ensure that the named physical dimension quantities are of the right dimensions, or convert them from plain numbers using the current system of units as specified by *system-of-units*.

— Variable: antik:*zero-is-dimensionless*

Numbers with zero magnitude are made dimensionless.