/// <summary> /// Finds the first occurence of the specfied value along the specified axis and returns its index. /// </summary> /// <param name="value">The value to find.</param> /// <param name="axis">The axis to find the value along.</param> /// <param name="source">The NdArray containing the source values.</param> /// <returns>A new NdArray containing the indices of the first occurence of <paramref name="value"/>.</returns> public static int[] TryFind(T value, NdArray <T> source) { var pos = FindAxis(value, 0, NdArray <T> .Flatten(source)).Value; if (pos != SpecialIdx.NotFound) { return(Layout.LinearToIndex(source.Layout, pos)); } return(new int[] { }); }
/// <summary> /// Counts the elements being true returning the result as a NdArray. /// </summary> /// <param name="source">The NdArray containing the source values.</param> /// <returns>A new scalar NdArray containing the result of this operation.</returns> public static NdArray <int> CountTrueNdArray(NdArray <bool> source) { return(CountTrueAxis(0, NdArray <bool> .Flatten(source))); }
/// <summary> /// Finds the indicies of the maximum value of the NdArray. /// </summary> /// <param name="source">The NdArray containing the source values.</param> /// <returns>The indices of the position of the maximum value.</returns> public static int[] ArgMax(NdArray <T> source) { return(Layout.LinearToIndex(source.Layout, ArgMaxAxis(0, NdArray <T> .Flatten(source)).Value)); }