コード例 #1
0
            /// <summary>
            /// Applies a binary operation using the two operands.
            /// Assumes that the target array is allocated and shaped for broadcast.
            /// </summary>
            /// <typeparam name="T">The type of data to operate on</typeparam>
            /// <typeparam name="C">The type of operation to perform</typeparam>
            /// <param name="op">The operation to use</param>
            /// <param name="in1">One input operand</param>
            /// <param name="in2">Another input operand</param>
            /// <param name="out">The target operand, must be allocated and shaped for broadcast</param>
            /// <returns>True if the operation was applied, false otherwise</returns>
            public static void ApplyBinaryOp <T, C>(C op, NdArray <T> in1, NdArray <T> in2, NdArray <T> @out)
                where C : struct, IBinaryOp <T>
            {
                foreach (var n in _handlers)
                {
                    if (n.Item2.ApplyBinaryOp <T, C>(op, in1, in2, @out))
                    {
                        return;
                    }
                }

                //Fallback
                Threads.BinaryOp <T, C>(op, in1, in2, @out);
            }