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