Ejemplo n.º 1
0
        /// <summary>
        ///   Creates a bidimensional mesh matrix.
        /// </summary>
        ///
        public static double[][] Mesh(DoubleRange rowRange, DoubleRange colRange,
                                      double rowSteps, double colSteps)
        {
            double[][] mesh = Matrix.CartesianProduct(
                Matrix.Interval(rowRange, rowSteps),
                Matrix.Interval(colRange, colSteps));

            return(mesh);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Creates a bi-dimensional mesh matrix.
        /// </summary>
        ///
        /// <example>
        /// <code>
        /// // The Mesh method can be used to generate all
        /// // possible (x,y) pairs between two ranges.
        ///
        /// // We can create a grid as
        /// double[][] grid = Matrix.Mesh
        /// (
        ///     rowMin: 0, rowMax: 1, rowSteps: 10,
        ///     colMin: 0, colMax: 1, colSteps: 5
        /// );
        ///
        /// // Now we can plot the points on-screen
        /// ScatterplotBox.Show("Grid (fixed steps)", grid).Hold();
        /// </code>
        ///
        /// <para>
        ///   The resulting image is shown below. </para>
        ///   <img src="..\images\grid-fixed-steps.png" />
        /// </example>
        ///
        public static double[][] Mesh(
            double rowMin, double rowMax, int rowSteps,
            double colMin, double colMax, int colSteps)
        {
            double[][] mesh = Matrix.CartesianProduct(
                Matrix.Interval(rowMin, rowMax, rowSteps),
                Matrix.Interval(colMin, colMax, colSteps));

            return(mesh);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   Creates a bi-dimensional mesh matrix.
        /// </summary>
        ///
        public static int[][] Mesh(
            int rowMin, int rowMax,
            int colMin, int colMax)
        {
            int[][] mesh = Matrix.CartesianProduct(
                Matrix.Interval(rowMin, rowMax),
                Matrix.Interval(colMin, colMax));

            return(mesh);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///   Creates a bi-dimensional mesh matrix.
 /// </summary>
 ///
 /// <param name="x">The values to be replicated vertically.</param>
 /// <param name="y">The values to be replicated horizontally.</param>
 ///
 /// <example>
 /// <code>
 /// // The Mesh method generates all possible (x,y) pairs
 /// // between two vector of points. For example, let's
 /// // suppose we have the values:
 /// //
 /// double[] a = { 0, 1 };
 /// double[] b = { 0, 1 };
 ///
 /// // We can create a grid as
 /// double[][] grid = a.Mesh(b);
 ///
 /// // the result will be:
 /// double[][] expected =
 /// {
 ///     new double[] { 0, 0 },
 ///     new double[] { 0, 1 },
 ///     new double[] { 1, 0 },
 ///     new double[] { 1, 1 },
 /// };
 /// </code>
 /// </example>
 ///
 public static T[][] Mesh <T>(this T[] x, T[] y)
 {
     return(Matrix.CartesianProduct(x, y));
 }