From 987704134452650f77c06446dcaec0b4e342b5a7 Mon Sep 17 00:00:00 2001 From: MaLiN2223 Date: Mon, 25 Jan 2016 11:16:57 +0100 Subject: [PATCH] added if's in magnitude calculation --- src/Numerics/Complex32.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Numerics/Complex32.cs b/src/Numerics/Complex32.cs index 608014d0..cfa0f009 100644 --- a/src/Numerics/Complex32.cs +++ b/src/Numerics/Complex32.cs @@ -187,10 +187,12 @@ namespace MathNet.Numerics [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get { + if (float.IsNaN(_real) || float.IsNaN(_imag)) + return float.NaN; + if (float.IsInfinity(_real) || float.IsInfinity(_imag)) + return float.PositiveInfinity; float a = Math.Abs(_real); float b = Math.Abs(_imag); - if (float.IsPositiveInfinity(a) && float.IsPositiveInfinity(b)) - return float.PositiveInfinity; if (a > b) { double tmp = b / a;