Ejemplo n.º 1
0
 /// <summary>
 /// Multiplication of leftFunction and rightFunction.
 /// The component multiplication is defined in calculator on T.
 /// </summary>
 /// <param name="ring">The calculator.</param>
 /// <param name="leftFunction">Left function.</param>
 /// <param name="rightFunction">Right function.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 /// <returns>The multiplication of the left function with the right function.</returns>
 public static Func <T, T> Multiplication <T> (
     this IRing <T> ring,
     Func <T, T> leftFunction,
     Func <T, T> rightFunction)
 {
     return((x) => ring.Multiplication(
                leftFunction(x),
                rightFunction(x)));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Multiplies the specified element power times.
        /// </summary>
        /// <param name="ring">The ring.</param>
        /// <param name="element">The element.</param>
        /// <param name="power">The power.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        /// <returns>The result.</returns>
        public static T Pow <T>(this IRing <T> ring, T element, uint power)
        {
            var result = ring.One;

            for (var i = 0; i < power; i++)
            {
                result = ring.Multiplication(element, result);
            }

            return(result);
        }