1 package org.djunits.value.vdouble.scalar;
2
3 import java.util.Locale;
4
5 import org.djunits.unit.AbsorbedDoseUnit;
6 import org.djunits.unit.AccelerationUnit;
7 import org.djunits.unit.AmountOfSubstanceUnit;
8 import org.djunits.unit.AngleUnit;
9 import org.djunits.unit.AreaUnit;
10 import org.djunits.unit.CatalyticActivityUnit;
11 import org.djunits.unit.DensityUnit;
12 import org.djunits.unit.DimensionlessUnit;
13 import org.djunits.unit.DurationUnit;
14 import org.djunits.unit.ElectricalCapacitanceUnit;
15 import org.djunits.unit.ElectricalChargeUnit;
16 import org.djunits.unit.ElectricalConductanceUnit;
17 import org.djunits.unit.ElectricalCurrentUnit;
18 import org.djunits.unit.ElectricalInductanceUnit;
19 import org.djunits.unit.ElectricalPotentialUnit;
20 import org.djunits.unit.ElectricalResistanceUnit;
21 import org.djunits.unit.EnergyUnit;
22 import org.djunits.unit.EquivalentDoseUnit;
23 import org.djunits.unit.FlowMassUnit;
24 import org.djunits.unit.FlowVolumeUnit;
25 import org.djunits.unit.ForceUnit;
26 import org.djunits.unit.FrequencyUnit;
27 import org.djunits.unit.IlluminanceUnit;
28 import org.djunits.unit.LengthUnit;
29 import org.djunits.unit.LinearDensityUnit;
30 import org.djunits.unit.LuminousFluxUnit;
31 import org.djunits.unit.LuminousIntensityUnit;
32 import org.djunits.unit.MagneticFluxDensityUnit;
33 import org.djunits.unit.MagneticFluxUnit;
34 import org.djunits.unit.MassUnit;
35 import org.djunits.unit.PowerUnit;
36 import org.djunits.unit.PressureUnit;
37 import org.djunits.unit.RadioActivityUnit;
38 import org.djunits.unit.SolidAngleUnit;
39 import org.djunits.unit.SpeedUnit;
40 import org.djunits.unit.TemperatureUnit;
41 import org.djunits.unit.TorqueUnit;
42 import org.djunits.unit.VolumeUnit;
43 import org.djunits.value.function.DimensionlessFunctions;
44 import org.djunits.value.vdouble.scalar.base.DoubleScalarRel;
45 import org.djutils.base.NumberParser;
46 import org.djutils.exceptions.Throw;
47
48 import jakarta.annotation.Generated;
49
50
51
52
53
54
55
56
57
58
59 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z")
60 public class Dimensionless extends DoubleScalarRel<DimensionlessUnit, Dimensionless>
61 implements DimensionlessFunctions<DimensionlessUnit, Dimensionless>
62 {
63
64 private static final long serialVersionUID = 20150905L;
65
66
67 public static final Dimensionless ZERO = new Dimensionless(0.0, DimensionlessUnit.SI);
68
69
70 public static final Dimensionless ONE = new Dimensionless(1.0, DimensionlessUnit.SI);
71
72
73 @SuppressWarnings("checkstyle:constantname")
74 public static final Dimensionless NaN = new Dimensionless(Double.NaN, DimensionlessUnit.SI);
75
76
77 public static final Dimensionless POSITIVE_INFINITY = new Dimensionless(Double.POSITIVE_INFINITY, DimensionlessUnit.SI);
78
79
80 public static final Dimensionless NEGATIVE_INFINITY = new Dimensionless(Double.NEGATIVE_INFINITY, DimensionlessUnit.SI);
81
82
83 public static final Dimensionless POS_MAXVALUE = new Dimensionless(Double.MAX_VALUE, DimensionlessUnit.SI);
84
85
86 public static final Dimensionless NEG_MAXVALUE = new Dimensionless(-Double.MAX_VALUE, DimensionlessUnit.SI);
87
88
89
90
91
92
93 public Dimensionless(final double value, final DimensionlessUnit unit)
94 {
95 super(value, unit);
96 }
97
98
99
100
101
102 public Dimensionless(final Dimensionless value)
103 {
104 super(value);
105 }
106
107 @Override
108 public final Dimensionless instantiateRel(final double value, final DimensionlessUnit unit)
109 {
110 return new Dimensionless(value, unit);
111 }
112
113
114
115
116
117
118 public static final Dimensionless instantiateSI(final double value)
119 {
120 return new Dimensionless(value, DimensionlessUnit.SI);
121 }
122
123
124
125
126
127
128
129
130 public static Dimensionless interpolate(final Dimensionless zero, final Dimensionless one, final double ratio)
131 {
132 return new Dimensionless(zero.getInUnit() * (1 - ratio) + one.getInUnit(zero.getDisplayUnit()) * ratio,
133 zero.getDisplayUnit());
134 }
135
136
137
138
139
140
141
142 public static Dimensionless max(final Dimensionless r1, final Dimensionless r2)
143 {
144 return r1.gt(r2) ? r1 : r2;
145 }
146
147
148
149
150
151
152
153
154 public static Dimensionless max(final Dimensionless r1, final Dimensionless r2, final Dimensionless... rn)
155 {
156 Dimensionless maxr = r1.gt(r2) ? r1 : r2;
157 for (Dimensionless r : rn)
158 {
159 if (r.gt(maxr))
160 {
161 maxr = r;
162 }
163 }
164 return maxr;
165 }
166
167
168
169
170
171
172
173 public static Dimensionless min(final Dimensionless r1, final Dimensionless r2)
174 {
175 return r1.lt(r2) ? r1 : r2;
176 }
177
178
179
180
181
182
183
184
185 public static Dimensionless min(final Dimensionless r1, final Dimensionless r2, final Dimensionless... rn)
186 {
187 Dimensionless minr = r1.lt(r2) ? r1 : r2;
188 for (Dimensionless r : rn)
189 {
190 if (r.lt(minr))
191 {
192 minr = r;
193 }
194 }
195 return minr;
196 }
197
198
199
200
201
202
203
204
205
206
207 public static Dimensionless valueOf(final String text)
208 {
209 Throw.whenNull(text, "Error parsing Dimensionless: text to parse is null");
210 Throw.when(text.length() == 0, IllegalArgumentException.class, "Error parsing Dimensionless: empty text to parse");
211 try
212 {
213 NumberParser numberParser = new NumberParser().lenient().trailing();
214 double d = numberParser.parseDouble(text);
215 String unitString = text.substring(numberParser.getTrailingPosition()).trim();
216 if (unitString.length() != 0)
217 throw new IllegalArgumentException("Unit " + unitString + " not found for Dimensionless");
218 return new Dimensionless(d, DimensionlessUnit.SI);
219 }
220 catch (Exception exception)
221 {
222 throw new IllegalArgumentException(
223 "Error parsing Dimensionless from " + text + " using Locale " + Locale.getDefault(Locale.Category.FORMAT),
224 exception);
225 }
226 }
227
228
229
230
231
232
233
234
235
236 public static Dimensionless of(final double value, final String unitString)
237 {
238 Throw.whenNull(unitString, "Error parsing Dimensionless: unitString is null");
239 Throw.when(unitString.trim().length() != 0, IllegalArgumentException.class,
240 "Error parsing Dimensionless: non-empty unitString");
241 DimensionlessUnit unit = DimensionlessUnit.SI;
242 return new Dimensionless(value, unit);
243 }
244
245 @Override
246 public String toStringSIPrefixed(final int smallestPower, final int biggestPower)
247 {
248 return toString();
249 }
250
251 @Override
252 public final Dimensionless acos()
253 {
254 return instantiateRel(Math.acos(getInUnit()), getDisplayUnit());
255 }
256
257 @Override
258 public final Dimensionless asin()
259 {
260 return instantiateRel(Math.asin(getInUnit()), getDisplayUnit());
261 }
262
263 @Override
264 public final Dimensionless atan()
265 {
266 return instantiateRel(Math.atan(getInUnit()), getDisplayUnit());
267 }
268
269 @Override
270 public final Dimensionless cbrt()
271 {
272 return instantiateRel(Math.cbrt(getInUnit()), getDisplayUnit());
273 }
274
275 @Override
276 public final Dimensionless cos()
277 {
278 return instantiateRel(Math.cos(getInUnit()), getDisplayUnit());
279 }
280
281 @Override
282 public final Dimensionless cosh()
283 {
284 return instantiateRel(Math.cosh(getInUnit()), getDisplayUnit());
285 }
286
287 @Override
288 public final Dimensionless exp()
289 {
290 return instantiateRel(Math.exp(getInUnit()), getDisplayUnit());
291 }
292
293 @Override
294 public final Dimensionless expm1()
295 {
296 return instantiateRel(Math.expm1(getInUnit()), getDisplayUnit());
297 }
298
299 @Override
300 public final Dimensionless log()
301 {
302 return instantiateRel(Math.log(getInUnit()), getDisplayUnit());
303 }
304
305 @Override
306 public final Dimensionless log10()
307 {
308 return instantiateRel(Math.log10(getInUnit()), getDisplayUnit());
309 }
310
311 @Override
312 public final Dimensionless log1p()
313 {
314 return instantiateRel(Math.log1p(getInUnit()), getDisplayUnit());
315 }
316
317 @Override
318 public final Dimensionless pow(final double x)
319 {
320 return instantiateRel(Math.pow(getInUnit(), x), getDisplayUnit());
321 }
322
323 @Override
324 public final Dimensionless signum()
325 {
326 return instantiateRel(Math.signum(getInUnit()), getDisplayUnit());
327 }
328
329 @Override
330 public final Dimensionless sin()
331 {
332 return instantiateRel(Math.sin(getInUnit()), getDisplayUnit());
333 }
334
335 @Override
336 public final Dimensionless sinh()
337 {
338 return instantiateRel(Math.sinh(getInUnit()), getDisplayUnit());
339 }
340
341 @Override
342 public final Dimensionless sqrt()
343 {
344 return instantiateRel(Math.sqrt(getInUnit()), getDisplayUnit());
345 }
346
347 @Override
348 public final Dimensionless tan()
349 {
350 return instantiateRel(Math.tan(getInUnit()), getDisplayUnit());
351 }
352
353 @Override
354 public final Dimensionless tanh()
355 {
356 return instantiateRel(Math.tanh(getInUnit()), getDisplayUnit());
357 }
358
359 @Override
360 public final Dimensionless inv()
361 {
362 return instantiateRel(1.0 / getInUnit(), getDisplayUnit());
363 }
364
365
366
367
368
369
370 public final Dimensionless divide(final Dimensionless v)
371 {
372 return new Dimensionless(this.si / v.si, DimensionlessUnit.SI);
373 }
374
375
376
377
378
379
380 public final AbsorbedDose times(final AbsorbedDose v)
381 {
382 return new AbsorbedDose(this.si * v.si, AbsorbedDoseUnit.SI);
383 }
384
385
386
387
388
389
390 public final Acceleration times(final Acceleration v)
391 {
392 return new Acceleration(this.si * v.si, AccelerationUnit.SI);
393 }
394
395
396
397
398
399
400 public final AmountOfSubstance times(final AmountOfSubstance v)
401 {
402 return new AmountOfSubstance(this.si * v.si, AmountOfSubstanceUnit.SI);
403 }
404
405
406
407
408
409
410 public final Angle times(final Angle v)
411 {
412 return new Angle(this.si * v.si, AngleUnit.SI);
413 }
414
415
416
417
418
419
420 public final SolidAngle times(final SolidAngle v)
421 {
422 return new SolidAngle(this.si * v.si, SolidAngleUnit.SI);
423 }
424
425
426
427
428
429
430 public final Area times(final Area v)
431 {
432 return new Area(this.si * v.si, AreaUnit.SI);
433 }
434
435
436
437
438
439
440 public final CatalyticActivity times(final CatalyticActivity v)
441 {
442 return new CatalyticActivity(this.si * v.si, CatalyticActivityUnit.SI);
443 }
444
445
446
447
448
449
450 public final Density times(final Density v)
451 {
452 return new Density(this.si * v.si, DensityUnit.SI);
453 }
454
455
456
457
458
459
460 public final Dimensionless times(final Dimensionless v)
461 {
462 return new Dimensionless(this.si * v.si, DimensionlessUnit.SI);
463 }
464
465
466
467
468
469
470 public final ElectricalCapacitance times(final ElectricalCapacitance v)
471 {
472 return new ElectricalCapacitance(this.si * v.si, ElectricalCapacitanceUnit.SI);
473 }
474
475
476
477
478
479
480 public final ElectricalCharge times(final ElectricalCharge v)
481 {
482 return new ElectricalCharge(this.si * v.si, ElectricalChargeUnit.SI);
483 }
484
485
486
487
488
489
490 public final ElectricalConductance times(final ElectricalConductance v)
491 {
492 return new ElectricalConductance(this.si * v.si, ElectricalConductanceUnit.SI);
493 }
494
495
496
497
498
499
500 public final ElectricalCurrent times(final ElectricalCurrent v)
501 {
502 return new ElectricalCurrent(this.si * v.si, ElectricalCurrentUnit.SI);
503 }
504
505
506
507
508
509
510 public final ElectricalInductance times(final ElectricalInductance v)
511 {
512 return new ElectricalInductance(this.si * v.si, ElectricalInductanceUnit.SI);
513 }
514
515
516
517
518
519
520 public final ElectricalPotential times(final ElectricalPotential v)
521 {
522 return new ElectricalPotential(this.si * v.si, ElectricalPotentialUnit.SI);
523 }
524
525
526
527
528
529
530 public final ElectricalResistance times(final ElectricalResistance v)
531 {
532 return new ElectricalResistance(this.si * v.si, ElectricalResistanceUnit.SI);
533 }
534
535
536
537
538
539
540 public final Energy times(final Energy v)
541 {
542 return new Energy(this.si * v.si, EnergyUnit.SI);
543 }
544
545
546
547
548
549
550 public final EquivalentDose times(final EquivalentDose v)
551 {
552 return new EquivalentDose(this.si * v.si, EquivalentDoseUnit.SI);
553 }
554
555
556
557
558
559
560 public final FlowMass times(final FlowMass v)
561 {
562 return new FlowMass(this.si * v.si, FlowMassUnit.SI);
563 }
564
565
566
567
568
569
570 public final FlowVolume times(final FlowVolume v)
571 {
572 return new FlowVolume(this.si * v.si, FlowVolumeUnit.SI);
573 }
574
575
576
577
578
579
580 public final Force times(final Force v)
581 {
582 return new Force(this.si * v.si, ForceUnit.SI);
583 }
584
585
586
587
588
589
590 public final Frequency times(final Frequency v)
591 {
592 return new Frequency(this.si * v.si, FrequencyUnit.SI);
593 }
594
595
596
597
598
599
600 public final Illuminance times(final Illuminance v)
601 {
602 return new Illuminance(this.si * v.si, IlluminanceUnit.SI);
603 }
604
605
606
607
608
609
610 public final Length times(final Length v)
611 {
612 return new Length(this.si * v.si, LengthUnit.SI);
613 }
614
615
616
617
618
619
620 public final LinearDensity times(final LinearDensity v)
621 {
622 return new LinearDensity(this.si * v.si, LinearDensityUnit.SI);
623 }
624
625
626
627
628
629
630 public final LuminousFlux times(final LuminousFlux v)
631 {
632 return new LuminousFlux(this.si * v.si, LuminousFluxUnit.SI);
633 }
634
635
636
637
638
639
640 public final LuminousIntensity times(final LuminousIntensity v)
641 {
642 return new LuminousIntensity(this.si * v.si, LuminousIntensityUnit.SI);
643 }
644
645
646
647
648
649
650 public final MagneticFluxDensity times(final MagneticFluxDensity v)
651 {
652 return new MagneticFluxDensity(this.si * v.si, MagneticFluxDensityUnit.SI);
653 }
654
655
656
657
658
659
660 public final MagneticFlux times(final MagneticFlux v)
661 {
662 return new MagneticFlux(this.si * v.si, MagneticFluxUnit.SI);
663 }
664
665
666
667
668
669
670 public final Mass times(final Mass v)
671 {
672 return new Mass(this.si * v.si, MassUnit.SI);
673 }
674
675
676
677
678
679
680 public final Power times(final Power v)
681 {
682 return new Power(this.si * v.si, PowerUnit.SI);
683 }
684
685
686
687
688
689
690 public final Pressure times(final Pressure v)
691 {
692 return new Pressure(this.si * v.si, PressureUnit.SI);
693 }
694
695
696
697
698
699
700 public final RadioActivity times(final RadioActivity v)
701 {
702 return new RadioActivity(this.si * v.si, RadioActivityUnit.SI);
703 }
704
705
706
707
708
709
710 public final Speed times(final Speed v)
711 {
712 return new Speed(this.si * v.si, SpeedUnit.SI);
713 }
714
715
716
717
718
719
720 public final Temperature times(final Temperature v)
721 {
722 return new Temperature(this.si * v.si, TemperatureUnit.SI);
723 }
724
725
726
727
728
729
730 public final Duration times(final Duration v)
731 {
732 return new Duration(this.si * v.si, DurationUnit.SI);
733 }
734
735
736
737
738
739
740 public final Torque times(final Torque v)
741 {
742 return new Torque(this.si * v.si, TorqueUnit.SI);
743 }
744
745
746
747
748
749
750 public final Volume times(final Volume v)
751 {
752 return new Volume(this.si * v.si, VolumeUnit.SI);
753 }
754
755
756
757
758
759
760 public final LinearDensity divide(final Length v)
761 {
762 return new LinearDensity(this.si / v.si, LinearDensityUnit.SI);
763 }
764
765
766
767
768
769
770 public final Length divide(final LinearDensity v)
771 {
772 return new Length(this.si / v.si, LengthUnit.SI);
773 }
774
775
776
777
778
779
780 public final Frequency divide(final Duration v)
781 {
782 return new Frequency(this.si / v.si, FrequencyUnit.SI);
783 }
784
785
786
787
788
789
790 public final Duration divide(final Frequency v)
791 {
792 return new Duration(this.si / v.si, DurationUnit.SI);
793 }
794
795
796
797
798
799
800 public final ElectricalResistance divide(final ElectricalConductance v)
801 {
802 return new ElectricalResistance(this.si / v.si, ElectricalResistanceUnit.SI);
803 }
804
805
806
807
808
809
810 public final ElectricalConductance divide(final ElectricalResistance v)
811 {
812 return new ElectricalConductance(this.si / v.si, ElectricalConductanceUnit.SI);
813 }
814
815 @Override
816 public Dimensionless reciprocal()
817 {
818 return Dimensionless.instantiateSI(1.0 / this.si);
819 }
820
821 }