You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `Dimensions(args...)`: Pass all the dimensions as arguments. `R` is set to `DEFAULT_DIM_TYPE`.
26
+
- `Dimensions(; kws...)`: Pass a subset of dimensions as keyword arguments. `R` is set to `DEFAULT_DIM_TYPE`.
27
+
- `Dimensions(::Type{R}; kws...)` or `Dimensions{R}(; kws...)`: Pass a subset of dimensions as keyword arguments, with the output type set to `Dimensions{R}`.
28
+
- `Dimensions{R}(args...)`: Pass all the dimensions as arguments, with the output type set to `Dimensions{R}`.
29
+
- `Dimensions{R}(d::Dimensions)`: Copy the dimensions from another `Dimensions` object, with the output type set to `Dimensions{R}`.
30
+
22
31
"""
23
32
struct Dimensions{R <:Real}
24
33
length::R
@@ -68,12 +77,21 @@ You can access specific dimensions with `ulength(q)`, `umass(q)`, `utime(q)`,
68
77
`ucurrent(q)`, `utemperature(q)`, `uluminosity(q)`, and `uamount(q)`.
69
78
70
79
Severals operators in `Base` are extended to work with `Quantity` objects,
71
-
including `*`, `+`, `-`, `/`, `^`, `sqrt`, and `cbrt`.
80
+
including `*`, `+`, `-`, `/`, `abs`, `^`, `sqrt`, and `cbrt`, which manipulate
81
+
dimensions according to the operation.
72
82
73
83
# Fields
74
84
75
-
- `value::T`: value of the quantity of some type `T`
76
-
- `dimensions::Dimensions`: dimensions of the quantity
85
+
- `value::T`: value of the quantity of some type `T`. Access with `ustrip(::Quantity)`
86
+
- `dimensions::Dimensions{R}`: dimensions of the quantity with dimension type `R`. Access with `dimension(::Quantity)`
87
+
88
+
# Constructors
89
+
90
+
- `Quantity(x; kws...)`: Construct a quantity with value `x` and dimensions given by the keyword arguments. The value type is inferred from `x`. `R` is set to `DEFAULT_DIM_TYPE`.
91
+
- `Quantity(x, ::Type{R}; kws...)`: Construct a quantity with value `x`. The dimensions parametric type is set to `R`.
92
+
- `Quantity(x, d::Dimensions{R})`: Construct a quantity with value `x` and dimensions `d`.
93
+
- `Quantity{T}(q::Quantity)`: Construct a quantity with value `q.value` and dimensions `q.dimensions`, but with value type converted to `T`.
94
+
- `Quantity{T,R}(q::Quantity)`: Construct a quantity with value `q.value` and dimensions `q.dimensions`, but with value type converted to `T` and dimensions parametric type set to `R`.
0 commit comments