Example #1
0
 /// <summary>
 ///
 /// </summary>
 public static void LerpTo(this IDiscreteField <double> f0, IDiscreteField <double> f1, IDiscreteField <double> t, IDiscreteField <double> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Lerp(f0.Values, f1.Values, t.Values, f0.Count, result.Values);
     }
     else
     {
         ArrayMath.Lerp(f0.Values, f1.Values, t.Values, f0.Count, result.Values);
     }
 }
Example #2
0
 /// <summary>
 /// result = f0 + (f1 - f2) * t
 /// </summary>
 public static void AddScaledDelta(this IDiscreteField <double> f0, IDiscreteField <double> f1, IDiscreteField <double> f2, IDiscreteField <double> t, IDiscreteField <double> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.AddScaledDelta(f0.Values, f1.Values, f2.Values, t.Values, f0.Count, result.Values);
     }
     else
     {
         ArrayMath.AddScaledDelta(f0.Values, f1.Values, f2.Values, t.Values, f0.Count, result.Values);
     }
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="field"></param>
 /// <param name="value"></param>
 public static void Set <T>(this IDiscreteField <T> field, T value)
 {
     field.Values.SetRange(value, 0, field.Count);
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 public static void Subtract(this IDiscreteField <double> f0, IDiscreteField <double> f1, IDiscreteField <double> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Subtract(f0.Values, f1.Values, f0.Count, result.Values);
     }
     else
     {
         ArrayMath.Subtract(f0.Values, f1.Values, f0.Count, result.Values);
     }
 }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 public static void Clear <T>(this IDiscreteField <T> field)
     where T : struct
 {
     Array.Clear(field.Values, 0, field.Count);
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 public static bool ApproxEquals(this IDiscreteField <Vec2d> f0, IDiscreteField <Vec2d> f1, double tolerance = SlurMath.ZeroTolerance)
 {
     return(ArrayMath.ApproxEquals(f0.Values, f1.Values, f0.Count, tolerance));
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="result"></param>
 /// <param name="parallel"></param>
 public void GetLaplacian(IDiscreteField <Vec2d> result, bool parallel = false)
 {
     GetLaplacian(result.Values, parallel);
 }
Example #8
0
 /// <summary>
 /// Sets the resulting field to some function of this field and two others
 /// </summary>
 public static void Function <T0, T1, T2, U>(this IDiscreteField <T0> f0, IDiscreteField <T1> f1, IDiscreteField <T2> f2, Func <T0, T1, T2, U> func, IDiscreteField <U> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Function(f0.Values, f1.Values, f2.Values, f0.Count, func, result.Values);
     }
     else
     {
         ArrayMath.Function(f0.Values, f1.Values, f2.Values, f0.Count, func, result.Values);
     }
 }
Example #9
0
 /// <summary>
 ///
 /// </summary>
 public static void Normalize(this IDiscreteField <Vec3d> field, Interval3d interval, IDiscreteField <Vec3d> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Normalize(field.Values, interval, result.Values);
     }
     else
     {
         ArrayMath.Normalize(field.Values, interval, result.Values);
     }
 }
Example #10
0
 /// <summary>
 /// Sets the given field to some function of this field's coordinates in grid space.
 /// </summary>
 /// <param name="func"></param>
 /// <param name="result"></param>
 /// <param name="parallel"></param>
 public void SpatialFunction(Func <int, int, int, T> func, IDiscreteField <T> result, bool parallel = false)
 {
     SpatialFunction(func, result.Values, parallel);
 }
Example #11
0
 /// <summary>
 /// result = f0 * t0 + f1 * t1
 /// </summary>
 public static void AddScaled(this IDiscreteField <Vec3d> f0, IDiscreteField <double> t0, IDiscreteField <Vec3d> f1, IDiscreteField <double> t1, IDiscreteField <Vec3d> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.AddScaled(f0.Values, t0.Values, f1.Values, t1.Values, f0.Count, result.Values);
     }
     else
     {
         ArrayMath.AddScaled(f0.Values, t0.Values, f1.Values, t1.Values, f0.Count, result.Values);
     }
 }
Example #12
0
 /// <summary>
 /// Sets the given field to some function of this field's coordinates.
 /// </summary>
 /// <param name="func"></param>
 /// <param name="result"></param>
 /// <param name="normalize"></param>
 /// <param name="parallel"></param>
 public void SpatialFunction(Func <Vec3d, T> func, IDiscreteField <T> result, bool normalize = false, bool parallel = false)
 {
     SpatialFunction(func, result.Values, normalize, parallel);
 }
Example #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="result"></param>
 /// <param name="parallel"></param>
 public void GetCurl(IDiscreteField <double> result, bool parallel = false)
 {
     GetCurl(result.Values, parallel);
 }
Example #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="result"></param>
 /// <param name="parallel"></param>
 public void GetDivergence(IDiscreteField <double> result, bool parallel = false)
 {
     GetDivergence(result.Values, parallel);
 }
Example #15
0
 /// <summary>
 ///
 /// </summary>
 public static void Evaluate(this IDiscreteField <double> field, Intervald interval, IDiscreteField <double> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Evaluate(field.Values, interval, result.Values);
     }
     else
     {
         ArrayMath.Evaluate(field.Values, interval, result.Values);
     }
 }
Example #16
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="field"></param>
 /// <returns></returns>
 public static ReadOnlySubArray <T> AsReadOnly <T>(this IDiscreteField <T> field)
 {
     return(new ReadOnlySubArray <T>(field.Values, 0, field.Count));
 }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 public static void Remap(this IDiscreteField <double> field, Intervald from, Intervald to, IDiscreteField <double> result, bool parallel = false)
 {
     if (parallel)
     {
         ArrayMath.Parallel.Remap(field.Values, from, to, result.Values);
     }
     else
     {
         ArrayMath.Remap(field.Values, from, to, result.Values);
     }
 }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 public static double Min(this IDiscreteField <double> field)
 {
     return(ArrayMath.Min(field.Values, field.Count));
 }
Example #19
0
 /// <summary>
 ///
 /// </summary>
 public static Vec2d Sum(this IDiscreteField <Vec2d> field)
 {
     return(ArrayMath.Sum(field.Values, field.Count));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="result"></param>
 /// <param name="parallel"></param>
 public void GetGradient(IDiscreteField <Vec3d> result, bool parallel = false)
 {
     GetGradient(result.Values, parallel);
 }