/// <summary>
 /// Generates a "sparse" or "dense" polynomial containing numOnes ints equal to 1,
 /// numNegOnes int equal to -1, and the rest equal to 0.
 /// </summary>
 ///
 /// <param name="N">Number of coeffeients</param>
 /// <param name="NumOnes">Number of ones</param>
 /// <param name="NumNegOnes">Number of negative ones</param>
 /// <param name="Sparse">Create a SparseTernaryPolynomial or DenseTernaryPolynomial</param>
 /// <param name="Rng">Random number generator</param>
 ///
 /// <returns>A ternary polynomial</returns>
 public static ITernaryPolynomial GenerateRandomTernary(int N, int NumOnes, int NumNegOnes, bool Sparse, IRandom Rng)
 {
     if (Sparse)
     {
         return(SparseTernaryPolynomial.GenerateRandom(N, NumOnes, NumNegOnes, Rng));
     }
     else
     {
         return(DenseTernaryPolynomial.GenerateRandom(N, NumOnes, NumNegOnes, Rng));
     }
 }
        /// <summary>
        /// Generates a <c>ProductFormPolynomial</c> from three random ternary polynomials.
        /// </summary>
        ///
        /// <param name="N">Number of coefficients</param>
        /// <param name="Df1">Number of ones in the first polynomial; also the number of negative ones</param>
        /// <param name="Df2">Number of ones in the second polynomial; also the number of negative ones</param>
        /// <param name="Df3Ones">Number of ones in the third polynomial</param>
        /// <param name="Df3NegOnes">Number of negative ones in the third polynomial</param>
        /// <param name="Rng">Random number generator</param>
        ///
        /// <returns>A random <c>ProductFormPolynomial</c></returns>
        public static ProductFormPolynomial GenerateRandom(int N, int Df1, int Df2, int Df3Ones, int Df3NegOnes, IRandom Rng)
        {
            SparseTernaryPolynomial f1 = null;
            SparseTernaryPolynomial f2 = null;
            SparseTernaryPolynomial f3 = null;

            f1 = SparseTernaryPolynomial.GenerateRandom(N, Df1, Df1, Rng);
            f2 = SparseTernaryPolynomial.GenerateRandom(N, Df2, Df2, Rng);
            f3 = SparseTernaryPolynomial.GenerateRandom(N, Df3Ones, Df3NegOnes, Rng);

            return(new ProductFormPolynomial(f1, f2, f3));
        }