1 package org.djunits.value.vdouble.vector; 2 3 import java.util.List; 4 import java.util.Map; 5 6 import org.djunits.unit.EquivalentDoseUnit; 7 import org.djunits.unit.scale.IdentityScale; 8 import org.djunits.value.storage.StorageType; 9 import org.djunits.value.vdouble.scalar.EquivalentDose; 10 import org.djunits.value.vdouble.vector.base.DoubleVectorRel; 11 import org.djunits.value.vdouble.vector.data.DoubleVectorData; 12 13 import jakarta.annotation.Generated; 14 15 /** 16 * Double EquivalentDoseVector, a vector of values with a EquivalentDoseUnit. 17 * <p> 18 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 19 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 20 * </p> 21 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 22 * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a> 23 */ 24 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z") 25 public class EquivalentDoseVector extends DoubleVectorRel<EquivalentDoseUnit, EquivalentDose, EquivalentDoseVector> 26 27 { 28 /** */ 29 private static final long serialVersionUID = 20190905L; 30 31 /** 32 * Construct an EquivalentDoseVector from an internal data object. 33 * @param data DoubleVectorData; the internal data object for the vector 34 * @param displayUnit EquivalentDoseUnit; the display unit of the vector data 35 */ 36 public EquivalentDoseVector(final DoubleVectorData data, final EquivalentDoseUnit displayUnit) 37 { 38 super(data, displayUnit); 39 } 40 41 /* CONSTRUCTORS WITH double[] */ 42 43 /** 44 * Construct an EquivalentDoseVector from a double[] object. The double values are expressed in the displayUnit, and will be 45 * printed using the displayUnit. 46 * @param data double[]; the data for the vector, expressed in the displayUnit 47 * @param displayUnit EquivalentDoseUnit; the unit of the values in the data array, and display unit when printing 48 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 49 */ 50 public EquivalentDoseVector(final double[] data, final EquivalentDoseUnit displayUnit, final StorageType storageType) 51 { 52 this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit); 53 } 54 55 /** 56 * Construct an EquivalentDoseVector from a double[] object. The double values are expressed in the displayUnit. Assume that 57 * the StorageType is DENSE since we offer the data as an array. 58 * @param data double[]; the data for the vector 59 * @param displayUnit EquivalentDoseUnit; the unit of the values in the data array, and display unit when printing 60 */ 61 public EquivalentDoseVector(final double[] data, final EquivalentDoseUnit displayUnit) 62 { 63 this(data, displayUnit, StorageType.DENSE); 64 } 65 66 /** 67 * Construct an EquivalentDoseVector from a double[] object with SI-unit values. 68 * @param data double[]; the data for the vector, in SI units 69 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 70 */ 71 public EquivalentDoseVector(final double[] data, final StorageType storageType) 72 { 73 this(data, EquivalentDoseUnit.SI, storageType); 74 } 75 76 /** 77 * Construct an EquivalentDoseVector from a double[] object with SI-unit values. Assume that the StorageType is DENSE since 78 * we offer the data as an array. 79 * @param data double[]; the data for the vector, in SI units 80 */ 81 public EquivalentDoseVector(final double[] data) 82 { 83 this(data, StorageType.DENSE); 84 } 85 86 /* CONSTRUCTORS WITH EquivalentDose[] */ 87 88 /** 89 * Construct an EquivalentDoseVector from an array of EquivalentDose objects. The EquivalentDose values are each expressed 90 * in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. 91 * @param data EquivalentDose[]; the data for the vector 92 * @param displayUnit EquivalentDoseUnit; the display unit of the values when printing 93 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 94 */ 95 public EquivalentDoseVector(final EquivalentDose[] data, final EquivalentDoseUnit displayUnit, 96 final StorageType storageType) 97 { 98 this(DoubleVectorData.instantiate(data, storageType), displayUnit); 99 } 100 101 /** 102 * Construct an EquivalentDoseVector from an array of EquivalentDose objects. The EquivalentDose values are each expressed 103 * in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. Assume 104 * that the StorageType is DENSE since we offer the data as an array. 105 * @param data EquivalentDose[]; the data for the vector 106 * @param displayUnit EquivalentDoseUnit; the display unit of the values when printing 107 */ 108 public EquivalentDoseVector(final EquivalentDose[] data, final EquivalentDoseUnit displayUnit) 109 { 110 this(data, displayUnit, StorageType.DENSE); 111 } 112 113 /** 114 * Construct an EquivalentDoseVector from an array of EquivalentDose objects. The EquivalentDose values are each expressed 115 * in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. since we offer 116 * the data as an array. 117 * @param data EquivalentDose[]; the data for the vector 118 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 119 */ 120 public EquivalentDoseVector(final EquivalentDose[] data, final StorageType storageType) 121 { 122 this(data, EquivalentDoseUnit.SI, storageType); 123 } 124 125 /** 126 * Construct an EquivalentDoseVector from an array of EquivalentDose objects. The EquivalentDose values are each expressed 127 * in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. Assume that 128 * the StorageType is DENSE since we offer the data as an array. 129 * @param data EquivalentDose[]; the data for the vector 130 */ 131 public EquivalentDoseVector(final EquivalentDose[] data) 132 { 133 this(data, StorageType.DENSE); 134 } 135 136 /* CONSTRUCTORS WITH List<Double> or List<EquivalentDose> */ 137 138 /** 139 * Construct an EquivalentDoseVector from a list of Number objects or a list of EquivalentDose objects. Note that the 140 * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or 141 * EquivalentDose objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values 142 * in the list are expressed, as well as the unit in which they will be printed. In case the list contains EquivalentDose 143 * objects, each EquivalentDose has its own unit, and the displayUnit is just used for printing. The values but will always 144 * be internally stored as SI values or base values, and expressed using the display unit or base unit when printing. 145 * @param data List<Double> or List<EquivalentDose>; the data for the vector 146 * @param displayUnit EquivalentDoseUnit; the display unit of the vector data, and the unit of the data points when the data 147 * is expressed as List<Double> or List<Number> in general 148 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 149 */ 150 public EquivalentDoseVector(final List<? extends Number> data, final EquivalentDoseUnit displayUnit, 151 final StorageType storageType) 152 { 153 this(data.size() == 0 ? DoubleVectorData.instantiate(new double[] {}, IdentityScale.SCALE, storageType) 154 : data.get(0) instanceof EquivalentDose ? DoubleVectorData.instantiate(data, IdentityScale.SCALE, storageType) 155 : DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), 156 displayUnit); 157 } 158 159 /** 160 * Construct an EquivalentDoseVector from a list of Number objects or a list of EquivalentDose objects. Note that the 161 * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Double objects) or 162 * EquivalentDose objects. In case the list contains Number objects, the displayUnit indicates the unit in which the values 163 * in the list are expressed, as well as the unit in which they will be printed. In case the list contains EquivalentDose 164 * objects, each EquivalentDose has its own unit, and the displayUnit is just used for printing. The values but will always 165 * be internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume 166 * the storage type is DENSE since we offer the data as a List. 167 * @param data List<Double> or List<EquivalentDose>; the data for the vector 168 * @param displayUnit EquivalentDoseUnit; the display unit of the vector data, and the unit of the data points when the data 169 * is expressed as List<Double> or List<Number> in general 170 */ 171 public EquivalentDoseVector(final List<? extends Number> data, final EquivalentDoseUnit displayUnit) 172 { 173 this(data, displayUnit, StorageType.DENSE); 174 } 175 176 /** 177 * Construct an EquivalentDoseVector from a list of Number objects or a list of EquivalentDose objects. When data contains 178 * numbers such as Double, assume that they are expressed using SI units. When the data consists of EquivalentDose objects, 179 * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally 180 * stored as SI values or base values, and expressed using the display unit or base unit when printing. 181 * @param data List<Double> or List<EquivalentDose>; the data for the vector 182 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 183 */ 184 public EquivalentDoseVector(final List<? extends Number> data, final StorageType storageType) 185 { 186 this(data, EquivalentDoseUnit.SI, storageType); 187 } 188 189 /** 190 * Construct an EquivalentDoseVector from a list of Number objects or a list of EquivalentDose objects. When data contains 191 * numbers such as Double, assume that they are expressed using SI units. When the data consists of EquivalentDose objects, 192 * they each have their own unit, but will be printed using SI units or base units. The values but will always be internally 193 * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage 194 * type is DENSE since we offer the data as a List. 195 * @param data List<Double> or List<EquivalentDose>; the data for the vector 196 */ 197 public EquivalentDoseVector(final List<? extends Number> data) 198 { 199 this(data, StorageType.DENSE); 200 } 201 202 /* CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, EquivalentDose> */ 203 204 /** 205 * Construct an EquivalentDoseVector from a (sparse) map of index values to Number objects or a (sparse) map of index values 206 * to of EquivalentDose objects. Using index values is particularly useful for sparse vectors. The size parameter indicates 207 * the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a 208 * different meaning depending on whether the map contains Number objects (e.g., Double objects) or EquivalentDose objects. 209 * In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, 210 * as well as the unit in which they will be printed. In case the map contains EquivalentDose objects, each EquivalentDose 211 * has its own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI 212 * values or base values, and expressed using the display unit or base unit when printing. 213 * @param data Map<Integer, Double> or Map<Integer, EquivalentDose>; the data for the vector 214 * @param size int; the size off the vector, i.e., the highest index 215 * @param displayUnit EquivalentDoseUnit; the display unit of the vector data, and the unit of the data points when the data 216 * is expressed as List<Double> or List<Number> in general 217 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 218 */ 219 public EquivalentDoseVector(final Map<Integer, ? extends Number> data, final int size, final EquivalentDoseUnit displayUnit, 220 final StorageType storageType) 221 { 222 this(data.size() == 0 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 223 : data.values().iterator().next() instanceof EquivalentDose 224 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 225 : DoubleVectorData.instantiate(data, size, displayUnit.getScale(), storageType), 226 displayUnit); 227 } 228 229 /** 230 * Construct an EquivalentDoseVector from a (sparse) map of index values to Number objects or a (sparse) map of index values 231 * to of EquivalentDose objects. Using index values is particularly useful for sparse vectors. The size parameter indicates 232 * the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit has a 233 * different meaning depending on whether the map contains Number objects (e.g., Double objects) or EquivalentDose objects. 234 * In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are expressed, 235 * as well as the unit in which they will be printed. In case the map contains EquivalentDose objects, each EquivalentDose 236 * has its own unit, and the displayUnit is just used for printing. The values but will always be internally stored as SI 237 * values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE 238 * since we offer the data as a Map. 239 * @param data Map<Integer, Double> or Map<Integer, EquivalentDose>; the data for the vector 240 * @param size int; the size off the vector, i.e., the highest index 241 * @param displayUnit EquivalentDoseUnit; the display unit of the vector data, and the unit of the data points when the data 242 * is expressed as List<Double> or List<Number> in general 243 */ 244 public EquivalentDoseVector(final Map<Integer, ? extends Number> data, final int size, final EquivalentDoseUnit displayUnit) 245 { 246 this(data, size, displayUnit, StorageType.SPARSE); 247 } 248 249 /** 250 * Construct an EquivalentDoseVector from a (sparse) map of index values to Number objects or a (sparse) map of index values 251 * to of EquivalentDose objects. Using index values is particularly useful for sparse vectors. The size parameter indicates 252 * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as 253 * Double, assume that they are expressed using SI units. When the data consists of EquivalentDose objects, they each have 254 * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI 255 * values or base values, and expressed using the display unit or base unit when printing. 256 * @param data Map<Integer, Double> or Map<Integer, EquivalentDose>; the data for the vector 257 * @param size int; the size off the vector, i.e., the highest index 258 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 259 */ 260 public EquivalentDoseVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType) 261 { 262 this(data, size, EquivalentDoseUnit.SI, storageType); 263 } 264 265 /** 266 * Construct an EquivalentDoseVector from a (sparse) map of index values to Number objects or a (sparse) map of index values 267 * to of EquivalentDose objects. Using index values is particularly useful for sparse vectors. The size parameter indicates 268 * the size of the vector, since the largest index does not have to be part of the map. When data contains numbers such as 269 * Double, assume that they are expressed using SI units. When the data consists of EquivalentDose objects, they each have 270 * their own unit, but will be printed using SI units or base units. The values but will always be internally stored as SI 271 * values or base values, and expressed using the display unit or base unit when printing. Assume the storage type is SPARSE 272 * since we offer the data as a Map. 273 * @param data Map<Integer, Double> or Map<Integer, EquivalentDose>; the data for the vector 274 * @param size int; the size off the vector, i.e., the highest index 275 */ 276 public EquivalentDoseVector(final Map<Integer, ? extends Number> data, final int size) 277 { 278 this(data, size, StorageType.SPARSE); 279 } 280 281 /* ****************************** Other methods ****************************** */ 282 283 @Override 284 public Class<EquivalentDose> getScalarClass() 285 { 286 return EquivalentDose.class; 287 } 288 289 @Override 290 public EquivalentDoseVector instantiateVector(final DoubleVectorData dvd, final EquivalentDoseUnit displayUnit) 291 { 292 return new EquivalentDoseVector(dvd, displayUnit); 293 } 294 295 @Override 296 public EquivalentDose instantiateScalarSI(final double valueSI, final EquivalentDoseUnit displayUnit) 297 { 298 EquivalentDose result = EquivalentDose.instantiateSI(valueSI); 299 result.setDisplayUnit(displayUnit); 300 return result; 301 } 302 303 }