Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }