double.IsInfinity(double)

Here are the examples of the csharp api double.IsInfinity(double) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

694 Examples 7

19 Source : Helpers.cs
with MIT License
from 404Lcc

public static bool IsInfinity(double value)
        {
#if MF
            const double inf = (double)1.0 / (double)0.0, minf = (double)-1.0F / (double)0.0;
            return value == inf || value == minf;
#else
            return double.IsInfinity(value);
#endif
        }

19 Source : VirtualizingWrapPanel .cs
with MIT License
from 944095635

protected override Size MeasureOverride(Size availableSize)
        {
            if (_itemsControl == null)
            {
                return availableSize;
            }

            _isInMeasure = true;
            _childLayouts.Clear();

            var extentInfo = GetExtentInfo(availableSize);

            EnsureScrollOffsetIsWithinConstrains(extentInfo);

            var layoutInfo = GetLayoutInfo(availableSize, ItemHeight, extentInfo);

            RecycleItems(layoutInfo);

            // Determine where the first item is in relation to previously realized items
            var generatorStartPosition = _itemsGenerator.GeneratorPositionFromIndex(layoutInfo.FirstRealizedItemIndex);

            var visualIndex = 0;

            var currentX = layoutInfo.FirstRealizedItemLeft;
            var currentY = layoutInfo.FirstRealizedLineTop;

            using (_itemsGenerator.StartAt(generatorStartPosition, GeneratorDirection.Forward, true))
            {
                for (var itemIndex = layoutInfo.FirstRealizedItemIndex; itemIndex <= layoutInfo.LastRealizedItemIndex; itemIndex++, visualIndex++)
                {
                    bool newlyRealized;

                    var child = (UIElement)_itemsGenerator.GenerateNext(out newlyRealized);
                    SetVirtualItemIndex(child, itemIndex);

                    if (newlyRealized)
                    {
                        InsertInternalChild(visualIndex, child);
                    }
                    else
                    {
                        // check if item needs to be moved into a new position in the Children collection
                        if (visualIndex < Children.Count)
                        {
                            if (!ReferenceEquals(Children[visualIndex], child))
                            {
                                var childCurrentIndex = Children.IndexOf(child);

                                if (childCurrentIndex >= 0)
                                {
                                    RemoveInternalChildRange(childCurrentIndex, 1);
                                }

                                InsertInternalChild(visualIndex, child);
                            }
                        }
                        else
                        {
                            // we know that the child can't already be in the children collection
                            // because we've been inserting children in correct visualIndex order,
                            // and this child has a visualIndex greater than the Children.Count
                            AddInternalChild(child);
                        }
                    }

                    // only prepare the item once it has been added to the visual tree
                    _itemsGenerator.PrepareItemContainer(child);

                    child.Measure(new Size(ItemWidth, ItemHeight));

                    _childLayouts.Add(child, new Rect(currentX, currentY, ItemWidth, ItemHeight));

                    if (currentX + ItemWidth * 2 >= availableSize.Width)
                    {
                        // wrap to a new line
                        currentY += ItemHeight;
                        currentX = 0;
                    }
                    else
                    {
                        currentX += ItemWidth;
                    }
                }
            }

            RemoveRedundantChildren();
            UpdateScrollInfo(availableSize, extentInfo);

            var desiredSize = new Size(double.IsInfinity(availableSize.Width) ? 0 : availableSize.Width,
                                       double.IsInfinity(availableSize.Height) ? 0 : availableSize.Height);

            _isInMeasure = false;

            return desiredSize;
        }

19 Source : CubicSpline.cs
with MIT License
from ABTSoftware

public void Fit(double[] x, double[] y, double startSlope = double.NaN, double endSlope = double.NaN, bool debug = false)
        {
            if (Double.IsInfinity(startSlope) || Double.IsInfinity(endSlope))
            {
                throw new Exception("startSlope and endSlope cannot be infinity.");
            }

            // Save x and y for eval
            this.xOrig = x;
            this.yOrig = y;

            int n = x.Length;
            double[] r = new double[n]; // the right hand side numbers: wikipedia page overloads b

            TriDiagonalMatrixF m = new TriDiagonalMatrixF(n);
            double dx1, dx2, dy1, dy2;

            // First row is different (equation 16 from the article)
            if (double.IsNaN(startSlope))
            {
                dx1 = x[1] - x[0];
                m.C[0] = 1.0f / dx1;
                m.B[0] = 2.0f * m.C[0];
                r[0] = 3 * (y[1] - y[0]) / (dx1 * dx1);
            }
            else
            {
                m.B[0] = 1;
                r[0] = startSlope;
            }

            // Body rows (equation 15 from the article)
            for (int i = 1; i < n - 1; i++)
            {
                dx1 = x[i] - x[i - 1];
                dx2 = x[i + 1] - x[i];

                m.A[i] = 1.0f / dx1;
                m.C[i] = 1.0f / dx2;
                m.B[i] = 2.0f * (m.A[i] + m.C[i]);

                dy1 = y[i] - y[i - 1];
                dy2 = y[i + 1] - y[i];
                r[i] = 3 * (dy1 / (dx1 * dx1) + dy2 / (dx2 * dx2));
            }

            // Last row also different (equation 17 from the article)
            if (double.IsNaN(endSlope))
            {
                dx1 = x[n - 1] - x[n - 2];
                dy1 = y[n - 1] - y[n - 2];
                m.A[n - 1] = 1.0f / dx1;
                m.B[n - 1] = 2.0f * m.A[n - 1];
                r[n - 1] = 3 * (dy1 / (dx1 * dx1));
            }
            else
            {
                m.B[n - 1] = 1;
                r[n - 1] = endSlope;
            }

//            if (debug) Console.WriteLine("Tri-diagonal matrix:\n{0}", m.ToDisplayString(":0.0000", "  "));
//            if (debug) Console.WriteLine("r: {0}", ArrayUtil.ToString<double>(r));

            // k is the solution to the matrix
            double[] k = m.Solve(r);
//            if (debug) Console.WriteLine("k = {0}", ArrayUtil.ToString<double>(k));

            // a and b are each spline's coefficients
            this.a = new double[n - 1];
            this.b = new double[n - 1];

            for (int i = 1; i < n; i++)
            {
                dx1 = x[i] - x[i - 1];
                dy1 = y[i] - y[i - 1];
                a[i - 1] = k[i - 1] * dx1 - dy1; // equation 10 from the article
                b[i - 1] = -k[i] * dx1 + dy1; // equation 11 from the article
            }

//            if (debug) Console.WriteLine("a: {0}", ArrayUtil.ToString<double>(a));
//            if (debug) Console.WriteLine("b: {0}", ArrayUtil.ToString<double>(b));
        }

