using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BotSharp.Algorithm.HiddenMarkovModel.MathHelpers
{
public class PolynomialHelper
{
///
/// Evaluates polynomial of degree N
///
///
public static double Polevl(double x, double[] coef, int n)
{
double ans;
ans = coef[0];
for (int i = 1; i <= n; i++)
ans = ans * x + coef[i];
return ans;
}
///
/// Evaluates polynomial of degree N with assumption that coef[N] = 1.0
///
///
public static double P1evl(double x, double[] coef, int n)
{
double ans;
ans = x + coef[0];
for (int i = 1; i < n; i++)
ans = ans * x + coef[i];
return ans;
}
}
}