示例#1
0
 private static double[] DoubleArray <T>(T[] dataIn)
 {
     double[] dataOut = new double[dataIn.Length];
     for (int i = 0; i < dataIn.Length; i++)
     {
         dataOut[i] = NumericConversion.GenericToDouble(ref dataIn[i]);
     }
     return(dataOut);
 }
示例#2
0
        /// <summary>
        /// Throw an exception if an element is less than the previous element
        /// </summary>
        public static void AssertDoesNotDescend <T>(string label, T[] values, int minIndex = 0, int?maxIndex = null)
        {
            if (maxIndex is null)
            {
                maxIndex = values.Length - 1;
            }

            label = ValidLabel(label);

            if (values is null)
            {
                throw new InvalidOperationException($"{label} must not be null");
            }

            for (int i = minIndex; i < maxIndex; i++)
            {
                if (NumericConversion.GenericToDouble(ref values[i]) > NumericConversion.GenericToDouble(ref values[i + 1]))
                {
                    throw new InvalidOperationException($"{label} must not descend: " +
                                                        $"{label}[{i}]={values[i]} but {label}[{i + 1}]={values[i + 1]}");
                }
            }
        }
示例#3
0
 public static Coordinate FromGeneric <T>(T x, T y)
 {
     return(new(NumericConversion.GenericToDouble(ref x), NumericConversion.GenericToDouble(ref y)));
 }