Пример #1
0
 private GaussEliminationResultType CheckGaussEliminationResultType()
 {
     for (int row = 0; row < Rows; row++)
     {
         // Check single row for all zeros
         bool allZeros = true;
         for (int column = 0; column < Columns - 1; column++)
         {
             var matrixValue = (dynamic)this[row, column];
             if (!NumericUtilities.DoubleCompare((double)matrixValue, 0.0))
             {
                 allZeros = false;
                 break;
             }
         }
         if (allZeros)
         {
             // Two possible results: Infinity results, No valid result
             var equationResult = (dynamic)this[row, Columns - 1];
             return(NumericUtilities.DoubleCompare((double)equationResult, 0.0)
                 ? GaussEliminationResultType.InfinityResults : GaussEliminationResultType.NoValidResult);
         }
     }
     return(GaussEliminationResultType.ValidResult);
 }
Пример #2
0
        private static double GetWeightsSumThrowIfZero(List <WeightedValue> values)
        {
            var sumWeights = values.Aggregate(0.0, (prev, current) => prev + current.Weight);

            if (NumericUtilities.DoubleCompare(sumWeights, 0.0))
            {
                throw new ArgumentException("Sum of weights cannot be zero");
            }
            return(sumWeights);
        }