/// <summary> /// Gets the least common multiple of two elements in a <see cref="IEuclideanDomain{T, TFirst, TSecond}"/> via Euclid's algorithm. The LCDM is defined as: /// <code> /// r.Mult(r.Gcd(x,y), r.Lcm(x,y)) == r.Mult(x,y) /// </code> /// </summary> /// <typeparam name="T">The type of the carrier set.</typeparam> /// <typeparam name="TRinglike">The type of the ringlike structure.</typeparam> /// <typeparam name="TFirst">The type of the first grouplike operation.</typeparam> /// <typeparam name="TSecond">The type of the second groupike operation.</typeparam> /// <param name="r">The ringlike structure.</param> /// <param name="x">The first element.</param> /// <param name="y">The second element.</param> /// <exception cref="DivideByZeroException">If <paramref name="x"/> or <paramref name="y"/> is zero.</exception> public static T Lcm <T, TRinglike, TFirst, TSecond>(this IContainsRinglike <TRinglike> r, T x, T y) where TRinglike : IEuclideanDomain <T, TFirst, TSecond> where TFirst : ICommutativeGroup <T> where TSecond : IMonoid <T>, ICommutative <T> => r.Ringlike.Lcm(x, y);
/// <summary> /// Computes the average value of a sequence iteratively using the operations of the field <paramref name="field"/>. See the <see cref="CollectionExtensions.AverageIterative(IEnumerable{double})"/>-family of functions. The average of the empty sequence is defined as <see cref="Ringlike.Zero{T, TFirst, TSecond}(IRinglike{T, TFirst, TSecond})"/>. /// </summary> /// <typeparam name="T">The type of the carrier set.</typeparam> /// <typeparam name="TRinglike">The type of the ringlike structure.</typeparam> /// <typeparam name="TFirst">The type of the first grouplike operation.</typeparam> /// <typeparam name="TSecond">The type of the second groupike operation.</typeparam> /// <param name="xs">The sequence to traverse.</param> /// <param name="field">The field whose operations to use.</param> public static T Average <T, TRinglike, TFirst, TSecond>(this IEnumerable <T> xs, IContainsRinglike <TRinglike> field) where TRinglike : IField <T, TFirst, TSecond> where TFirst : ICommutativeGroup <T> where TSecond : ICommutativeGroup <T> => xs.Average(field.Ringlike);
/// <summary> /// Performs Euclidean division on two elements <paramref name="x"/> and <paramref name="y"/> and returns a quotient <c>q</c> and a remainder <c>r</c> /// </summary> /// <typeparam name="T">The type of the carrier set.</typeparam> /// <typeparam name="TRinglike">The type of the ringlike structure.</typeparam> /// <typeparam name="TFirst">The type of the first grouplike structure.</typeparam> /// <typeparam name="TSecond">The type of the second grouplike structure.</typeparam> /// <param name="r">The ringlike structure.</param> /// <param name="x">The divident.</param> /// <param name="y">The divisor.</param> public static (T quotient, T remainder) EuclideanDivide <T, TRinglike, TFirst, TSecond>(this IContainsRinglike <TRinglike> r, T x, T y)