/// <summary> /// Performs matrix multiplication on the two operands, using the supplied methods /// </summary> /// <typeparam name="T">The type of data to operate on</typeparam> /// <param name="addop">The add operator</param> /// <param name="mulop">The multiply operator</param> /// <param name="in1">The left-hand-side argument</param> /// <param name="in2">The right-hand-side argument</param> /// <param name="out">An optional output argument, use for in-place operations</param> /// <returns>An array with the matrix multiplication result</returns> public static NdArray <T> Matmul <T>(IBinaryOp <T> addop, IBinaryOp <T> mulop, NdArray <T> in1, NdArray <T> in2, NdArray <T> @out = null) { var method = typeof(UFunc).GetMethod("Matmul_Entry", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); var gm = method.MakeGenericMethod(typeof(T), addop.GetType(), mulop.GetType()); return((NdArray <T>)gm.Invoke(null, new object[] { addop, mulop, in1, in2, @out })); }
/// <summary> /// Reduces the input argument on the specified axis /// </summary> /// <typeparam name="T">The type of data to operate on</typeparam> /// <param name="op">The operation to reduce with</param> /// <param name="in1">The input argument</param> /// <param name="axis">The axis to reduce</param> /// <param name="out">The output target</param> /// <returns>The output target</returns> public static NdArray <T> Reduce <T>(IBinaryOp <T> op, NdArray <T> in1, long axis = 0, NdArray <T> @out = null) { var method = typeof(UFunc).GetMethod("Reduce_Entry", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); var gm = method.MakeGenericMethod(typeof(T), op.GetType()); return((NdArray <T>)gm.Invoke(null, new object[] { op, in1, axis, @out })); }
/// <summary> /// Calculates the scalar result of applying the binary operation to all elements /// </summary> /// <typeparam name="T">The value to operate on</typeparam> /// <param name="op">The operation to perform</param> /// <param name="in1">The array to aggregate</param> /// <returns>A scalar value that is the result of aggregating all elements</returns> public static T Aggregate <T>(IBinaryOp <T> op, NdArray <T> in1) { var method = typeof(UFunc).GetMethod("Aggregate_Entry", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); var gm = method.MakeGenericMethod(typeof(T), op.GetType()); return((T)gm.Invoke(null, new object[] { op, in1 })); }
/// <summary> /// Initializes a new instance of the <see cref="LazyMatmulOperation<T>"/> class /// </summary> /// <param name="addOperation">The add operator</param> /// <param name="mulOperation">The multiply operator</param> public LazyMatmulOperation(IBinaryOp <T> addOperation, IBinaryOp <T> mulOperation) { this.AddOperator = addOperation; this.MulOperator = mulOperation; }
/// <summary> /// Initializes a new instance of the <see cref="LazyReduceOperation<T>"/> struct. /// </summary> /// <param name="operation">The operation to reduce with</param> /// <param name="axis">The axis to reduce over</param> public LazyReduceOperation(IBinaryOp <T> operation, long axis) { Operation = operation; Axis = axis; }
/// <summary> /// Initializes a new instance of the <see cref="LazyReduceOperation<T>"/> struct. /// </summary> /// <param name="operation">The operation to reduce with</param> public LazyAggregateOperation(IBinaryOp <T> operation) { Operation = operation; }