19 Source : RealTimePerformanceDemoView.xaml.cs
with MIT License
from ABTSoftware

private void OnSciChartRendered(object sender, EventArgs e)
        {
            // Compute the render time
            double frameTime = _stopWatch.ElapsedMilliseconds;
            double delta = frameTime - _lastFrameTime;
            double fps = 1000.0 / delta;
            double fpsAverageBefore = _fpsAverage.Current;

            // Push the fps to the movingaverage, we want to average the FPS to get a more reliable reading
            if (!double.IsInfinity(fps))
            {
                _fpsAverage.Push(fps);
            }

            double fpsAverageAfter = _fpsAverage.Current;

            // Render the fps to the screen
            if (Math.Abs(fpsAverageAfter - fpsAverageBefore) >= 0.1)
                FpsCounter.Text = double.IsNaN(_fpsAverage.Current) ? "-" : string.Format("{0:0}", _fpsAverage.Current);

            // Render the total point count (all series) to the screen
            int numPoints = 3 * _mainSeries.Count;
            PointCount.Text = string.Format("{0:n0}", numPoints);

            if (numPoints > MaxCount)
            {
                this.PauseButton_Click(this, null);
            }

            _lastFrameTime = frameTime;
        }

19 Source : YPeakViewportManager.cs
with MIT License
from ABTSoftware

private bool IsNullOrInfinity(IComparable value)
        {
            if(value is double d)
            {
                return double.IsInfinity(d);
            }

            return value == null;
        }

19 Source : PropertyValidation.cs
with MIT License
from actions

private static void ValidateDouble(String propertyName, Double propertyValue)
        {
            if (Double.IsInfinity(propertyValue) || Double.IsNaN(propertyValue))
            {
                throw new VssPropertyValidationException("value", CommonResources.DoubleValueOutOfRange(propertyName, propertyValue));
            }

            // SQL Server support: - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308
            if (propertyValue < s_minNegative ||
                (propertyValue < 0 && propertyValue > s_maxNegative) ||
                propertyValue > s_maxPositive ||
                (propertyValue > 0 && propertyValue < s_minPositive))
            {
                throw new VssPropertyValidationException("value", CommonResources.DoubleValueOutOfRange(propertyName, propertyValue));
            }
        }

19 Source : Global.cs
with MIT License
from adamped

public static bool IsFinite(this double d)
        {
            return !double.IsInfinity(d);
        }

19 Source : Helper.cs
with MIT License
from adamped

public static bool isFinite(this double value) => !double.IsInfinity(value);

19 Source : ValidateHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsInRangeOfPosDouble(object value, bool includeZero = false)
        {
            var v = (double)value;
            return !(double.IsNaN(v) || double.IsInfinity(v)) && (includeZero ? v >= 0 : v > 0);
        }

19 Source : ValidateHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsInRangeOfNegDouble(object value, bool includeZero = false)
        {
            var v = (double)value;
            return !(double.IsNaN(v) || double.IsInfinity(v)) && (includeZero ? v <= 0 : v < 0);
        }

19 Source : ValidateHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsInRangeOfPosDoubleIncludeZero(object value)
        {
            var v = (double)value;
            return !(double.IsNaN(v) || double.IsInfinity(v)) && v >= 0;
        }

19 Source : MetroWaterfallFlow.cs
with GNU General Public License v3.0
from aduskin

protected override Size MeasureOverride(Size constraint)
      {
         if (double.IsInfinity(constraint.Width))
         {
            _colums = InternalChildren.Count;
            _actualListWidth = ListWidth;
            _panelWidth = _actualListWidth * _colums;
         }
         else
         {
            _colums = (int)Math.Floor(constraint.Width / ListWidth);
            _actualListWidth = constraint.Width / _colums;
            _panelWidth = constraint.Width;
         }
         _curHeight = new double[_colums];
         foreach (UIElement item in InternalChildren)
         {
            var col = GetFistMiniHeight();
            item.SetValue(WidthProperty, _actualListWidth);
            item.Measure(new Size(_actualListWidth, double.PositiveInfinity));
            SetCurHeight(col, item.DesiredSize.Height);
         }
         return new Size(_panelWidth, _maxheight);
      }

19 Source : UIElementExtension.cs
with GNU General Public License v3.0
from aduskin

public static double RoundLayoutValue(double value, double dpiScale)
      {
         double num;
         if (!DoubleUtil.AreClose(dpiScale, 1.0))
         {
            num = Math.Round(value * dpiScale) / dpiScale;
            if (DoubleUtil.IsNaN(num) || double.IsInfinity(num) || DoubleUtil.AreClose(num, 1.7976931348623157E+308))
            {
               num = value;
            }
         }
         else
         {
            num = Math.Round(value);
         }
         return num;
      }

19 Source : ArithmeticHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsValidDoubleValue(object value)
        {
            var d = (double)value;
            if (!double.IsNaN(d))
                return !double.IsInfinity(d);
            return false;
        }

19 Source : GeometryHelper.cs
with GNU General Public License v3.0
from aduskin

internal static bool HasValidArea(this Size size)
        {
            return size.Width > 0.0 && size.Height > 0.0 && !double.IsInfinity(size.Width) &&
                   !double.IsInfinity(size.Height);
        }

19 Source : MathHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsFiniteDouble(double x) => !double.IsInfinity(x) && !double.IsNaN(x);

19 Source : ValidateHelper.cs
with GNU General Public License v3.0
from aduskin

public static bool IsInRangeOfDouble(object value)
        {
            var v = (double)value;
            return !(double.IsNaN(v) || double.IsInfinity(v));
        }

19 Source : HCTimeBarNew.cs
with GNU General Public License v3.0
from aduskin

private void UpdateMouseFollowBlockPos()
      {
         var p = Mouse.GetPosition(this);
         var mlliseconds = (p.X - ActualWidth / 2) / _itemWidth * _timeSpeList[_speIndex];
         if (double.IsNaN(mlliseconds) || double.IsInfinity(mlliseconds)) return;
         _textBlockMove.Text = mlliseconds < 0
             ? (SelectedTime - TimeSpan.FromMilliseconds(-mlliseconds)).ToString(TimeFormat)
             : (SelectedTime + TimeSpan.FromMilliseconds(mlliseconds)).ToString(TimeFormat);
         _textBlockMove.Margin = new Thickness(p.X - _textBlockMove.ActualWidth / 2, 2, 0, 0);
      }

19 Source : AngleBorder.cs
with GNU General Public License v3.0
from aduskin

public static double RoundLayoutValue(double value, double dpiScale)
        {
            double num;
            if (!DoubleUtil.AreClose(dpiScale, 1.0))
            {
                num = Math.Round(value * dpiScale) / dpiScale;
                if (DoubleUtil.IsNaN(num) || double.IsInfinity(num) || DoubleUtil.AreClose(num, 1.7976931348623157E+308))
                {
                    num = value;
                }
            }
            else
            {
                num = Math.Round(value);
            }
            return num;
        }

19 Source : Ckfinite.cs
with GNU General Public License v3.0
from Aekras1a

public void Load(DarksVMContext ctx, out ExecutionState state)
        {
            var sp = ctx.Registers[DarksVMConstants.REG_SP].U4;
            var valueSlot = ctx.Stack[sp--];

            var fl = ctx.Registers[DarksVMConstants.REG_FL].U1;
            if((fl & DarksVMConstants.FL_UNSIGNED) != 0)
            {
                var v = valueSlot.R4;
                if(float.IsNaN(v) || float.IsInfinity(v))
                    throw new ArithmeticException();
            }
            else
            {
                var v = valueSlot.R8;
                if(double.IsNaN(v) || double.IsInfinity(v))
                    throw new ArithmeticException();
            }

            ctx.Stack.SetTopPosition(sp);
            ctx.Registers[DarksVMConstants.REG_SP].U4 = sp;
            state = ExecutionState.Next;
        }

19 Source : IconFile.cs
with MIT License
from ahopper

internal static (Size, Matrix) CalculateSizeAndTransform(Size availableSize, Rect shapeBounds, Stretch Stretch)
        {
            Size shapeSize = new Size(shapeBounds.Right, shapeBounds.Bottom);
            Matrix translate = Matrix.Idenreplacedy;
            double desiredX = availableSize.Width;
            double desiredY = availableSize.Height;
            double sx = 0.0;
            double sy = 0.0;

            if (Stretch != Stretch.None)
            {
                shapeSize = shapeBounds.Size;
                translate = Matrix.CreateTranslation(-(Vector)shapeBounds.Position);
            }

            if (double.IsInfinity(availableSize.Width))
            {
                desiredX = shapeSize.Width;
            }

            if (double.IsInfinity(availableSize.Height))
            {
                desiredY = shapeSize.Height;
            }

            if (shapeBounds.Width > 0)
            {
                sx = desiredX / shapeSize.Width;
            }

            if (shapeBounds.Height > 0)
            {
                sy = desiredY / shapeSize.Height;
            }

            if (double.IsInfinity(availableSize.Width))
            {
                sx = sy;
            }

            if (double.IsInfinity(availableSize.Height))
            {
                sy = sx;
            }

            switch (Stretch)
            {
                case Stretch.Uniform:
                    sx = sy = Math.Min(sx, sy);
                    break;
                case Stretch.UniformToFill:
                    sx = sy = Math.Max(sx, sy);
                    break;
                case Stretch.Fill:
                    if (double.IsInfinity(availableSize.Width))
                    {
                        sx = 1.0;
                    }

                    if (double.IsInfinity(availableSize.Height))
                    {
                        sy = 1.0;
                    }

                    break;
                default:
                    sx = sy = 1;
                    break;
            }

            var transform = translate * Matrix.CreateScale(sx, sy);
            var size = new Size(shapeSize.Width * sx, shapeSize.Height * sy);
            return (size, transform);
        }

19 Source : JsonConvert.cs
with MIT License
from akaskela

private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
        {
            if (floatFormatHandling == FloatFormatHandling.Symbol || !(double.IsInfinity(value) || double.IsNaN(value)))
            {
                return text;
            }

            if (floatFormatHandling == FloatFormatHandling.DefaultValue)
            {
                return (!nullable) ? "0.0" : Null;
            }

            return quoteChar + text + quoteChar;
        }

19 Source : JsonConvert.cs
with MIT License
from akaskela

private static string EnsureDecimalPlace(double value, string text)
        {
            if (double.IsNaN(value) || double.IsInfinity(value) || text.IndexOf('.') != -1 || text.IndexOf('E') != -1 || text.IndexOf('e') != -1)
            {
                return text;
            }

            return text + ".0";
        }

19 Source : JsonSerializer.cs
with MIT License
from AlenToma

private void WriteValue(object obj)
        {
            if (obj == null || obj is DBNull)
                _output.Append("null");

            else if (obj is string || obj is char)
                WriteString(obj.ToString());

            else if (obj is Guid)
                WriteGuid((Guid)obj);

            else if (obj is bool)
                _output.Append(((bool)obj) ? "true" : "false"); // conform to standard

            else if (
                obj is int || obj is long ||
                obj is decimal ||
                obj is byte || obj is short ||
                obj is sbyte || obj is ushort ||
                obj is uint || obj is ulong
            )
                _output.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));

            else if (obj is double || obj is Double)
            {
                double d = (double)obj;
                if (double.IsNaN(d))
                    _output.Append("\"NaN\"");
                else if (double.IsInfinity(d))
                {
                    _output.Append("\"");
                    _output.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
                    _output.Append("\"");
                }
                else
                    _output.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
            }
            else if (obj is float || obj is Single)
            {
                float d = (float)obj;
                if (float.IsNaN(d))
                    _output.Append("\"NaN\"");
                else if (float.IsInfinity(d))
                {
                    _output.Append("\"");
                    _output.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
                    _output.Append("\"");
                }
                else
                    _output.Append(((IConvertible)obj).ToString(NumberFormatInfo.InvariantInfo));
            }

            else if (obj is DateTime)
                WriteDateTime((DateTime)obj);

            else if (obj is DateTimeOffset)
                WriteDateTimeOffset((DateTimeOffset)obj);

            else if (obj is TimeSpan)
                _output.Append(((TimeSpan)obj).Ticks);

            else if (_params.KVStyleStringDictionary == false &&
                obj is IEnumerable<KeyValuePair<string, object>>)

                WriteStringDictionary((IEnumerable<KeyValuePair<string, object>>)obj);


            else if (_params.KVStyleStringDictionary == false && obj is IDictionary &&
                obj.GetType().IsGenericType && Reflection.Instance.GetGenericArguments(obj.GetType())[0] == typeof(string))

                WriteStringDictionary((IDictionary)obj);
            else if (obj is IDictionary)
                WriteDictionary((IDictionary)obj);
#if !SILVERLIGHT
            else if (obj is DataSet)
                WriteDataset((DataSet)obj);

            else if (obj is DataTable)
                this.WriteDataTable((DataTable)obj);
#endif
            else if (obj is byte[])
                WriteBytes((byte[])obj);

            else if (obj is StringDictionary)
                WriteSD((StringDictionary)obj);

            else if (obj is NameValueCollection)
                WriteNV((NameValueCollection)obj);

            else if (obj is IEnumerable)
                WriteArray((IEnumerable)obj);

            else if (obj is Enum)
                WriteEnum((Enum)obj);

            else if (Reflection.Instance.IsTypeRegistered(obj.GetType()))
                WriteCustom(obj);

            else
                WriteObject(obj);
        }

19 Source : HexGrid.cs
with MIT License
from AlexanderSharykin

protected override Size MeasureOverride(Size availableSize)
        {
            double w = availableSize.Width;
            double h = availableSize.Height;            

            // if there is Infinity size dimension
            if (Double.IsInfinity(w) || Double.IsInfinity(h))
            {
                // determine maximum desired size
                h = 0;
                w = 0;
                foreach (UIElement e in InternalChildren)
                {
                    e.Measure(availableSize);
                    var s = e.DesiredSize;
                    if (s.Height > h)
                        h = s.Height;
                    if (s.Width > w)
                        w = s.Width;
                }                

                // multiply maximum size to RowCount and ColumnCount to get total size
                if (Orientation == Orientation.Horizontal)
                    return new Size(w*(ColumnCount * 3 + 1)/4, h*(RowCount * 2 + 1)/2);

                return new Size(w*(ColumnCount * 2 + 1)/2, h*(RowCount * 3 + 1)/4);
            }            

            return availableSize;
        }

19 Source : LogarithmicAxis.cs
with MIT License
from AlexGyver

public override void CoerceActualMaxMin()
        {
            if (double.IsNaN(this.ActualMinimum) || double.IsInfinity(this.ActualMinimum))
            {
                this.ActualMinimum = 1;
            }

            if (this.ActualMinimum <= 0)
            {
                this.ActualMinimum = 1;
            }

            if (this.ActualMaximum <= this.ActualMinimum)
            {
                this.ActualMaximum = this.ActualMinimum * 100;
            }

            base.CoerceActualMaxMin();
        }

19 Source : LogarithmicAxis.cs
with MIT License
from AlexGyver

public override void GetTickValues(
            out IList<double> majorLabelValues, out IList<double> majorTickValues, out IList<double> minorTickValues)
        {
            if (this.ActualMinimum <= 0)
            {
                this.ActualMinimum = 0.1;
            }

            double logBase = Math.Log(this.Base);
            var e0 = (int)Math.Floor(Math.Log(this.ActualMinimum) / logBase);
            var e1 = (int)Math.Ceiling(Math.Log(this.ActualMaximum) / logBase);

            // find the min & max values for the specified base
            // round to max 10 digits
            double p0 = Math.Pow(this.Base, e0);
            double p1 = Math.Pow(this.Base, e1);
            double d0 = Math.Round(p0, 10);
            double d1 = Math.Round(p1, 10);
            if (d0 <= 0)
            {
                d0 = p0;
            }

            double d = d0;
            majorTickValues = new List<double>();
            minorTickValues = new List<double>();

            double epsMin = this.ActualMinimum * 1e-6;
            double epsMax = this.ActualMaximum * 1e-6;

            while (d <= d1 + epsMax)
            {
                // d = RemoveNoiseFromDoubleMath(d);
                if (d >= this.ActualMinimum - epsMin && d <= this.ActualMaximum + epsMax)
                {
                    majorTickValues.Add(d);
                }

                for (int i = 1; i < this.Base; i++)
                {
                    double d2 = d * (i + 1);
                    if (d2 > d1 + double.Epsilon)
                    {
                        break;
                    }

                    if (d2 > this.ActualMaximum)
                    {
                        break;
                    }

                    if (d2 >= this.ActualMinimum && d2 <= this.ActualMaximum)
                    {
                        minorTickValues.Add(d2);
                    }
                }

                d *= this.Base;
                if (double.IsInfinity(d))
                {
                    break;
                }

                if (d < double.Epsilon)
                {
                    break;
                }

                if (double.IsNaN(d))
                {
                    break;
                }
            }

            if (majorTickValues.Count < 2)
            {
                base.GetTickValues(out majorLabelValues, out majorTickValues, out minorTickValues);
            }
            else
            {
                majorLabelValues = majorTickValues;
            }
        }

19 Source : RangeAxis.cs
with MIT License
from AlexGyver

public void Include(double p)
        {
            if (double.IsNaN(p) || double.IsInfinity(p))
                return;

            if (double.IsNaN(ActualMinimum))
                ActualMinimum = p;
            else
                ActualMinimum = Math.Min(ActualMinimum, p);

            if (double.IsNaN(ActualMaximum))
                ActualMaximum = p;
            else
                ActualMaximum = Math.Max(ActualMaximum, p);
        }

19 Source : IntervalBarSeries.cs
with MIT License
from AlexGyver

public virtual bool IsValidPoint(double v, Axis yaxis)
        {
            return !double.IsNaN(v) && !double.IsInfinity(v);
        }

19 Source : BoxPlotSeries.cs
with MIT License
from AlexGyver

public virtual bool IsValidPoint(BoxPloreplacedem item, Axis xaxis, Axis yaxis)
        {
            return !double.IsNaN(item.X) && !double.IsInfinity(item.X) && !item.Values.Any(double.IsNaN)
                   && !item.Values.Any(double.IsInfinity) && (xaxis != null && xaxis.IsValidValue(item.X))
                   && (yaxis != null && item.Values.All(yaxis.IsValidValue));
        }

19 Source : HighLowSeries.cs
with MIT License
from AlexGyver

public virtual bool IsValidItem(HighLowItem pt, Axis xaxis, Axis yaxis)
        {
            return !double.IsNaN(pt.X) && !double.IsInfinity(pt.X) && !double.IsNaN(pt.High)
                   && !double.IsInfinity(pt.High) && !double.IsNaN(pt.Low) && !double.IsInfinity(pt.Low);
        }

19 Source : XYAxisSeries.cs
with MIT License
from AlexGyver

protected virtual bool IsValidPoint(IDataPoint pt, Axis xaxis, Axis yaxis)
        {
            return !double.IsNaN(pt.X) && !double.IsInfinity(pt.X) && !double.IsNaN(pt.Y) && !double.IsInfinity(pt.Y)
                   && (xaxis != null && xaxis.IsValidValue(pt.X)) && (yaxis != null && yaxis.IsValidValue(pt.Y));
        }

19 Source : BarSeriesBase.cs
with MIT License
from AlexGyver

protected virtual bool IsValidPoint(double v, Axis yaxis)
        {
            return !double.IsNaN(v) && !double.IsInfinity(v);
        }

19 Source : RectangleBarSeries.cs
with MIT License
from AlexGyver

protected virtual bool IsValid(double v)
        {
            return !double.IsNaN(v) && !double.IsInfinity(v);
        }

19 Source : ScatterSeries.cs
with MIT License
from AlexGyver

public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate)
        {
            if (this.XAxis == null || this.YAxis == null)
            {
                return null;
            }

            if (interpolate)
            {
                return null;
            }

            TrackerHitResult result = null;
            double minimumDistance = double.MaxValue;
            int i = 0;

            var xaxisreplacedle = this.XAxis.replacedle ?? "X";
            var yaxisreplacedle = this.YAxis.replacedle ?? "Y";
            var colorAxisreplacedle = (this.ColorAxis != null ? this.ColorAxis.replacedle : null) ?? "Z";

            var formatString = TrackerFormatString;
            if (string.IsNullOrEmpty(this.TrackerFormatString))
            {
                // Create a default format string
                formatString = "{1}: {2}\n{3}: {4}";
                if (this.ColorAxis != null)
                {
                    formatString += "\n{5}: {6}";
                }
            }

            foreach (var p in this.Points)
            {
                if (p.X < this.XAxis.ActualMinimum || p.X > this.XAxis.ActualMaximum || p.Y < this.YAxis.ActualMinimum || p.Y > this.YAxis.ActualMaximum)
                {
                    i++;
                    continue;
                }

                var dp = new DataPoint(p.X, p.Y);
                var sp = Axis.Transform(dp, this.XAxis, this.YAxis);
                double dx = sp.x - point.x;
                double dy = sp.y - point.y;
                double d2 = (dx * dx) + (dy * dy);

                if (d2 < minimumDistance)
                {
                    var item = this.Gereplacedem(i);

                    object xvalue = this.XAxis.GetValue(dp.X);
                    object yvalue = this.YAxis.GetValue(dp.Y);
                    object zvalue = null;

                    var scatterPoint = p as ScatterPoint;
                    if (scatterPoint != null)
                    {
                        if (!double.IsNaN(scatterPoint.Value) && !double.IsInfinity(scatterPoint.Value))
                        {
                            zvalue = scatterPoint.Value;
                        }
                    }

                    var text = StringHelper.Format(
                        this.ActualCulture,
                        formatString,
                        item,
                        this.replacedle,
                        xaxisreplacedle,
                        xvalue,
                        yaxisreplacedle,
                        yvalue,
                        colorAxisreplacedle,
                        zvalue);

                    result = new TrackerHitResult(this, dp, sp, item, i, text);

                    minimumDistance = d2;
                }

                i++;
            }

            return result;
        }

19 Source : ScatterSeries.cs
with MIT License
from AlexGyver

public virtual bool IsValidPoint(ScatterPoint pt, Axis xaxis, Axis yaxis)
        {
            return !double.IsNaN(pt.X) && !double.IsInfinity(pt.X) && !double.IsNaN(pt.Y) && !double.IsInfinity(pt.Y)
                   && (xaxis != null && xaxis.IsValidValue(pt.X)) && (yaxis != null && yaxis.IsValidValue(pt.Y));
        }

19 Source : TermBuilder.cs
with MIT License
from alexshtf

public static Term Power(Term t, double power)
        {
            Guard.NotNull(t, nameof(t));
            Guard.MustHold(!double.IsNaN(power) && !double.IsInfinity(power) && power != 0, "power must be finite and non-zero");

            return new ConstPower(t, power);
        }

19 Source : ChartClusterPainter.cs
with Apache License 2.0
from AlexWan

