Arcane  v3.16.2.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
VariableDataTypeTraits.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* VariableDataTypeTraits.h (C) 2000-2025 */
9/* */
10/* Classes spécialisées pour caractériser les types de données. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_VARIABLEDATATYPETRAITS_H
13#define ARCANE_CORE_VARIABLEDATATYPETRAITS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/ValueConvert.h"
19#include "arcane/utils/BFloat16.h"
20#include "arcane/utils/Float16.h"
21#include "arcane/utils/Float128.h"
22#include "arcane/utils/Int128.h"
23
25
26#include <cmath>
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
39template <typename DataType> inline void
40builtInDumpValue(String& s, const DataType& v)
41{
42 std::ostringstream sbuf;
43 sbuf << v << '\0';
44 s = sbuf.str();
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
55template <typename DataType>
57{
58 public:
59
60 static eDataType type() { return DT_Unknown; }
61};
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
72template <>
73class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Byte>
74{
75 public:
76
78 typedef Byte Type;
79
82
85
88
91
92 typedef Byte BasicType;
93
94 static constexpr Integer nbBasicType() { return 1; }
95
96 typedef Byte NormType;
97
98 public:
99
101 static constexpr const char* typeName() { return "Byte"; }
103 static constexpr eDataType type() { return DT_Byte; }
105 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
111 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
112
113 static bool verifDifferent(Byte v1, Byte v2, Byte& diff,
114 [[maybe_unused]] bool is_nan_equal = false)
115 {
116 return _verifDifferent(v1, v2, diff, v1);
117 }
118 static bool verifDifferentNorm(Type v1, Type v2, Type& diff, Type norm,
119 [[maybe_unused]] bool is_nan_equal = false)
120 {
121 return _verifDifferent(v1, v2, diff, norm);
122 }
123
124 static NormType normeMax(Byte v)
125 {
126 return static_cast<Byte>(math::abs(v));
127 }
128
129 private:
130
131 static bool _verifDifferent(Type v1, Type v2, Type& diff, Type divider)
132 {
133 if (v1 != v2) {
134 auto abs_diff = v1 - v2;
135 if (!math::isZero(divider))
136 abs_diff = abs_diff / divider;
137 diff = static_cast<Byte>(diff);
138 return true;
139 }
140 return false;
141 }
142};
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
150template <>
151class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Real>
152{
153 public:
154
156 typedef Real Type;
157
159 typedef TrueType HasDump;
160
162 typedef TrueType HasReduce;
163
165 typedef TrueType HasReduceMinMax;
166
168 typedef TrueType IsNumeric;
169
170 typedef Real BasicType;
171
172 static constexpr Integer nbBasicType() { return 1; }
173
174 typedef Real NormType;
175
176 public:
177
179 static constexpr const char* typeName() { return "Real"; }
181 static constexpr eDataType type() { return DT_Real; }
183 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
189 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
190
191 static bool verifDifferentNorm(Type v1, Type v2, Type& diff, Type norm, bool is_nan_equal = false)
192 {
193 return _verifDifferent(v1, v2, diff, norm, is_nan_equal);
194 }
195
196 static bool verifDifferent(Type v1, Type v2, Type& diff, bool is_nan_equal = false)
197 {
198 return _verifDifferent(v1, v2, diff, v1, is_nan_equal);
199 }
200
201 static NormType normeMax(Real v)
202 {
203 return math::abs(v);
204 }
205
206 private:
207
208 static bool _verifDifferent(Type v1, Type v2, Type& diff, Type divider, bool is_nan_equal)
209 {
210 if (is_nan_equal) {
211 if (std::isnan(v1) && std::isnan(v2))
212 return false;
213 }
214 // Vérifie avant de les comparer que les deux nombres sont valides
215 // pour éviter une exception flottante sur certaines plates-formes
216 if (platform::isDenormalized(v1) || platform::isDenormalized(v2)) {
217 diff = 1.0;
218 return true;
219 }
220 if (v1 != v2) {
221 if (math::abs(divider) < 1.e-100) // TH: plantait pour v1 tres petit(math::isZero(v1))
222 diff = v1 - v2;
223 else
224 diff = (v1 - v2) / divider;
225 return true;
226 }
227 return false;
228 }
229};
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
237template <>
238class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Float128>
239{
240 public:
241
243 typedef Float128 Type;
244
247
250
253
256
257 typedef Float128 BasicType;
258
259 static constexpr Int32 nbBasicType() { return 1; }
260
261 typedef Float128 NormType;
262
263 public:
264
266 static constexpr const char* typeName() { return "Float128"; }
268 static constexpr eDataType type() { return DT_Float128; }
270 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
276 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
277
278 static bool verifDifferent(Type v1, Type v2, Type& diff, [[maybe_unused]] bool is_nan_equal = false)
279 {
280 return _verifDifferent(v1, v2, diff, v1);
281 }
282
283 static bool verifDifferentNorm(Type v1, Type v2, Type& diff, NormType norm, [[maybe_unused]] bool is_nan_equal)
284 {
285 return _verifDifferent(v1, v2, diff, norm);
286 }
287
288 static NormType normeMax(Float128 v)
289 {
290 return math::abs(v);
291 }
292
293 private:
294
295 static bool _verifDifferent(Type v1, Type v2, Type& diff, Type divider)
296 {
297 if (v1 != v2) {
298 if (math::abs(divider) < 1.e-100) // TH: plantait pour v1 tres petit(math::isZero(v1))
299 diff = v1 - v2;
300 else
301 diff = (v1 - v2) / divider;
302 return true;
303 }
304 return false;
305 }
306};
307
308/*---------------------------------------------------------------------------*/
309/*---------------------------------------------------------------------------*/
314template <>
315class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Int8>
316{
317 public:
318
320 typedef Int8 Type;
321
324
327
330
333
334 typedef Int8 BasicType;
335
336 static constexpr Int32 nbBasicType() { return 1; }
337
338 typedef Int8 NormType;
339
340 public:
341
343 static constexpr const char* typeName() { return "Int8"; }
345 static constexpr eDataType type() { return DT_Int8; }
347 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
353 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
354 static bool verifDifferent(Int8 v1, Int8 v2, Int8& diff,
355 [[maybe_unused]] bool is_nan_equal = false)
356 {
357 if (v1 != v2) {
358 if (math::isZero(v1))
359 diff = (Int8)(v1 - v2);
360 else
361 diff = (Int8)((v1 - v2) / v1);
362 return true;
363 }
364 return false;
365 }
366 static bool verifDifferentNorm(Type v1, Type v2, Type& diff,
367 [[maybe_unused]] NormType norm,
368 [[maybe_unused]] bool is_nan_equal = false)
369 {
370 return verifDifferent(v1, v2, diff, is_nan_equal);
371 }
372 static NormType normeMax(Int8 v)
373 {
374 return static_cast<Int8>(math::abs(v));
375 }
376};
377
378/*---------------------------------------------------------------------------*/
379/*---------------------------------------------------------------------------*/
384template <>
385class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Int16>
386{
387 public:
388
390 typedef Int16 Type;
391
394
397
400
403
404 typedef Int16 BasicType;
405
406 static constexpr Integer nbBasicType() { return 1; }
407
408 typedef Int16 NormType;
409
410 public:
411
413 static constexpr const char* typeName() { return "Int16"; }
415 static constexpr eDataType type() { return DT_Int16; }
417 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
423 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
424 static bool verifDifferent(Int16 v1, Int16 v2, Int16& diff,
425 [[maybe_unused]] bool is_nan_equal = false)
426 {
427 if (v1 != v2) {
428 if (math::isZero(v1))
429 diff = (Int16)(v1 - v2);
430 else
431 diff = (Int16)((v1 - v2) / v1);
432 return true;
433 }
434 return false;
435 }
436 static bool verifDifferentNorm(Type v1, Type v2, Type& diff,
437 [[maybe_unused]] NormType norm,
438 [[maybe_unused]] bool is_nan_equal = false)
439 {
440 return verifDifferent(v1, v2, diff, is_nan_equal);
441 }
442 static NormType normeMax(Int16 v)
443 {
444 return math::abs(v);
445 }
446};
447
448/*---------------------------------------------------------------------------*/
449/*---------------------------------------------------------------------------*/
454template <>
455class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Int32>
456{
457 public:
458
460 typedef Int32 Type;
461
464
467
470
473
474 typedef Int32 BasicType;
475
476 static constexpr Integer nbBasicType() { return 1; }
477
478 typedef Int32 NormType;
479
480 public:
481
483 static constexpr const char* typeName() { return "Int32"; }
485 static constexpr eDataType type() { return DT_Int32; }
487 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
493 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
494 static bool verifDifferent(Int32 v1, Int32 v2, Int32& diff,
495 [[maybe_unused]] bool is_nan_equal = false)
496 {
497 if (v1 != v2) {
498 if (math::isZero(v1))
499 diff = v1 - v2;
500 else
501 diff = (v1 - v2) / v1;
502 return true;
503 }
504 return false;
505 }
506 static bool verifDifferentNorm(Type v1, Type v2, Type& diff,
507 [[maybe_unused]] NormType norm,
508 [[maybe_unused]] bool is_nan_equal = false)
509 {
510 return verifDifferent(v1, v2, diff, is_nan_equal);
511 }
512
513 static NormType normeMax(Int32 v)
514 {
515 return math::abs(v);
516 }
517};
518
519/*---------------------------------------------------------------------------*/
520/*---------------------------------------------------------------------------*/
525template <>
526class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Int64>
527{
528 public:
529
531 typedef Int64 Type;
532
535
538
541
544
545 typedef Int64 BasicType;
546
547 static constexpr Integer nbBasicType() { return 1; }
548
549 typedef Int64 NormType;
550
551 public:
552
554 static constexpr const char* typeName() { return "Int64"; }
556 static constexpr eDataType type() { return DT_Int64; }
558 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
564 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
565
566 static bool verifDifferent(Type v1, Type v2, Type& diff,
567 [[maybe_unused]] bool is_nan_equal = false)
568 {
569 if (v1 != v2) {
570 if (math::isZero(v1))
571 diff = v1 - v2;
572 else
573 diff = (v1 - v2) / v1;
574 return true;
575 }
576 return false;
577 }
578
579 static bool verifDifferentNorm(Type v1, Type v2, Type& diff,
580 [[maybe_unused]] NormType norm,
581 [[maybe_unused]] bool is_nan_equal = false)
582 {
583 return verifDifferent(v1, v2, diff, is_nan_equal);
584 }
585
586 static NormType normeMax(Int64 v)
587 {
588 return v;
589 }
590};
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
598template <>
599class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Int128>
600{
601 public:
602
604 typedef Int128 Type;
605
608
611
614
617
618 typedef Int128 BasicType;
619
620 static constexpr Int32 nbBasicType() { return 1; }
621
622 typedef Int128 NormType;
623
624 public:
625
627 static constexpr const char* typeName() { return "Int128"; }
629 static constexpr eDataType type() { return DT_Int128; }
631 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
637 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
638
639 static bool verifDifferent(Type v1, Type v2, Type& diff,
640 [[maybe_unused]] bool is_nan_equal = false)
641 {
642 if (v1 != v2) {
643 if (math::isZero(v1))
644 diff = v1 - v2;
645 else
646 diff = (v1 - v2) / v1;
647 return true;
648 }
649 return false;
650 }
651
652 static bool verifDifferentNorm(Type v1, Type v2, Type& diff,
653 [[maybe_unused]] NormType norm,
654 [[maybe_unused]] bool is_nan_equal = false)
655 {
656 return verifDifferent(v1, v2, diff, is_nan_equal);
657 }
658
659 static NormType normeMax(Int16 v)
660 {
661 return static_cast<Int16>(math::abs(v));
662 }
663};
664
665/*---------------------------------------------------------------------------*/
666/*---------------------------------------------------------------------------*/
671template <>
672class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<String>
673{
674 public:
675
677 typedef String Type;
678
681
684
687
690
691 typedef String BasicType;
692
693 // Uniquement utilisé pour compiler les routines de comparaison de valeurs.
694 using NormType = String;
695
696 static constexpr Integer nbBasicType() { return 1; }
697
698 public:
699
701 static constexpr const char* typeName() { return "String"; }
703 static constexpr eDataType type() { return DT_String; }
705 static void dumpValue(String& s, const Type& v) { s = v; }
711 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
712
713 static bool verifDifferent(const Type v1, const Type& v2, Type& diff,
714 [[maybe_unused]] bool is_nan_equal = false)
715 {
716 diff = v1;
717 return (v1 != v2);
718 }
719 static bool verifDifferentNorm(const Type v1, const Type& v2, Type& diff,
720 [[maybe_unused]] const String& divider,
721 [[maybe_unused]] bool is_nan_equal = false)
722 {
723 return verifDifferent(v1, v2, diff, is_nan_equal);
724 }
725};
726
727/*---------------------------------------------------------------------------*/
728/*---------------------------------------------------------------------------*/
733template <>
734class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<BFloat16>
735{
736 public:
737
739 typedef BFloat16 Type;
740
743
746
749
752
753 typedef BFloat16 BasicType;
754
755 static constexpr Integer nbBasicType() { return 1; }
756
757 typedef BFloat16 NormType;
758
759 public:
760
762 static constexpr const char* typeName() { return "BFloat16"; }
764 static constexpr eDataType type() { return DT_BFloat16; }
766 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
772 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
773
774 static bool verifDifferent(float v1, float v2, BFloat16& diff,
775 [[maybe_unused]] bool is_nan_equal = false)
776 {
777 return _verifDifferent(v1, v2, diff, v1);
778 }
779
780 static bool verifDifferentNorm(float v1, float v2, BFloat16& diff, NormType norm,
781 [[maybe_unused]] bool is_nan_equal = false)
782 {
783 return _verifDifferent(v1, v2, diff, norm);
784 }
785
786 static BFloat16 normeMax(float v)
787 {
788 return static_cast<Type>(math::abs(v));
789 }
790
791 private:
792
793 static bool _verifDifferent(float v1, float v2, BFloat16& diff, float divider)
794 {
795 if (v1 != v2) {
796 float fdiff = 0.0;
797 if (math::abs(divider) != 0.0)
798 fdiff = v1 - v2;
799 else
800 fdiff = (v1 - v2) / divider;
801 diff = static_cast<Type>(fdiff);
802 return true;
803 }
804 return false;
805 }
806};
807
808/*---------------------------------------------------------------------------*/
809/*---------------------------------------------------------------------------*/
814template <>
815class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Float16>
816{
817 public:
818
820 typedef Float16 Type;
821
824
827
830
833
834 typedef Float16 BasicType;
835
836 static constexpr Integer nbBasicType() { return 1; }
837
838 typedef Float16 NormType;
839
840 public:
841
843 static constexpr const char* typeName() { return "Float16"; }
845 static constexpr eDataType type() { return DT_Float16; }
847 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
853 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
854
855 static bool verifDifferent(float v1, float v2, Float16& diff,
856 [[maybe_unused]] bool is_nan_equal = false)
857 {
858 return _verifDifferent(v1, v2, diff, v1);
859 }
860
861 static bool verifDifferentNorm(float v1, float v2, Float16& diff, NormType norm,
862 [[maybe_unused]] bool is_nan_equal = false)
863 {
864 return _verifDifferent(v1, v2, diff, norm);
865 }
866
867 static Float16 normeMax(Float16 v)
868 {
869 return static_cast<Float16>(math::abs(v));
870 }
871
872 private:
873
874 static bool _verifDifferent(float v1, float v2, Float16& diff, float divider)
875 {
876 if (v1 != v2) {
877 float fdiff = 0.0;
878 if (math::abs(divider) != 0.0)
879 fdiff = v1 - v2;
880 else
881 fdiff = (v1 - v2) / divider;
882 diff = static_cast<Type>(fdiff);
883 return true;
884 }
885 return false;
886 }
887};
888
889/*---------------------------------------------------------------------------*/
890/*---------------------------------------------------------------------------*/
895template <>
896class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Float32>
897{
898 public:
899
901 typedef Float32 Type;
902
905
908
911
914
915 typedef Real BasicType;
916
917 static constexpr Integer nbBasicType() { return 1; }
918
919 typedef Float32 NormType;
920
921 public:
922
924 static constexpr const char* typeName() { return "Float32"; }
926 static constexpr eDataType type() { return DT_Float32; }
928 static void dumpValue(String& s, const Type& v) { builtInDumpValue(s, v); }
934 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
935
936 static bool verifDifferentNorm(Type v1, Type v2, Type& diff, NormType norm, bool is_nan_equal = false)
937 {
938 return _verifDifferent(v1, v2, diff, norm, is_nan_equal);
939 }
940
941 static bool verifDifferent(Type v1, Type v2, Type& diff, bool is_nan_equal = false)
942 {
943 return _verifDifferent(v1, v2, diff, v1, is_nan_equal);
944 }
945
946 static Float32 normeMax(Float32 v)
947 {
948 return math::abs(v);
949 }
950
951 private:
952
953 static bool _verifDifferent(Type v1, Type v2, Type& diff, Type divider, bool is_nan_equal)
954 {
955 if (is_nan_equal) {
956 if (std::isnan(v1) && std::isnan(v2))
957 return false;
958 }
959 // Vérifie avant de les comparer que les deux nombres sont valides
960 // pour éviter une exception flottante sur certaines plates-formes
961 if (platform::isDenormalized(v1) || platform::isDenormalized(v2)) {
962 diff = 1.0;
963 return true;
964 }
965 if (v1 != v2) {
966 if (math::abs(divider) < 1.e-40)
967 diff = v1 - v2;
968 else
969 diff = (v1 - v2) / divider;
970 return true;
971 }
972 return false;
973 }
974};
975
976/*---------------------------------------------------------------------------*/
977/*---------------------------------------------------------------------------*/
982template <>
983class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Real2>
984{
985 public:
986
988 typedef Real2 Type;
989
991 typedef TrueType HasDump;
992
994 typedef TrueType HasReduce;
995
997 typedef TrueType HasReduceMinMax;
998
1000 typedef TrueType IsNumeric;
1001
1002 typedef Real BasicType;
1003
1004 static constexpr Integer nbBasicType() { return 2; }
1005
1006 typedef Real NormType;
1007
1008 private:
1009
1010 using SubTraits = VariableDataTypeTraitsT<Real>;
1011
1012 public:
1013
1015 static constexpr const char* typeName() { return "Real2"; }
1017 static constexpr eDataType type() { return DT_Real2; }
1019 static void dumpValue(String& s, const Type&) { s = "N/A"; }
1025 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
1026
1027 static bool verifDifferent(Real2 v1, Real2 v2, Real2& diff, bool is_nan_equal = false)
1028 {
1029 bool is_different = false;
1030 is_different |= SubTraits::verifDifferent(v1.x, v2.x, diff.x, is_nan_equal);
1031 is_different |= SubTraits::verifDifferent(v1.y, v2.y, diff.y, is_nan_equal);
1032 return is_different;
1033 }
1034
1035 static bool verifDifferentNorm(const Real2& v1, const Real2& v2, Real2& diff, NormType norm, [[maybe_unused]] bool is_nan_equal)
1036 {
1037 if (norm < 1.e-100) {
1038 diff.x = math::abs(v2.x);
1039 diff.y = math::abs(v2.y);
1040 }
1041 else {
1042 diff.x = math::abs(v2.x - v1.x) / norm;
1043 diff.y = math::abs(v2.y - v1.y) / norm;
1044 }
1045 bool is_different = (normeMax(diff) != 0.);
1046 return is_different;
1047 }
1048
1049 static NormType normeMax(const Real2& v)
1050 {
1051 Real vx = SubTraits::normeMax(v.x);
1052 Real vy = SubTraits::normeMax(v.y);
1053 return math::max(vx, vy);
1054 }
1055};
1056
1057/*---------------------------------------------------------------------------*/
1058/*---------------------------------------------------------------------------*/
1063template <>
1064class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Real3>
1065{
1066 public:
1067
1069 typedef Real3 Type;
1070
1072 typedef TrueType HasDump;
1073
1075 typedef TrueType HasReduce;
1076
1078 typedef TrueType HasReduceMinMax;
1079
1081 typedef TrueType IsNumeric;
1082
1083 typedef Real BasicType;
1084
1085 static constexpr Integer nbBasicType() { return 3; }
1086
1087 typedef Real NormType;
1088
1089 private:
1090
1091 using SubTraits = VariableDataTypeTraitsT<Real>;
1092
1093 public:
1094
1096 static constexpr const char* typeName() { return "Real3"; }
1098 static constexpr eDataType type() { return DT_Real3; }
1100 static void dumpValue(String& s, const Type&) { s = "N/A"; }
1106 static bool getValue(Type& v, const String& s) { return builtInGetValue(v, s); }
1107
1108 static bool verifDifferent(Real3 v1, Real3 v2, Real3& diff, bool is_nan_equal = false)
1109 {
1110 bool is_different = false;
1111 is_different |= SubTraits::verifDifferent(v1.x, v2.x, diff.x, is_nan_equal);
1112 is_different |= SubTraits::verifDifferent(v1.y, v2.y, diff.y, is_nan_equal);
1113 is_different |= SubTraits::verifDifferent(v1.z, v2.z, diff.z, is_nan_equal);
1114 return is_different;
1115 }
1116
1117 static bool verifDifferentNorm(const Real3& v1, const Real3& v2, Real3& diff, NormType norm, [[maybe_unused]] bool is_nan_equal)
1118 {
1119 if (norm < 1.e-100) {
1120 diff.x = math::abs(v2.x);
1121 diff.y = math::abs(v2.y);
1122 diff.z = math::abs(v2.z);
1123 }
1124 else {
1125 diff.x = math::abs(v2.x - v1.x) / norm;
1126 diff.y = math::abs(v2.y - v1.y) / norm;
1127 diff.z = math::abs(v2.z - v1.z) / norm;
1128 }
1129 bool is_different = (normeMax(diff) != 0.);
1130 return is_different;
1131 }
1132
1133 static NormType normeMax(const Real3& v)
1134 {
1135 Real vx = SubTraits::normeMax(v.x);
1136 Real vy = SubTraits::normeMax(v.y);
1137 Real vz = SubTraits::normeMax(v.z);
1138 return math::max(vx, math::max(vy, vz));
1139 }
1140};
1141
1142/*---------------------------------------------------------------------------*/
1143/*---------------------------------------------------------------------------*/
1148template <>
1149class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Real2x2>
1150{
1151 public:
1152
1154 typedef Real2x2 Type;
1155
1158
1161
1164
1167
1168 typedef Real BasicType;
1169
1170 static constexpr Integer nbBasicType() { return 4; }
1171
1172 typedef Real NormType;
1173
1174 private:
1175
1176 using SubTraits = VariableDataTypeTraitsT<Real2>;
1177
1178 public:
1179
1181 static constexpr const char* typeName() { return "Real2x2"; }
1183 static constexpr eDataType type() { return DT_Real2x2; }
1185 static void dumpValue(String& s, const Type&) { s = "N/A"; }
1191 static bool getValue(Type&, const String&) { return true; }
1192
1193 static bool verifDifferent(Real2x2 v1, Real2x2 v2, Real2x2& diff, bool is_nan_equal = false)
1194 {
1195 bool is_different = false;
1196 is_different |= SubTraits::verifDifferent(v1.x, v2.x, diff.x, is_nan_equal);
1197 is_different |= SubTraits::verifDifferent(v1.y, v2.y, diff.y, is_nan_equal);
1198 return is_different;
1199 }
1200
1201 static bool verifDifferentNorm(const Real2x2& v1, const Real2x2& v2, Real2x2& diff, NormType norm, [[maybe_unused]] bool is_nan_equal)
1202 {
1203 if (norm < 1.e-100) {
1204 diff.x.x = math::abs(v2.x.x);
1205 diff.x.y = math::abs(v2.x.y);
1206
1207 diff.y.x = math::abs(v2.y.x);
1208 diff.y.y = math::abs(v2.y.y);
1209 }
1210 else {
1211 diff.x.x = math::abs(v2.x.x - v1.x.x) / norm;
1212 diff.x.y = math::abs(v2.x.y - v1.x.y) / norm;
1213
1214 diff.y.x = math::abs(v2.y.x - v1.y.x) / norm;
1215 diff.y.y = math::abs(v2.y.y - v1.y.y) / norm;
1216 }
1217 bool is_different = (normeMax(diff) != 0.);
1218 return is_different;
1219 }
1220
1221 static NormType normeMax(const Real2x2& v)
1222 {
1223 Real vx = SubTraits::normeMax(v.x);
1224 Real vy = SubTraits::normeMax(v.y);
1225 return SubTraits::normeMax(Real2(vx, vy));
1226 }
1227};
1228
1229/*---------------------------------------------------------------------------*/
1230/*---------------------------------------------------------------------------*/
1235template <>
1236class ARCANE_CORE_EXPORT VariableDataTypeTraitsT<Real3x3>
1237{
1238 public:
1239
1241 typedef Real3x3 Type;
1242
1245
1248
1251
1254
1255 typedef Real BasicType;
1256
1257 static constexpr Integer nbBasicType() { return 9; }
1258
1259 typedef Real NormType;
1260
1261 private:
1262
1263 using SubTraits = VariableDataTypeTraitsT<Real3>;
1264
1265 public:
1266
1268 static constexpr const char* typeName() { return "Real3x3"; }
1270 static constexpr eDataType type() { return DT_Real3x3; }
1272 static void dumpValue(String& s, const Type&) { s = "N/A"; }
1278 static bool getValue(Type&, const String&) { return true; }
1279
1280 static bool verifDifferent(Real3x3 v1, Real3x3 v2, Real3x3& diff, bool is_nan_equal = false)
1281 {
1282 bool is_different = false;
1283 is_different |= SubTraits::verifDifferent(v1.x, v2.x, diff.x, is_nan_equal);
1284 is_different |= SubTraits::verifDifferent(v1.y, v2.y, diff.y, is_nan_equal);
1285 is_different |= SubTraits::verifDifferent(v1.z, v2.z, diff.z, is_nan_equal);
1286 return is_different;
1287 }
1288
1289 static bool verifDifferentNorm(const Real3x3& v1, const Real3x3& v2, Real3x3& diff, NormType norm, [[maybe_unused]] bool is_nan_equal)
1290 {
1291 if (norm < 1.e-100) {
1292 diff.x.x = math::abs(v2.x.x);
1293 diff.x.y = math::abs(v2.x.y);
1294 diff.x.z = math::abs(v2.x.z);
1295
1296 diff.y.x = math::abs(v2.y.x);
1297 diff.y.y = math::abs(v2.y.y);
1298 diff.y.z = math::abs(v2.y.z);
1299
1300 diff.z.x = math::abs(v2.z.x);
1301 diff.z.y = math::abs(v2.z.y);
1302 diff.z.z = math::abs(v2.z.z);
1303 }
1304 else {
1305 diff.x.x = math::abs(v2.x.x - v1.x.x) / norm;
1306 diff.x.y = math::abs(v2.x.y - v1.x.y) / norm;
1307 diff.x.z = math::abs(v2.x.z - v1.x.z) / norm;
1308
1309 diff.y.x = math::abs(v2.y.x - v1.y.x) / norm;
1310 diff.y.y = math::abs(v2.y.y - v1.y.y) / norm;
1311 diff.y.z = math::abs(v2.y.z - v1.y.z) / norm;
1312
1313 diff.z.x = math::abs(v2.z.x - v1.z.x) / norm;
1314 diff.z.y = math::abs(v2.z.y - v1.z.y) / norm;
1315 diff.z.z = math::abs(v2.z.z - v1.z.z) / norm;
1316 }
1317 bool is_different = (normeMax(diff) != 0.);
1318 return is_different;
1319 }
1320
1321 static NormType normeMax(const Real3x3& v)
1322 {
1323 Real vx = SubTraits::normeMax(v.x);
1324 Real vy = SubTraits::normeMax(v.y);
1325 Real vz = SubTraits::normeMax(v.z);
1326 return VariableDataTypeTraitsT<Real3>::normeMax(Real3(vx, vy, vz));
1327 }
1328};
1329
1330/*---------------------------------------------------------------------------*/
1331/*---------------------------------------------------------------------------*/
1332
1333} // namespace Arcane
1334
1335/*---------------------------------------------------------------------------*/
1336/*---------------------------------------------------------------------------*/
1337
1338#endif
Fichier contenant les définitions des types de données gérés par Arcane.
Type flottant demi-précision.
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
Real2 x
Première composante.
Definition Real2x2.h:98
Real2 y
Deuxième composante.
Definition Real2x2.h:99
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
Real3 z
premier élément du triplet
Definition Real3x3.h:119
Real3 y
premier élément du triplet
Definition Real3x3.h:118
Real3 x
premier élément du triplet
Definition Real3x3.h:117
Chaîne de caractères unicode.
TrueType IsNumeric
Indique si le type est numérique.
static constexpr eDataType type()
Retourne le type de la variable.
BFloat16 Type
Type du paramètre template.
FalseType HasReduce
Indique si le type peut être subir une réduction.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
FalseType HasDump
Indique si le type peut être sauvé et relu.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static constexpr eDataType type()
Retourne le type de la variable.
TrueType IsNumeric
Indique si le type est numérique.
TrueType HasDump
Indique si le type peut être sauvé et relu.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
Byte Type
Type du paramètre template.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
TrueType HasReduce
Indique si le type peut être subir une réduction.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
FalseType HasReduce
Indique si le type peut être subir une réduction.
static constexpr eDataType type()
Retourne le type de la variable.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
TrueType HasDump
Indique si le type peut être sauvé et relu.
TrueType IsNumeric
Indique si le type est numérique.
Float128 Type
Type du paramètre template.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static constexpr eDataType type()
Retourne le type de la variable.
FalseType HasDump
Indique si le type peut être sauvé et relu.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
Float16 Type
Type du paramètre template.
TrueType IsNumeric
Indique si le type est numérique.
FalseType HasReduce
Indique si le type peut être subir une réduction.
Float32 Type
Type du paramètre template.
TrueType HasReduce
Indique si le type peut être subir une réduction.
FalseType HasDump
Indique si le type peut être sauvé et relu.
TrueType IsNumeric
Indique si le type est numérique.
static constexpr eDataType type()
Retourne le type de la variable.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
TrueType IsNumeric
Indique si le type est numérique.
Int128 Type
Type du paramètre template.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static constexpr eDataType type()
Retourne le type de la variable.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
TrueType HasDump
Indique si le type peut être sauvé et relu.
FalseType HasReduce
Indique si le type peut être subir une réduction.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
TrueType IsNumeric
Indique si le type est numérique.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
static constexpr eDataType type()
Retourne le type de la variable.
TrueType HasReduce
Indique si le type peut être subir une réduction.
TrueType HasDump
Indique si le type peut être sauvé et relu.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
TrueType HasDump
Indique si le type peut être sauvé et relu.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static constexpr eDataType type()
Retourne le type de la variable.
TrueType IsNumeric
Indique si le type est numérique.
TrueType HasReduce
Indique si le type peut être subir une réduction.
TrueType HasReduce
Indique si le type peut être subir une réduction.
static constexpr eDataType type()
Retourne le type de la variable.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
TrueType HasDump
Indique si le type peut être sauvé et relu.
TrueType IsNumeric
Indique si le type est numérique.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
TrueType HasDump
Indique si le type peut être sauvé et relu.
TrueType IsNumeric
Indique si le type est numérique.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
static constexpr eDataType type()
Retourne le type de la variable.
TrueType HasReduce
Indique si le type peut être subir une réduction.
static constexpr eDataType type()
Retourne le type de la variable.
TrueType IsNumeric
Indique si le type est numérique.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
TrueType HasReduce
Indique si le type peut être subir une réduction.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static bool getValue(Type &, const String &)
Stocke la conversion de la chaîne s en le type Type dans v.
TrueType HasDump
Indique si le type peut être sauvé et relu.
static void dumpValue(String &s, const Type &)
Ecrit dans la chaîne s la valeur de v.
TrueType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
TrueType HasDump
Indique si le type peut être sauvé et relu.
static constexpr eDataType type()
Retourne le type de la variable.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
TrueType HasReduce
Indique si le type peut être subir une réduction.
static bool getValue(Type &, const String &)
Stocke la conversion de la chaîne s en le type Type dans v.
static void dumpValue(String &s, const Type &)
Ecrit dans la chaîne s la valeur de v.
TrueType IsNumeric
Indique si le type est numérique.
FalseType HasReduceMinMax
Indique si le type peut être subir une réduction Min/Max.
static constexpr eDataType type()
Retourne le type de la variable.
static constexpr const char * typeName()
Retourne le nom du type de la variable.
FalseType IsNumeric
Indique si le type est numérique.
TrueType HasDump
Indique si le type peut être sauvé et relu.
FalseType HasReduce
Indique si le type peut être subir une réduction.
static void dumpValue(String &s, const Type &v)
Ecrit dans la chaîne s la valeur de v.
static bool getValue(Type &v, const String &s)
Stocke la conversion de la chaîne s en le type Type dans v.
String Type
Type du paramètre template.
Classe template d'informations sur un type d'une variable.
bool isZero(const BuiltInProxy< _Type > &a)
Teste si une valeur est exactement égale à zéro.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int8_t Int8
Type entier signé sur 8 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
void builtInDumpValue(String &s, const DataType &v)
Ecriture dans la chaine s d'un type basique de valeur v.
std::int16_t Int16
Type entier signé sur 16 bits.
double Real
Type représentant un réel.
unsigned char Byte
Type d'un octet.
Definition BaseTypes.h:43
float Float32
Type flottant IEEE-753 simple précision.
eDataType
Type d'une donnée.
Definition DataTypes.h:39
@ DT_Float32
Donnée de type 'Float32'.
Definition DataTypes.h:52
@ DT_Int128
Donnée de type entier sur 128 bits.
Definition DataTypes.h:55
@ DT_Real2x2
Donnée de type tenseur 3x3.
Definition DataTypes.h:48
@ DT_Int16
Donnée de type entier 16 bits.
Definition DataTypes.h:42
@ DT_Int8
Donnée de type entier sur 8 bits.
Definition DataTypes.h:53
@ DT_Real3x3
Donnée de type tenseur 3x3.
Definition DataTypes.h:49
@ DT_Int32
Donnée de type entier 32 bits.
Definition DataTypes.h:43
@ DT_Real3
Donnée de type vecteur 3.
Definition DataTypes.h:47
@ DT_Float16
Donnée de type 'Float16'.
Definition DataTypes.h:51
@ DT_Int64
Donnée de type entier 64 bits.
Definition DataTypes.h:44
@ DT_Unknown
Donnée de type inconnue ou non initialisée.
Definition DataTypes.h:56
@ DT_String
Donnée de type chaîne de caractère UTF-8.
Definition DataTypes.h:45
@ DT_BFloat16
Donnée de type 'BFloat16'.
Definition DataTypes.h:50
@ DT_Real2
Donnée de type vecteur 2.
Definition DataTypes.h:46
@ DT_Real
Donnée de type réel.
Definition DataTypes.h:41
@ DT_Byte
Donnée de type octet.
Definition DataTypes.h:40
@ DT_Float128
Donnée de type flottant sur 128 bits.
Definition DataTypes.h:54
std::int32_t Int32
Type entier signé sur 32 bits.
Arcane::BFloat16 BFloat16
Type 'Brain Float16'.
Arcane::Float16 Float16
Type 'Float16' (binary16)
Type
Type of JSON value.
Definition rapidjson.h:665
Structure équivalente à la valeur booléenne vrai.
Structure équivalente à la valeur booléenne vrai.