File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -195,26 +195,26 @@ impl<T: Float> Complex<T> {
195
195
pub fn exp ( self ) -> Self {
196
196
// formula: e^(a + bi) = e^a (cos(b) + i*sin(b)) = from_polar(e^a, b)
197
197
198
+ let Complex { re, mut im } = self ;
198
199
// Treat the corner cases +∞, -∞, and NaN
199
- let mut im = self . im ;
200
- if self . re . is_infinite ( ) {
201
- if self . re < T :: zero ( ) {
202
- if !self . im . is_finite ( ) {
203
- im = T :: one ( ) ;
200
+ if re. is_infinite ( ) {
201
+ if re < T :: zero ( ) {
202
+ if !im. is_finite ( ) {
203
+ return Self :: new ( T :: zero ( ) , T :: zero ( ) ) ;
204
204
}
205
205
} else {
206
- if self . im == T :: zero ( ) || !self . im . is_finite ( ) {
207
- if self . im . is_infinite ( ) {
206
+ if im == T :: zero ( ) || !im. is_finite ( ) {
207
+ if im. is_infinite ( ) {
208
208
im = T :: nan ( ) ;
209
209
}
210
- return Self :: new ( self . re , im) ;
210
+ return Self :: new ( re, im) ;
211
211
}
212
212
}
213
- } else if self . re . is_nan ( ) && self . im == T :: zero ( ) {
213
+ } else if re. is_nan ( ) && im == T :: zero ( ) {
214
214
return self ;
215
215
}
216
216
217
- Self :: from_polar ( self . re . exp ( ) , im)
217
+ Self :: from_polar ( re. exp ( ) , im)
218
218
}
219
219
220
220
/// Computes the principal value of natural logarithm of `self`.
You can’t perform that action at this time.
0 commit comments