private static void Argmax(NArray <T, TC, TOut> src, TOut dst, uint[] src_dim, int dimindex, int axis, List <Slice> src_slice, List <int> dst_index) { if (dimindex < src_dim.Length) { src_slice.Add(0); if (axis == dimindex) { src_slice[dimindex] = ":"; Argmax(src, dst, src_dim, dimindex + 1, axis, src_slice, dst_index); } else { dst_index.Add(0); var dst_index_last = dst_index.Count - 1; var current_dim = src_dim[dimindex]; for (int i = 0; i < current_dim; i++) { src_slice[dimindex] = i; dst_index[dst_index_last] = i; Argmax(src, dst, src_dim, dimindex + 1, axis, src_slice, dst_index); } dst_index.RemoveAt(dst_index.Count - 1); } src_slice.RemoveAt(src_slice.Count - 1); } else { dst[dst_index.ToArray()] = (T)Convert.ChangeType(src[src_slice.ToArray()].Argmax(), typeof(T)); } }
public TOut Compare(NArray <T, TC, TOut> other) { if (shape != other.shape) { TOut retfalse = new TOut(); retfalse.Init(new Shape(1), new T[] { (T)Convert.ChangeType(0, typeof(T)) }); return(retfalse); } TOut ret = new TOut(); ret.Init(shape, this.storage .Select((x, i) => Calculator.Compare(x, other.storage[i])).ToArray()); return(ret); }