private void _chart_MouseMove2(object sender, MouseEventArgs e)
        {
            if (_chart.Cursor == Cursors.SizeAll)
            {
                return;
            }
            if (_chart.ChartAreas.Count < 1)
            {
                return;
            }

            if (e.Button == MouseButtons.Left &&
                _chart.Cursor == Cursors.Arrow)
            {
                return;
            }

            if (_volume.VolumeClusters == null ||
                _volume.VolumeClusters.Count < 3)
            {
                return;
            }

            if (_areaPositions.Count != _chart.ChartAreas.Count ||
                _areaPositions.Find(posi => posi.RightPoint == 0) != null)
            {
                _areaPositions = new List<ChartAreaPosition>();
                ReloadChartArereplacedize();
            }

            if (_chart.Cursor == Cursors.Hand ||
                _chart.Cursor == Cursors.SizeNS ||
                _areaPositions == null)
            {
                return;
            }

            ChartAreaPosition myPosition = null;

            MouseEventArgs mouse = (MouseEventArgs)e;

            ChartAreaPosition pos = _areaPositions[0];

            if ((pos.LeftPoint < e.X &&
                 pos.RightPoint > e.X &&
                 pos.DownPoint - 30 < e.Y &&
                 pos.DownPoint - 10 > e.Y)
                ||
                (mouse.Button == MouseButtons.Left && _chart.Cursor == Cursors.SizeWE && pos.LeftPoint < e.X &&
                 pos.RightPoint > e.X &&
                 pos.DownPoint - 200 < e.Y &&
                 pos.DownPoint + 100 > e.Y))
            {
                myPosition = pos;
                _chart.Cursor = Cursors.SizeWE;
            }
            else
            {
                pos.ValueYMouseOnClickStart = 0;
                pos.HeightAreaOnClick = 0;
                pos.ValueYChartOnClick = 0;
            }


            if (myPosition == null)
            {
                _chart.Cursor = Cursors.Arrow;
                return;
            }

            if (mouse.Button != MouseButtons.Left)
            {
                myPosition.ValueXMouseOnClickStart = 0;
                myPosition.CountXValuesChartOnClickStart = 0;
                return;
            }

            if (myPosition.ValueXMouseOnClickStart == 0)
            {
                myPosition.ValueXMouseOnClickStart = e.X;

                if (double.IsNaN(_chart.ChartAreas[0].AxisY.ScaleView.Size))
                {
                    int max = _volume.VolumeClusters.Count;

                    myPosition.CountXValuesChartOnClickStart = max;
                }
                else
                {
                    myPosition.CountXValuesChartOnClickStart = (int)_chart.ChartAreas[0].AxisY.ScaleView.Size;
                }
                return;
            }


            double persentMove = Math.Abs(myPosition.ValueXMouseOnClickStart - e.X) / _host.Child.Width;

            if (double.IsInfinity(persentMove) ||
                persentMove == 0)
            {
                return;
            }

            //double concateValue = 100*persentMove*5;


            int maxSize = _volume.VolumeClusters.Count;


            if (myPosition.ValueXMouseOnClickStart < e.X)
            {
                if (myPosition.Area.Position.Height < 10)
                {
                    return;
                }

                double newVal = myPosition.CountXValuesChartOnClickStart +
                             myPosition.CountXValuesChartOnClickStart * persentMove * 3;


                if (newVal > maxSize)
                {
                    _chart.ChartAreas[0].AxisY.ScaleView.Size = Double.NaN;
                }
                else
                {

                    if (newVal + _chart.ChartAreas[0].AxisY.ScaleView.Position > maxSize)
                    {
                        _chart.ChartAreas[0].AxisY.ScaleView.Position = maxSize - newVal;
                    }

                    _chart.ChartAreas[0].AxisY.ScaleView.Size = newVal;
                    //RePaintRightLebels();

                    if (_chart.ChartAreas[0].AxisY.ScaleView.Position + newVal > maxSize)
                    {
                        _chart.ChartAreas[0].AxisY.ScaleView.Position = maxSize - newVal;
                    }
                }
            }
            else if (myPosition.ValueXMouseOnClickStart > e.X)
            {
                double newVal = myPosition.CountXValuesChartOnClickStart -
               myPosition.CountXValuesChartOnClickStart * persentMove * 3;


                if (newVal < 5)
                {
                    _chart.ChartAreas[0].AxisY.ScaleView.Size = 5;
                }
                else
                {
                    if (!double.IsNaN(_chart.ChartAreas[0].AxisY.ScaleView.Size))
                    {


                        _chart.ChartAreas[0].AxisY.ScaleView.Position = _chart.ChartAreas[0].AxisY.ScaleView.Position + _chart.ChartAreas[0].AxisY.ScaleView.Size - newVal;
                    }

                    _chart.ChartAreas[0].AxisY.ScaleView.Size = newVal;
                    if (_chart.ChartAreas[0].AxisY.ScaleView.Position + newVal > maxSize)
                    {
                        double newStartPos = maxSize - newVal;
                        if (newStartPos < 0)
                        {
                            newStartPos = 0;
                        }
                        _chart.ChartAreas[0].AxisY.ScaleView.Position = newStartPos;
                    }

                }
            }

            ResizeXAxis();
            ResizeYAxis();
        }

19 Source : RandomExtensions.cs
with Apache License 2.0
from allenai

public static double NextGaussian(this Random r, double mu = 0, double sigma = 1) {
            var u1 = r.NextDouble();
            var u2 = r.NextDouble();
            var rand_std_normal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);
            var rand_normal = mu + sigma * rand_std_normal;

            // Very rarely, it is possible to have underflow or an infinity if u1/u1 = 0.
            // In such a case, just return the mean.
            if (
                Double.IsNaN(rand_normal)
                || Double.IsInfinity(rand_normal)
                || Double.IsNegativeInfinity(rand_normal)
            ) {
                return mu;
            }

            return rand_normal;
        }

19 Source : NavigationView.properties.cs
with MIT License
from amwx

private static double CoercePropertyValueToGreaterThanZero(IAvaloniaObject arg1, double arg2)
        {
            if (double.IsNaN(arg2) || double.IsInfinity(arg2))
                return 0;
            return Math.Max(arg2, 0.0);
        }

19 Source : CustomWindowManager.cs
with GNU General Public License v3.0
from AndreiFedarets

private void CloneSize(Window window, object view)
        {
            Control viewControl = view as Control;
            if (viewControl == null)
            {
                return;
            }
            Thickness padding = (Thickness)viewControl.GetValue(Control.PaddingProperty);
            Thickness margin = viewControl.Margin;
            double extraHeight = margin.Top + margin.Bottom + padding.Top + padding.Bottom + SystemParameters.WindowCaptionHeight + SystemParameters.ResizeFrameHorizontalBorderHeight * 2;
            double extraWidth = margin.Left + margin.Right + padding.Left + padding.Right + SystemParameters.ResizeFrameVerticalBorderWidth * 2;
            if (!double.IsNaN(viewControl.MinHeight) && !double.IsInfinity(viewControl.MinHeight))
            {
                window.MinHeight = viewControl.MinHeight + extraHeight;
                window.Height = window.MinHeight;
            }
            if (!double.IsNaN(viewControl.MinWidth) && !double.IsInfinity(viewControl.MinWidth))
            {
                window.MinWidth = viewControl.MinWidth + extraWidth;
                window.Width = window.MinWidth;
            }
            if (!double.IsNaN(viewControl.MaxHeight) && !double.IsInfinity(viewControl.MaxHeight))
            {
                window.MaxHeight = viewControl.MaxHeight = extraHeight;
            }
            if (!double.IsNaN(viewControl.MaxWidth) && !double.IsInfinity(viewControl.MaxWidth))
            {
                window.MaxWidth = viewControl.MaxWidth + extraWidth;
            }
            if (!double.IsNaN(viewControl.Height) && !double.IsInfinity(viewControl.Height))
            {
                window.Height = viewControl.Height + extraHeight;
            }
            if (!double.IsNaN(viewControl.Width) && !double.IsInfinity(viewControl.Width))
            {
                window.Width = viewControl.Width + extraWidth;
            }
        }

