public static RCArray <O> SequentialOp <S, R, O> (RCArray <R> right, SeqScalarOp <S, R, O> op) where S : struct where O : struct { S s = new S(); O o = new O(); for (int i = 0; i < right.Count; ++i) { o = op(ref s, right[i]); } return(new RCArray <O> (o)); }
public static RCArray <R> CumulativeOp <S, R> (RCArray <R> right, SeqScalarOp <S, R, R> op) where S : struct { if (right.Count == 0) { return(RCArray <R> .Empty); } RCArray <R> result = new RCArray <R> (right.Count); R accumulator = right[0]; S state = new S(); for (int i = 0; i < right.Count; ++i) { accumulator = op(ref state, right[i]); result.Write(accumulator); } return(result); }