Exemplo n.º 1
0
        public static void TestHarness_LOOP()
        {
            RandomAugmented random = RandomAugmented.getSeededRandomAugmented();

            ArrayList pool1 = new ArrayList();
            ArrayList pool2 = new ArrayList();

            for (int i = 0; i < 10; ++i)
            {
                pool1.Add(new Point2D(random.NextDouble(), random.NextDouble()));
                pool2.Add(new Point2D(random.NextDouble(), random.NextDouble()));
            }
            double m, c;

            findHull(pool1, pool2, out m, out c);
            ArrayList hull = new ArrayList();

            hull.Add(new Point2D(0, c)); hull.Add(new Point2D(1, m + c));

            GenericChartForm charts = new GenericChartForm();

            charts.setChartCounts(1, 1);
            charts[0].addSeries(new Series("Pool1", ChartType.Point, pool1));
            charts[0].addSeries(new Series("Pool2", ChartType.Point, pool2));
            charts[0].addSeries(new Series("Hull", ChartType.Line, hull));
            charts[0].Refresh();
            charts.ShowDialog();
        }
        public double[][] generateEmptyStartupParameters(double[] scales)
        {
            RandomAugmented ra = RandomAugmented.getSeededRandomAugmented();

            double[][] initial_points = new double[dimensions + 1][];
            for (int i = 0; i < dimensions + 1; ++i)
            {
                initial_points[i] = new double[dimensions];
                for (int j = 0; j < dimensions; ++j)
                {
                    initial_points[i][j] = ra.NextDoubleBalanced(scales[j]);
                }
            }

            return(initial_points);
        }
        public static void TestHarness()
        {
            RandomAugmented ra = RandomAugmented.getSeededRandomAugmented();

            int N = 4;

            // Create a matrix
            Matrix m = new Matrix(N, N);

            for (int i = 0; i < N; ++i)
            {
                for (int j = i; j < N; ++j)
                {
                    m[i, j] = ra.NextDouble(10);
                    m[j, i] = m[i, j];
                }
            }

            // Space for results
            Matrix eigenvectors = new Matrix(N, N);
            Vector eigenvalues  = new Vector(N);

            // Get values
            calculateEigensystem(m, eigenvectors, eigenvalues);
            sortEigensystem(eigenvectors, eigenvalues);

            Console.WriteLine("Eigenvalues");
            Console.WriteLine(eigenvalues);
            Console.WriteLine("Eigenvectors");
            Console.WriteLine(eigenvectors);

            // Test each eigenpair
            Vector eigenvector = new Vector(N);

            for (int i = 0; i < N; ++i)
            {
                eigenvectors.getColumn(i, eigenvector);

                Console.WriteLine("Eigenpair {0}", i);
                Console.WriteLine(m.multiply(eigenvector));
                Console.WriteLine(eigenvector.multiply(eigenvalues[i]));
            }
        }
Exemplo n.º 4
0
        Series doSampleChartSeries(int series_number)
        {
            RandomAugmented random = RandomAugmented.getSeededRandomAugmented();

            Point2D[] points = new Point2D[25];
            for (int i = 0; i < points.Length; ++i)
            {
                //				points[i] = new Point2D((i+1)/1.0, random.NextDouble());
                points[i] = new Point2D(Math.PI * i / (points.Length - 1), series_number * Math.Sin(series_number * Math.PI * i / (points.Length - 1)));
            }

            Series series = new Series("Series #" + series_number, ChartType.Line, points);

            switch (series_number % 5)
            {
            case 0:
                series.charttype = ChartType.Point;
                break;

            case 1:
                series.charttype = ChartType.Line;
                break;

            case 2:
                series.charttype = ChartType.SmoothLine;
                break;

            case 3:
                series.charttype = ChartType.LineAndPoint;
                break;

            case 4:
                series.chartaxis = ChartAxis.Secondary;
                series.charttype = ChartType.SmoothLineAndPoint;
                break;

            default:
                break;
            }

            return(series);
        }
        public static int[] generateRandomOrder(int num_tuples)
        {
            int[] random_order = new int[num_tuples];
            for (int i = 0; i < num_tuples; ++i)
            {
                random_order[i] = i;
            }

            RandomAugmented random = RandomAugmented.getSeededRandomAugmented();

            for (int i = 0; i < num_tuples; ++i)
            {
                int r = random.NextInt(num_tuples - 1);
                int t = random_order[i];
                random_order[i] = random_order[r];
                random_order[r] = t;
            }

            return(random_order);
        }
Exemplo n.º 6
0
 public GenzMultivariate(Matrix acorrelation)
 {
     random = RandomAugmented.getSeededRandomAugmented();
     setCorrelation(acorrelation);
 }