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