Ejemplo n.º 1
0
        public static TensorOld <int> DoIntCellByCell <TIn1, TIn2>(this TensorOld <TIn1> t1, TensorOld <TIn2> t2, Func <int, int, int> operation)
        {
            var converter1 = NumericUtils.GetNumericConverter <TIn1, int>();
            var converter2 = NumericUtils.GetNumericConverter <TIn2, int>();

            return(t1.DoCellByCell(t2, (TIn1 item1, TIn2 item2) => operation(converter1(item1), converter2(item2))));
        }
Ejemplo n.º 2
0
        public static TensorOld <int> DoIntScalarCellByCell <TIn1, TIn2>(this TensorOld <TIn1> t1, TIn2 val2, Func <int, int, int> operation)
        {
            var converter1 = NumericUtils.GetNumericConverter <TIn1, int>();
            var converter2 = NumericUtils.GetNumericConverter <TIn2, int>();

            int dVal2 = converter2(val2);

            return(t1.DoScalarCellByCell(val2, (TIn1 item1, TIn2 item2) => operation(converter1(item1), dVal2)));
        }
Ejemplo n.º 3
0
        public static TensorOld <TOut> Cast <TIn, TOut>(this TensorOld <TIn> t, Func <TIn, TOut> converter = null)
        {
            if (converter == null)
            {
                converter = NumericUtils.GetNumericConverter <TIn, TOut>();
            }

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

            result.SetSpan(t.TheSpan.Select(item => converter(item)));

            return(result);
        }