32 ComplexValue() =
default;
33 ComplexValue(
const ComplexValue &) =
default;
34 ComplexValue(ComplexValue &&) =
default;
35 ComplexValue &operator=(
const ComplexValue &) =
default;
36 ComplexValue &operator=(ComplexValue &&) =
default;
39 CHECK_MSG(r.
IsNull() == i.
IsNull(),
"real and imag must be the same kind");
41 "real and imag must be the same kind");
47 ComplexValue(
int kind,
const RealValue &r) : ComplexValue{r} {
51 ComplexValue(
int kind,
const ComplexValue &v) : ComplexValue{v} {
55 ComplexValue(
int kind, ComplexValue &&v) : ComplexValue{std::move(v)} {
64 return ComplexValue{zero, zero};
67 void print(llvm::raw_ostream &os)
const;
69#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
70 LLVM_DUMP_METHOD
void dump()
const;
76 CHECK(re_.IsNull() == im_.IsNull());
82 CHECK(re_.kind() == im_.kind());
88 return re_.bytesStored() + im_.bytesStored();
94 RealValue REAL()
const {
return re_; }
96 RealValue AIMAG()
const {
return im_; }
98 ComplexValue CONJG()
const {
return ComplexValue{re_, im_.Negate()}; }
100 ComplexValue Negate()
const {
101 return ComplexValue{re_.Negate(), im_.Negate()};
104 bool Equals(
const ComplexValue &y)
const {
105 return re_.Compare(y.re_) == Relation::Equal &&
106 im_.Compare(y.im_) == Relation::Equal;
109 bool operator==(
const ComplexValue &y)
const {
110 return re_ == y.re_ && im_ == y.im_;
113 bool operator!=(
const ComplexValue &y)
const {
return !(*
this == y); }
115 bool IsZero()
const {
return re_.IsZero() && im_.IsZero(); }
117 bool IsInfinite()
const {
return re_.IsInfinite() || im_.IsInfinite(); }
119 bool IsNotANumber()
const {
return re_.IsNotANumber() || im_.IsNotANumber(); }
121 bool IsSignalingNaN()
const {
122 return re_.IsSignalingNaN() || im_.IsSignalingNaN();
125 static ValueWithRealFlags<ComplexValue> FromInteger(
int kind,
126 const IntegerValue &n,
bool isUnsigned =
false,
127 Rounding rounding = TargetCharacteristics::defaultRounding);
129 ValueWithRealFlags<ComplexValue> Add(
const ComplexValue &,
130 Rounding rounding = TargetCharacteristics::defaultRounding)
const;
132 ValueWithRealFlags<ComplexValue> Subtract(
const ComplexValue &,
133 Rounding rounding = TargetCharacteristics::defaultRounding)
const;
134 ValueWithRealFlags<ComplexValue> Multiply(
const ComplexValue &,
135 Rounding rounding = TargetCharacteristics::defaultRounding)
const;
136 ValueWithRealFlags<ComplexValue> Divide(
const ComplexValue &,
137 Rounding rounding = TargetCharacteristics::defaultRounding)
const;
139 ValueWithRealFlags<ComplexValue> KahanSummation(
const ComplexValue &y,
140 ComplexValue &correction,
141 Rounding rounding = TargetCharacteristics::defaultRounding)
const;
145 Rounding rounding = TargetCharacteristics::defaultRounding)
const {
146 return re_.HYPOT(im_, rounding);
150 return ComplexValue{re_.FlushSubnormalToZero(), im_.FlushSubnormalToZero()};
153 static ComplexValue NotANumber(
int kind) {
154 return {RealValue::NotANumber(
kind), RealValue::NotANumber(
kind)};
157 std::string DumpHexadecimal()
const;
159 llvm::raw_ostream &AsFortran(llvm::raw_ostream &,
int kind)
const;
161 void StoreRawBytes(
void *dst,
size_t size,
bool *changed =
nullptr)
const;
163 static ComplexValue FromRawBytes(
164 int kind,
const void *raw, std::size_t expectedSize);
ValueWithRealFlags< RealValue > ABS(Rounding rounding=TargetCharacteristics::defaultRounding) const
ABS/CABS = HYPOT(re_, imag_) = SQRT(re_**2 + im_**2)
Definition complex-value.h:144