コード例 #1
2
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



        //PUBLIC METHOD DEFINITIONS

        public static void TestModule()
        {
            //textbook example, in order from least power to highest power of x
            //1.25 -3.875 2.125 2.75 -3.5 1
            double[] testArray = { 1.25, -3.875, 2.125, 2.75, -3.5, 1 };

            IterationResult result;
            Bairstow b = new Bairstow(testArray, 0.001, 30, 0,0);
            do
            {
                result = b.performIteration();
                Console.WriteLine("R: " + result.iterR + " S: " + result.iterS + " R-ERR: " + result.iterRError + " S-ERR: " + result.iterSError + " DELTA-R: " +
                    result.deltaR + " DELTA-S: " + result.deltaS);
                if (result.rootFound) Console.WriteLine();
            } while (result.allRootsFound == false);

            Tuple<double, double>[] roots = b.calculateRoots();
            for(int i = 0; i < roots.Length; ++i)
            {
                Console.WriteLine("REAL: " + roots[i].Item1 + " COMPLEX: " + roots[i].Item2);
            }
        }