Example #1
0
        public static TensorOld <TOut> DoCellByCell <TOut, TIn1, TIn2>(this TensorOld <TIn1> t1, TensorOld <TIn2> t2, Func <TIn1, TIn2, TOut> operation)
        {
            t1.CheckEqualDimensions(t2);

            TensorOld <TOut> result = new TensorOld <TOut>(t1.ShapeDimensions.ToArray());

            for (int i = 0; i < t1.TheSpan.NumberSubArrays; i++)
            {
                result.TheSpan[i] = operation(t1.TheSpan[i], t2.TheSpan[i]);
            }

            return(result);
        }
Example #2
0
        public static void DoCellByCell <TTarget, TSource>
        (
            this TensorOld <TTarget> target,
            TensorOld <TSource> source,
            RefFunc <TTarget, TSource> operation)
        {
            target.CheckEqualDimensions(source);
            TTarget t = default(TTarget);

            for (int i = 0; i < target.TheSpan.NumberSubArrays; i++)
            {
                operation(ref t, source.TheSpan[i]);
                target.TheSpan[i] = t;
            }
        }