Ejemplo n.º 1
0
 /// <summary>
 /// Projection of a 1D-function <paramref name="f"/> onto a DG-Field
 /// </summary>
 public static void ProjectField(this DGField u, _1D f)
 {
     if (u.Basis.GridDat.SpatialDimension != 1)
     {
         throw new ArgumentException("mismatch in spatial dimension");
     }
     u.ProjectField(f.Vectorize());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// L2Error w.r.t. a 1D-function <paramref name="f"/> of a DG-Field
 /// </summary>
 public static double L2Error(this DGField u, _1D f)
 {
     if (u.Basis.GridDat.SpatialDimension != 1)
     {
         throw new ArgumentException("mismatch in spatial dimension");
     }
     return(u.L2Error(f.Vectorize()));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Vectorized 1D function (<see cref="ScalarFunction"/>) from a scalar implementation
        /// </summary>
        /// <param name="f">calling sequence: f(x)</param>
        /// <returns></returns>
        public static ScalarFunction Vectorize(this _1D f)
        {
            return(delegate(MultidimensionalArray inp, MultidimensionalArray res) {
                int D = inp.GetLength(1);
                if (D != 1)
                {
                    throw new ArgumentException("wrong spatial dimension.");
                }

                for (int i = 0; i < inp.GetLength(0); i++)
                {
                    double x = inp[i, 0];

                    res[i] = f(x);
                }
            });
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Scalar function conversion.
 /// </summary>
 public static Func <double[], double> Convert_x2X(this _1D f)
 {
     return((double[] X) => f(X[0]));
 }