public static void FindLastAxis <T>(T value, DataAndLayout <int> trgt, DataAndLayout <T> src) { var nd = src.FastAccess.NumDiensions; var sp = ScalarPrimitivesRegistry.For <T, T>(); int op(int[] srcIndex, int pos, T val) { if (pos != SpecialIdx.NotFound) { return(pos); } else { if (sp.Equal(val, value)) { return(srcIndex[nd - 1]); } else { return(SpecialIdx.NotFound); } } } var initial = new InitialOption <int>(true, SpecialIdx.NotFound); ApplyAxisFold(op, v => v, trgt, src, initial, true, true); }
public static void Convert <T, TC>(DataAndLayout <T> trgt, DataAndLayout <TC> src) { var p = ScalarPrimitivesRegistry.For <T, TC>(); T op(int[] pos, TC v) => p.Convert(v); ApplyUnaryOp(op, trgt, src, isIndexed: false, useThreads: true); }
public static void IsFinite <TP>(DataAndLayout <bool> trgt, DataAndLayout <TP> src) { var p = ScalarPrimitivesRegistry.For <TP, TP>(); bool op(int[] pos, TP a) => p.IsFinite(a); ApplyUnaryOp(op, trgt, src, isIndexed: false, useThreads: true); }
public static void Truncate <T>(DataAndLayout <T> trgt, DataAndLayout <T> src) { var p = ScalarPrimitivesRegistry.For <T, T>(); T op(int[] pos, T a) => p.Truncate(a); ApplyUnaryOp(op, trgt, src, isIndexed: false, useThreads: true); }
public static void Pow <T>(DataAndLayout <T> trgt, DataAndLayout <T> lhs, DataAndLayout <T> rhs) { var p = ScalarPrimitivesRegistry.For <T, T>(); T op(int[] pos, T l, T t) => p.Power(l, t); ApplyBinaryOp(op, trgt, lhs, rhs, isIndexed: false, useThreads: true); }
public static void Minimum <T>(DataAndLayout <T> trgt, DataAndLayout <T> src1, DataAndLayout <T> src2) { var p = ScalarPrimitivesRegistry.For <T, T>(); T op(int[] pos, T a, T b) => p.Minimum(a, b); ApplyBinaryOp(op, trgt, src1, src2, isIndexed: false, useThreads: true); }
public static void GreaterOrEqual <TP>(DataAndLayout <bool> trgt, DataAndLayout <TP> src1, DataAndLayout <TP> src2) { var p = ScalarPrimitivesRegistry.For <TP, TP>(); bool op(int[] pos, TP a, TP b) => p.GreaterOrEqual(a, b); ApplyBinaryOp(op, trgt, src1, src2, isIndexed: false, useThreads: true); }
public static void FillIncrementing <T>(T start, T step, DataAndLayout <T> trgt) { var p = ScalarPrimitivesRegistry.For <T, int>(); T op(int[] pos) => p.Add(start, p.Multiply(step, p.Convert(pos[0]))); ApplyNoaryOp(op, trgt, isIndexed: true, useThreads: true); }
public static void ProductLastAxis <T>(DataAndLayout <T> trgt, DataAndLayout <T> src) { var p = ScalarPrimitivesRegistry.For <T, T>(); T foldOp(int[] pos, T res, T v) => p.Multiply(res, v); var initial = new InitialOption <T>(true, Primitives.One <T>()); ApplyAxisFold(foldOp, v => v, trgt, src, initial, false, true); }
public static void MinLastAxis <T>(DataAndLayout <T> trgt, DataAndLayout <T> src) { var p = ScalarPrimitivesRegistry.For <T, T>(); T foldOp(int[] pos, T res, T v) => p.Less(res, v) ? res : v; var initial = new InitialOption <T>(true, Primitives.MaxValue <T>()); ApplyAxisFold(foldOp, v => v, trgt, src, initial, false, true); }
public static void ArgMinLastAxis <T>(DataAndLayout <int> trgt, DataAndLayout <T> src) { var nd = src.FastAccess.NumDiensions; var sp = ScalarPrimitivesRegistry.For <T, T>(); (int pos, T val) op(int[] pos, (int minPos, T minVal) minInfo, T value) => sp.Less(value, minInfo.minVal) ? (pos[nd - 1], value) : minInfo; var initial = new InitialOption <(int, T)>(true, (SpecialIdx.NotFound, Primitives.MaxValue <T>())); ApplyAxisFold(op, v => v.Item1, trgt, src, initial, true, true); }