1 package org.djunits.value.vfloat.vector; 2 3 import java.util.List; 4 import java.util.Map; 5 6 import org.djunits.unit.DimensionlessUnit; 7 import org.djunits.unit.scale.IdentityScale; 8 import org.djunits.value.function.DimensionlessFunctions; 9 import org.djunits.value.storage.StorageType; 10 import org.djunits.value.vfloat.function.FloatMathFunctions; 11 import org.djunits.value.vfloat.scalar.FloatDimensionless; 12 import org.djunits.value.vfloat.vector.base.FloatVectorRel; 13 import org.djunits.value.vfloat.vector.data.FloatVectorData; 14 15 import jakarta.annotation.Generated; 16 17 /** 18 * Immutable Float FloatDimensionlessVector, a vector of values with a DimensionlessUnit. 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 FloatDimensionlessVector extends FloatVectorRel<DimensionlessUnit, FloatDimensionless, FloatDimensionlessVector> 28 implements DimensionlessFunctions<DimensionlessUnit, FloatDimensionlessVector> 29 { 30 /** */ 31 private static final long serialVersionUID = 20190905L; 32 33 /** 34 * Construct a FloatDimensionlessVector from an internal data object. 35 * @param data FloatVectorData; the internal data object for the vector 36 * @param displayUnit DimensionlessUnit; the display unit of the vector data 37 */ 38 public FloatDimensionlessVector(final FloatVectorData data, final DimensionlessUnit displayUnit) 39 { 40 super(data, displayUnit); 41 } 42 43 /* CONSTRUCTORS WITH float[] */ 44 45 /** 46 * Construct a FloatDimensionlessVector from a float[] object. The Float values are expressed in the displayUnit, and will 47 * be printed using the displayUnit. 48 * @param data float[]; the data for the vector, expressed in the displayUnit 49 * @param displayUnit DimensionlessUnit; 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 FloatDimensionlessVector(final float[] data, final DimensionlessUnit displayUnit, final StorageType storageType) 53 { 54 this(FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit); 55 } 56 57 /** 58 * Construct a FloatDimensionlessVector from a float[] object. The Float values are expressed in the displayUnit. Assume 59 * that the StorageType is DENSE since we offer the data as an array. 60 * @param data float[]; the data for the vector 61 * @param displayUnit DimensionlessUnit; the unit of the values in the data array, and display unit when printing 62 */ 63 public FloatDimensionlessVector(final float[] data, final DimensionlessUnit displayUnit) 64 { 65 this(data, displayUnit, StorageType.DENSE); 66 } 67 68 /** 69 * Construct a FloatDimensionlessVector from a float[] object with SI-unit values. 70 * @param data float[]; 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 FloatDimensionlessVector(final float[] data, final StorageType storageType) 74 { 75 this(data, DimensionlessUnit.SI, storageType); 76 } 77 78 /** 79 * Construct a FloatDimensionlessVector from a float[] object with SI-unit values. Assume that the StorageType is DENSE 80 * since we offer the data as an array. 81 * @param data float[]; the data for the vector, in SI units 82 */ 83 public FloatDimensionlessVector(final float[] data) 84 { 85 this(data, StorageType.DENSE); 86 } 87 88 /* CONSTRUCTORS WITH FloatDimensionless[] */ 89 90 /** 91 * Construct a FloatDimensionlessVector from an array of FloatDimensionless objects. The FloatDimensionless values are each 92 * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. 93 * @param data FloatDimensionless[]; the data for the vector 94 * @param displayUnit DimensionlessUnit; 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 FloatDimensionlessVector(final FloatDimensionless[] data, final DimensionlessUnit displayUnit, 98 final StorageType storageType) 99 { 100 this(FloatVectorData.instantiate(data, storageType), displayUnit); 101 } 102 103 /** 104 * Construct a FloatDimensionlessVector from an array of FloatDimensionless objects. The FloatDimensionless values are each 105 * expressed in their own unit, but will be internally stored as SI values, all expressed in the displayUnit when printing. 106 * Assume that the StorageType is DENSE since we offer the data as an array. 107 * @param data FloatDimensionless[]; the data for the vector 108 * @param displayUnit DimensionlessUnit; the display unit of the values when printing 109 */ 110 public FloatDimensionlessVector(final FloatDimensionless[] data, final DimensionlessUnit displayUnit) 111 { 112 this(data, displayUnit, StorageType.DENSE); 113 } 114 115 /** 116 * Construct a FloatDimensionlessVector from an array of FloatDimensionless objects. The FloatDimensionless values are each 117 * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. 118 * since we offer the data as an array. 119 * @param data FloatDimensionless[]; the data for the vector 120 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 121 */ 122 public FloatDimensionlessVector(final FloatDimensionless[] data, final StorageType storageType) 123 { 124 this(data, DimensionlessUnit.SI, storageType); 125 } 126 127 /** 128 * Construct a FloatDimensionlessVector from an array of FloatDimensionless objects. The FloatDimensionless values are each 129 * expressed in their own unit, but will be internally stored as SI values, and expressed using SI units when printing. 130 * Assume that the StorageType is DENSE since we offer the data as an array. 131 * @param data FloatDimensionless[]; the data for the vector 132 */ 133 public FloatDimensionlessVector(final FloatDimensionless[] data) 134 { 135 this(data, StorageType.DENSE); 136 } 137 138 /* CONSTRUCTORS WITH List<Float> or List<Dimensionless> */ 139 140 /** 141 * Construct a FloatDimensionlessVector from a list of Number objects or a list of FloatDimensionless objects. Note that the 142 * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or 143 * FloatDimensionless objects. In case the list contains Number objects, the displayUnit indicates the unit in which the 144 * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains 145 * FloatDimensionless objects, each FloatDimensionless has its own unit, and the displayUnit is just used for printing. The 146 * values but will always be internally stored as SI values or base values, and expressed using the display unit or base 147 * unit when printing. 148 * @param data List<Float> or List<Dimensionless>; the data for the vector 149 * @param displayUnit DimensionlessUnit; the display unit of the vector data, and the unit of the data points when the data 150 * is expressed as List<Float> or List<Number> in general 151 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 152 */ 153 public FloatDimensionlessVector(final List<? extends Number> data, final DimensionlessUnit displayUnit, 154 final StorageType storageType) 155 { 156 this(data.size() == 0 ? FloatVectorData.instantiate(new float[] {}, IdentityScale.SCALE, storageType) 157 : data.get(0) instanceof FloatDimensionless 158 ? FloatVectorData.instantiate(data, IdentityScale.SCALE, storageType) 159 : FloatVectorData.instantiate(data, displayUnit.getScale(), storageType), 160 displayUnit); 161 } 162 163 /** 164 * Construct a FloatDimensionlessVector from a list of Number objects or a list of FloatDimensionless objects. Note that the 165 * displayUnit has a different meaning depending on whether the list contains Number objects (e.g., Float objects) or 166 * FloatDimensionless objects. In case the list contains Number objects, the displayUnit indicates the unit in which the 167 * values in the list are expressed, as well as the unit in which they will be printed. In case the list contains 168 * FloatDimensionless objects, each FloatDimensionless has its own unit, and the displayUnit is just used for printing. The 169 * values but will always be internally stored as SI values or base values, and expressed using the display unit or base 170 * unit when printing. Assume the storage type is DENSE since we offer the data as a List. 171 * @param data List<Float> or List<Dimensionless>; the data for the vector 172 * @param displayUnit DimensionlessUnit; the display unit of the vector data, and the unit of the data points when the data 173 * is expressed as List<Float> or List<Number> in general 174 */ 175 public FloatDimensionlessVector(final List<? extends Number> data, final DimensionlessUnit displayUnit) 176 { 177 this(data, displayUnit, StorageType.DENSE); 178 } 179 180 /** 181 * Construct a FloatDimensionlessVector from a list of Number objects or a list of FloatDimensionless objects. When data 182 * contains numbers such as Float, assume that they are expressed using SI units. When the data consists of 183 * FloatDimensionless objects, they each have their own unit, but will be printed using SI units or base units. The values 184 * but will always be internally stored as SI values or base values, and expressed using the display unit or base unit when 185 * printing. 186 * @param data List<Float> or List<Dimensionless>; the data for the vector 187 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 188 */ 189 public FloatDimensionlessVector(final List<? extends Number> data, final StorageType storageType) 190 { 191 this(data, DimensionlessUnit.SI, storageType); 192 } 193 194 /** 195 * Construct a FloatDimensionlessVector from a list of Number objects or a list of FloatDimensionless objects. When data 196 * contains numbers such as Float, assume that they are expressed using SI units. When the data consists of 197 * FloatDimensionless objects, they each have their own unit, but will be printed using SI units or base units. The values 198 * but will always be internally stored as SI values or base values, and expressed using the display unit or base unit when 199 * printing. Assume the storage type is DENSE since we offer the data as a List. 200 * @param data List<Float> or List<Dimensionless>; the data for the vector 201 */ 202 public FloatDimensionlessVector(final List<? extends Number> data) 203 { 204 this(data, StorageType.DENSE); 205 } 206 207 /* CONSTRUCTORS WITH Map<Integer, Float> or Map<Integer, FloatDimensionless> */ 208 209 /** 210 * Construct a FloatDimensionlessVector from a (sparse) map of index values to Number objects or a (sparse) map of index 211 * values to of FloatDimensionless objects. Using index values is particularly useful for sparse vectors. The size parameter 212 * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit 213 * has a different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatDimensionless 214 * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are 215 * expressed, as well as the unit in which they will be printed. In case the map contains FloatDimensionless objects, each 216 * FloatDimensionless has its own unit, and the displayUnit is just used for printing. The values but will always be 217 * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. 218 * @param data Map<Integer, Float> or Map<Integer, FloatDimensionless>; the data for the vector 219 * @param size int; the size off the vector, i.e., the highest index 220 * @param displayUnit DimensionlessUnit; the display unit of the vector data, and the unit of the data points when the data 221 * is expressed as List<Float> or List<Number> in general 222 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 223 */ 224 public FloatDimensionlessVector(final Map<Integer, ? extends Number> data, final int size, 225 final DimensionlessUnit displayUnit, final StorageType storageType) 226 { 227 this(data.size() == 0 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 228 : data.values().iterator().next() instanceof FloatDimensionless 229 ? FloatVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 230 : FloatVectorData.instantiate(data, size, displayUnit.getScale(), storageType), 231 displayUnit); 232 } 233 234 /** 235 * Construct a FloatDimensionlessVector from a (sparse) map of index values to Number objects or a (sparse) map of index 236 * values to of FloatDimensionless objects. Using index values is particularly useful for sparse vectors. The size parameter 237 * indicates the size of the vector, since the largest index does not have to be part of the map. Note that the displayUnit 238 * has a different meaning depending on whether the map contains Number objects (e.g., Float objects) or FloatDimensionless 239 * objects. In case the map contains Number objects, the displayUnit indicates the unit in which the values in the map are 240 * expressed, as well as the unit in which they will be printed. In case the map contains FloatDimensionless objects, each 241 * FloatDimensionless has its own unit, and the displayUnit is just used for printing. The values but will always be 242 * internally stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume 243 * the storage type is SPARSE since we offer the data as a Map. 244 * @param data Map<Integer, Float> or Map<Integer, FloatDimensionless>; the data for the vector 245 * @param size int; the size off the vector, i.e., the highest index 246 * @param displayUnit DimensionlessUnit; the display unit of the vector data, and the unit of the data points when the data 247 * is expressed as List<Float> or List<Number> in general 248 */ 249 public FloatDimensionlessVector(final Map<Integer, ? extends Number> data, final int size, 250 final DimensionlessUnit displayUnit) 251 { 252 this(data, size, displayUnit, StorageType.SPARSE); 253 } 254 255 /** 256 * Construct a FloatDimensionlessVector from a (sparse) map of index values to Number objects or a (sparse) map of index 257 * values to of FloatDimensionless objects. Using index values is particularly useful for sparse vectors. The size parameter 258 * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers 259 * such as Float, assume that they are expressed using SI units. When the data consists of FloatDimensionless objects, they 260 * each have their own unit, but will be printed using SI units or base units. The values but will always be internally 261 * stored as SI values or base values, and expressed using the display unit or base unit when printing. 262 * @param data Map<Integer, Float> or Map<Integer, FloatDimensionless>; the data for the vector 263 * @param size int; the size off the vector, i.e., the highest index 264 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 265 */ 266 public FloatDimensionlessVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType) 267 { 268 this(data, size, DimensionlessUnit.SI, storageType); 269 } 270 271 /** 272 * Construct a FloatDimensionlessVector from a (sparse) map of index values to Number objects or a (sparse) map of index 273 * values to of FloatDimensionless objects. Using index values is particularly useful for sparse vectors. The size parameter 274 * indicates the size of the vector, since the largest index does not have to be part of the map. When data contains numbers 275 * such as Float, assume that they are expressed using SI units. When the data consists of FloatDimensionless objects, they 276 * each have their own unit, but will be printed using SI units or base units. The values but will always be internally 277 * stored as SI values or base values, and expressed using the display unit or base unit when printing. Assume the storage 278 * type is SPARSE since we offer the data as a Map. 279 * @param data Map<Integer, Float> or Map<Integer, FloatDimensionless>; the data for the vector 280 * @param size int; the size off the vector, i.e., the highest index 281 */ 282 public FloatDimensionlessVector(final Map<Integer, ? extends Number> data, final int size) 283 { 284 this(data, size, StorageType.SPARSE); 285 } 286 287 /* ****************************** Other methods ****************************** */ 288 289 @Override 290 public Class<FloatDimensionless> getScalarClass() 291 { 292 return FloatDimensionless.class; 293 } 294 295 @Override 296 public FloatDimensionlessVector instantiateVector(final FloatVectorData fvd, final DimensionlessUnit displayUnit) 297 { 298 return new FloatDimensionlessVector(fvd, displayUnit); 299 } 300 301 @Override 302 public FloatDimensionless instantiateScalarSI(final float valueSI, final DimensionlessUnit displayUnit) 303 { 304 FloatDimensionless result = FloatDimensionless.instantiateSI(valueSI); 305 result.setDisplayUnit(displayUnit); 306 return result; 307 } 308 309 @Override 310 public final FloatDimensionlessVector acos() 311 { 312 assign(FloatMathFunctions.ACOS); 313 return this; 314 } 315 316 @Override 317 public final FloatDimensionlessVector asin() 318 { 319 assign(FloatMathFunctions.ASIN); 320 return this; 321 } 322 323 @Override 324 public final FloatDimensionlessVector atan() 325 { 326 assign(FloatMathFunctions.ATAN); 327 return this; 328 } 329 330 @Override 331 public final FloatDimensionlessVector cbrt() 332 { 333 assign(FloatMathFunctions.CBRT); 334 return this; 335 } 336 337 @Override 338 public final FloatDimensionlessVector cos() 339 { 340 assign(FloatMathFunctions.COS); 341 return this; 342 } 343 344 @Override 345 public final FloatDimensionlessVector cosh() 346 { 347 assign(FloatMathFunctions.COSH); 348 return this; 349 } 350 351 @Override 352 public final FloatDimensionlessVector exp() 353 { 354 assign(FloatMathFunctions.EXP); 355 return this; 356 } 357 358 @Override 359 public final FloatDimensionlessVector expm1() 360 { 361 assign(FloatMathFunctions.EXPM1); 362 return this; 363 } 364 365 @Override 366 public final FloatDimensionlessVector log() 367 { 368 assign(FloatMathFunctions.LOG); 369 return this; 370 } 371 372 @Override 373 public final FloatDimensionlessVector log10() 374 { 375 assign(FloatMathFunctions.LOG10); 376 return this; 377 } 378 379 @Override 380 public final FloatDimensionlessVector log1p() 381 { 382 assign(FloatMathFunctions.LOG1P); 383 return this; 384 } 385 386 @Override 387 public final FloatDimensionlessVector pow(final double x) 388 { 389 assign(FloatMathFunctions.POW((float) x)); 390 return this; 391 } 392 393 @Override 394 public final FloatDimensionlessVector signum() 395 { 396 assign(FloatMathFunctions.SIGNUM); 397 return this; 398 } 399 400 @Override 401 public final FloatDimensionlessVector sin() 402 { 403 assign(FloatMathFunctions.SIN); 404 return this; 405 } 406 407 @Override 408 public final FloatDimensionlessVector sinh() 409 { 410 assign(FloatMathFunctions.SINH); 411 return this; 412 } 413 414 @Override 415 public final FloatDimensionlessVector sqrt() 416 { 417 assign(FloatMathFunctions.SQRT); 418 return this; 419 } 420 421 @Override 422 public final FloatDimensionlessVector tan() 423 { 424 assign(FloatMathFunctions.TAN); 425 return this; 426 } 427 428 @Override 429 public final FloatDimensionlessVector tanh() 430 { 431 assign(FloatMathFunctions.TANH); 432 return this; 433 } 434 435 @Override 436 public final FloatDimensionlessVector inv() 437 { 438 assign(FloatMathFunctions.INV); 439 return this; 440 } 441 442 }