19 Source : TextEditor.cs
with MIT License
from AngryCarrot789

public Rect GetCaretLocation()
        {
            try
            {
                if (CaretIndex >= 0)
                {
                    Rect rect = GetRectFromCharacterIndex(CaretIndex);
                    if (double.IsInfinity(rect.X) || double.IsInfinity(rect.Y))
                        return new Rect(0, 0, 0, 0);
                    return rect;
                }
                else return new Rect(0, 0, 0, 0);
            }
            catch { return new Rect(0, 0, 0, 0); }
        }

19 Source : ProtoWriter.cs
with MIT License
from AnotherEnd15

public
#if !FEAT_SAFE
            unsafe
#endif

                static void WriteDouble(double value, ProtoWriter writer)
        {
            if (writer == null) throw new ArgumentNullException("writer");
            switch (writer.wireType)
            {
                case WireType.Fixed32:
                    float f = (float)value;
                    if (float.IsInfinity(f) && !double.IsInfinity(value))
                    {
                        throw new OverflowException();
                    }
                    ProtoWriter.WriteSingle(f, writer);
                    return;
                case WireType.Fixed64:
#if FEAT_SAFE
                    ProtoWriter.WriteInt64(BitConverter.ToInt64(BitConverter.GetBytes(value), 0), writer);
#else
                    ProtoWriter.WriteInt64(*(long*)&value, writer);
#endif
                    return;
                default:
                    throw CreateException(writer);
            }
        }

19 Source : GenTests.cs
with Apache License 2.0
from AnthonyLloyd

[Fact]
        public void Double_Normal()
        {
            Gen.Double.Normal
            .Sample(d => !double.IsNaN(d) && !double.IsInfinity(d));
        }

19 Source : GenTests.cs
with Apache License 2.0
from AnthonyLloyd

[Fact]
        public void Double_NormalNegative()
        {
            Gen.Double.NormalNegative
            .Sample(d => !double.IsNaN(d) && !double.IsInfinity(d) && d < 0.0);
        }

19 Source : GenTests.cs
with Apache License 2.0
from AnthonyLloyd

[Fact]
        public void Double_NormalNonNegative()
        {
            Gen.Double.NormalNonNegative
            .Sample(d => !double.IsNaN(d) && !double.IsInfinity(d) && d >= 0.0);
        }

19 Source : GenTests.cs
with Apache License 2.0
from AnthonyLloyd

[Fact]
        public void Double_NormalPositive()
        {
            Gen.Double.NormalPositive
            .Sample(d => !double.IsNaN(d) && !double.IsInfinity(d) && d > 0.0);
        }

19 Source : GenTests.cs
with Apache License 2.0
from AnthonyLloyd

[Fact]
        public void Double_NormalNonPositive()
        {
            Gen.Double.NormalNonPositive
            .Sample(d => !double.IsNaN(d) && !double.IsInfinity(d) && d <= 0.0);
        }

19 Source : DownloaderEtaConverter.cs
with GNU General Public License v3.0
from antikmozib

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return String.Empty;
            try
            {
                double.TryParse(value.ToString(), out double remaining);
                if (remaining > 0 && !double.IsInfinity(remaining))
                {
                    TimeSpan t = TimeSpan.FromMilliseconds(remaining);
                    if ((int)t.TotalHours == 0)
                    {
                        return t.Minutes + "m " + t.Seconds + "s";
                    }
                    return (int)t.TotalHours + "h " + t.Minutes + "m " + t.Seconds + "s";
                }
            }
            catch
            {
                return String.Empty;
            }
            return string.Empty;
        }

19 Source : AbnormalDetection.cs
with MIT License
from aoso3

public double[][][] Detect()
        {

            for (int i = 0; i < row; i++)
            {

                for (int j = 0; j < col; j++)
                {
                   List<double> eucledianDist = new List<double>();

                    for (int k = 0; k < total_frames; k++)
                    {
                        
                        for (int q = 0; q < cluster_n; q++)
                        {
                            double temp = 0;
                            for (int w = 0; w < 8; w++)
                                temp += MegaBlock[i][j][k][w] * MegaBlock[i][j][k][w] - codewords[i][j][q][w] * codewords[i][j][q][w];

                            eucledianDist.Add(Math.Sqrt(temp));

                        }

                        if (!Double.IsNaN(eucledianDist.Min()) && !Double.IsInfinity(eucledianDist.Min()))
                            minDistMatrix[k][i][j] = eucledianDist.Min();
                        else
                            minDistMatrix[k][i][j] = 0;

                        eucledianDist.Clear();

                    }

                }

             
            }

            return minDistMatrix;
            
        }

See More Examples