diff --git a/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs b/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs index 142db86d..5de8000c 100644 --- a/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs +++ b/src/Numerics/Differentiation/FiniteDifferenceCoefficients.cs @@ -34,13 +34,13 @@ using MathNet.Numerics.LinearAlgebra.Double; namespace MathNet.Numerics.Differentiation { /// - /// Class to calculate finite difference coefficients using Taylor series expansion method. + /// Class to calculate finite difference coefficients using Taylor series expansion method. /// /// /// For n points, coefficients are calculated up to the maximum derivative order possible (n-1). - /// The current function value position specifies the "center" for surrounding coefficients. + /// The current function value position specifies the "center" for surrounding coefficients. /// Selecting the first, middle or last positions represent forward, backwards and central difference methods. - /// + /// /// /// public class FiniteDifferenceCoefficients @@ -109,7 +109,7 @@ namespace MathNet.Numerics.Differentiation { var c = new double[points][,]; - // For ever possible center given the number of points, compute ever possible coefficeint for all possible orders. + // For ever possible center given the number of points, compute ever possible coefficient for all possible orders. for (int center = 0; center < points; center++) { // Deltas matrix for center located at 'center'. @@ -131,7 +131,11 @@ namespace MathNet.Numerics.Differentiation var fac = SpecialFunctions.Factorial(points); for (int j = 0; j < points; j++) for (int k = 0; k < points; k++) +#if PORTABLE + c[center][j, k] = (Math.Round(c[center][j, k] * fac)) / fac; +#else c[center][j, k] = (Math.Round(c[center][j, k] * fac, MidpointRounding.AwayFromZero)) / fac; +#endif } _coefficients = c;