/// <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); } }
/// <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); } }
/// <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); }
/// <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); } }
/// <summary> /// /// </summary> public static void Clear <T>(this IDiscreteField <T> field) where T : struct { Array.Clear(field.Values, 0, field.Count); }
/// <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)); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <param name="parallel"></param> public void GetLaplacian(IDiscreteField <Vec2d> result, bool parallel = false) { GetLaplacian(result.Values, parallel); }
/// <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); } }
/// <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); } }
/// <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); }
/// <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); } }
/// <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); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <param name="parallel"></param> public void GetCurl(IDiscreteField <double> result, bool parallel = false) { GetCurl(result.Values, parallel); }
/// <summary> /// /// </summary> /// <param name="result"></param> /// <param name="parallel"></param> public void GetDivergence(IDiscreteField <double> result, bool parallel = false) { GetDivergence(result.Values, parallel); }
/// <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); } }
/// <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)); }
/// <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); } }
/// <summary> /// /// </summary> public static double Min(this IDiscreteField <double> field) { return(ArrayMath.Min(field.Values, field.Count)); }
/// <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); }