Complex numbers not in fundamental class?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Hamaidi
am 21 Mär. 2022
Beantwortet: Walter Roberson
am 21 Mär. 2022
Hi Community
Since a complex number is 1x1 array, why isn't in fundamental class type of datas?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Mär. 2022
Observe
format long g
t = complex(single(3), single(-5)), whos t
t = complex(double(3), double(-5)), whos t
t = complex(int8(3), int8(-5)), whos t
t = complex(uint64(3), uint64(5))
Complex is an attribute, not a class. If you made it a class, you would need a separate class for each different datatype that can be complex -- single, double, int8, uint8, int16, uint16, int32, uint32, int64, uint64. (Complex logical and complex char get converted to double precision.)
Meanwhile you would still need isnumeric() and issingle() and isdouble() and isinteger() to continue to work on the values. What would your inheritence hierarchy be?
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!