<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDevelopment_Class%2FPolynomial</id>
		<title>Csharp/C Sharp/Development Class/Polynomial - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDevelopment_Class%2FPolynomial"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Polynomial&amp;action=history"/>
		<updated>2026-04-29T22:54:59Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Polynomial&amp;diff=1197&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Polynomial&amp;diff=1197&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Polynomial&amp;diff=1198&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Polynomial&amp;diff=1198&amp;oldid=prev"/>
				<updated>2010-05-26T11:43:27Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Polynomial all==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
A Programmer&amp;quot;s Introduction to C# (Second Edition)&lt;br /&gt;
by Eric Gunnerson&lt;br /&gt;
Publisher: Apress  L.P.&lt;br /&gt;
ISBN: 1-893115-62-3&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;A href=&amp;quot;http://www.nfex.ru/Code/CSharpDownload/Polynomialall.zip&amp;quot;&amp;gt;Polynomialall.zip( 11 k)&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The simplest polynomial implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
A Programmer&amp;quot;s Introduction to C# (Second Edition)&lt;br /&gt;
by Eric Gunnerson&lt;br /&gt;
Publisher: Apress  L.P.&lt;br /&gt;
ISBN: 1-893115-62-3&lt;br /&gt;
*/&lt;br /&gt;
//Compile:&lt;br /&gt;
//csc /debug- /o+ /out:polynomial.exe /r:system.dll  Counter.cs Driver.cs PolySimple.cs polynomial.cs ipoly.cs&lt;br /&gt;
&lt;br /&gt;
//File:PolySimple.cs&lt;br /&gt;
namespace Polynomial&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    /// &amp;lt;summary&amp;gt;&lt;br /&gt;
    /// The simplest polynomial implementation&lt;br /&gt;
    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
    /// &amp;lt;description&amp;gt;&lt;br /&gt;
    /// This implementation loops through the coefficients and evaluates each&lt;br /&gt;
    /// term of the polynomial.&lt;br /&gt;
    /// &amp;lt;/description&amp;gt;&lt;br /&gt;
    class PolySimple: Polynomial&lt;br /&gt;
    {&lt;br /&gt;
        public PolySimple(params double[] coefficients): base(coefficients)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
        public override double Evaluate(double value)&lt;br /&gt;
        {&lt;br /&gt;
            double retval = coefficients[0];&lt;br /&gt;
    &lt;br /&gt;
            double f = value;&lt;br /&gt;
            for (int i = 1; i &amp;lt; coefficients.Length; i++)&lt;br /&gt;
            {&lt;br /&gt;
                retval += coefficients[i] * f;&lt;br /&gt;
                f *= value;&lt;br /&gt;
            }&lt;br /&gt;
            return(retval);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//File:Polynomial.cs&lt;br /&gt;
namespace Polynomial&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    using PolyInterface;&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// The abstract class all implementations inherit from&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
    public abstract class Polynomial&lt;br /&gt;
    {&lt;br /&gt;
        public Polynomial(params double[] coefficients)&lt;br /&gt;
        {&lt;br /&gt;
            this.coefficients = new double[coefficients.Length];&lt;br /&gt;
            for (int i = 0; i &amp;lt; coefficients.Length; i++)&lt;br /&gt;
                this.coefficients[i] = coefficients[i];&lt;br /&gt;
        }&lt;br /&gt;
        public abstract double Evaluate(double value);&lt;br /&gt;
        protected double[] coefficients = null;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//File:IPoly.cs&lt;br /&gt;
namespace PolyInterface&lt;br /&gt;
{&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// The interface that implementations will implement&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
    public interface IPolynomial&lt;br /&gt;
    {&lt;br /&gt;
        double Eval(double value);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//File:Driver.cs&lt;br /&gt;
namespace Polynomial&lt;br /&gt;
{&lt;br /&gt;
    using System;&lt;br /&gt;
    using System.Diagnostics;&lt;br /&gt;
    /// &amp;lt;summary&amp;gt;&lt;br /&gt;
    /// Driver class for the project&lt;br /&gt;
    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
    public class Driver&lt;br /&gt;
    {&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Times the evaluation of a polynomial&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name=&amp;quot;p&amp;quot;&amp;gt;The polynomial to evaluate&amp;lt;/param&amp;gt;&lt;br /&gt;
        public static double TimeEvaluate(Polynomial p)&lt;br /&gt;
        {&lt;br /&gt;
            double value = 2.0;&lt;br /&gt;
            Console.WriteLine(&amp;quot;{0}&amp;quot;, p.GetType().Name);&lt;br /&gt;
                // Time the first iteration. This one is done&lt;br /&gt;
                // separately so that we can figure out the startup&lt;br /&gt;
                // overhead separately...&lt;br /&gt;
            long start = Counter.Value;&lt;br /&gt;
            p.Evaluate(0.0);    // do the first iteration.&lt;br /&gt;
            long delta = Counter.Value - start;&lt;br /&gt;
            Console.WriteLine(&amp;quot;Overhead = {0:f2} seconds&amp;quot;, (double) delta/Counter.Frequency);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Eval({0}) = {1}&amp;quot;, value, p.Evaluate(value));&lt;br /&gt;
            int limit = 100000;&lt;br /&gt;
            start = Counter.Value;&lt;br /&gt;
    &lt;br /&gt;
                // Evaluate the polynomial the required number of&lt;br /&gt;
                // times.&lt;br /&gt;
            double result = 0;&lt;br /&gt;
            for (int i = 0; i &amp;lt; limit; i++)&lt;br /&gt;
            {&lt;br /&gt;
                result += p.Evaluate(value);&lt;br /&gt;
            }&lt;br /&gt;
            delta = Counter.Value - start;&lt;br /&gt;
            &lt;br /&gt;
            double ips = (double) limit * ((double)Counter.Frequency / (double) delta);&lt;br /&gt;
            Console.WriteLine(&amp;quot;Evalutions/Second = {0:f0}&amp;quot;, ips);&lt;br /&gt;
            Console.WriteLine();&lt;br /&gt;
            return(ips);&lt;br /&gt;
        }&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Run all implementations for a given set of coefficients&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        /// &amp;lt;param name=&amp;quot;coeff&amp;quot;&amp;gt; &amp;lt;/param&amp;gt;&lt;br /&gt;
        public static void Eval(double[] coeff)&lt;br /&gt;
        {&lt;br /&gt;
            Polynomial[] imps = new Polynomial []&lt;br /&gt;
                {&lt;br /&gt;
                    new PolySimple(coeff),&lt;br /&gt;
            };&lt;br /&gt;
            double[] results = new double[imps.Length];&lt;br /&gt;
            for (int index = 0; index &amp;lt; imps.Length; index++)&lt;br /&gt;
            {&lt;br /&gt;
                results[index] = TimeEvaluate(imps[index]);&lt;br /&gt;
            }&lt;br /&gt;
            Console.WriteLine(&amp;quot;Results for length = {0}&amp;quot;, coeff.Length);&lt;br /&gt;
            for (int index = 0; index &amp;lt; imps.Length; index++)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;{0} = {1:f0}&amp;quot;, imps[index], results[index]);&lt;br /&gt;
            }&lt;br /&gt;
            Console.WriteLine();&lt;br /&gt;
        }&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Maim function.&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        public static void Main()&lt;br /&gt;
        {&lt;br /&gt;
            Eval(new Double[] {5.5});&lt;br /&gt;
                // Evaluate the first polynomial, with 7 elements&lt;br /&gt;
            double[] coeff = &lt;br /&gt;
                new double[] {5.5, 7.0, 15, 30, 500, 100, 1};&lt;br /&gt;
            &lt;br /&gt;
            Eval(coeff);&lt;br /&gt;
            &lt;br /&gt;
                // Evaluate the second polynomial, with 50 elements&lt;br /&gt;
            coeff = new double[50];&lt;br /&gt;
            for (int index = 0; index &amp;lt; 50; index++)&lt;br /&gt;
            {&lt;br /&gt;
                coeff[index] = index;&lt;br /&gt;
            }&lt;br /&gt;
            Eval(coeff);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
//File:Counter.cs&lt;br /&gt;
using System;&lt;br /&gt;
namespace Polynomial&lt;br /&gt;
{&lt;br /&gt;
    class Counter &lt;br /&gt;
    {&lt;br /&gt;
        public static long Frequency &lt;br /&gt;
        {&lt;br /&gt;
            get &lt;br /&gt;
            {&lt;br /&gt;
                long freq = 0;&lt;br /&gt;
                QueryPerformanceFrequency(ref freq);&lt;br /&gt;
                return freq;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        public static long Value &lt;br /&gt;
        {&lt;br /&gt;
            get &lt;br /&gt;
            {&lt;br /&gt;
                long count = 0;&lt;br /&gt;
                QueryPerformanceCounter(ref count);&lt;br /&gt;
                return count;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        [System.Runtime.InteropServices.DllImport(&amp;quot;KERNEL32&amp;quot;)]&lt;br /&gt;
        private static extern bool QueryPerformanceCounter(  ref long lpPerformanceCount);&lt;br /&gt;
        [System.Runtime.InteropServices.DllImport(&amp;quot;KERNEL32&amp;quot;)]&lt;br /&gt;
        private static extern bool QueryPerformanceFrequency( ref long lpFrequency);                     &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;A href=&amp;quot;http://www.nfex.ru/Code/CSharpDownload/Polynomial.zip&amp;quot;&amp;gt;Polynomial.zip( 2 k)&amp;lt;/a&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>