Esempio n. 1
0
 public override RingElement <BigInteger> GetMultiplicativeInverse(RingElement <BigInteger> g)
 {
     if (g.Identifier == 1 || g.Identifier == -1)
     {
         return(g);
     }
     throw new DivideByZeroException();
 }
Esempio n. 2
0
        public override RingElement <R[]> GetMultiplicativeInverse(RingElement <R[]> g)
        {
            var polyg = (Polynomial)g;

            if (polyg.degree() == 1)
            {
                return(new Polynomial(new [] { (R)(1 / polyg[0]) }, this));
            }

            throw new DivideByZeroException();
        }
Esempio n. 3
0
        public override RingElement <R[]> GetAdditiveInverse(RingElement <R[]> g)
        {
            var polyg  = (Polynomial)g;
            var coeffs = new R[polyg.degree() + 1];

            for (var i = 0; i < coeffs.Length; ++i)
            {
                coeffs[i] = (R)(-polyg[i]);
            }

            return(new Polynomial(coeffs, this));
        }
Esempio n. 4
0
        public override RingElement <R[]> AddElements(RingElement <R[]> g, RingElement <R[]> h)
        {
            var polyg  = (Polynomial)g;
            var polyh  = (Polynomial)h;
            var len    = System.Math.Max(polyg.degree() + 1, polyh.degree() + 1);
            var coeffs = new List <R>();

            for (var i = 0; i < len; ++i)
            {
                coeffs.Add((R)(polyg[i] + polyh[i]));
            }

            return(new Polynomial(coeffs.ToArray(), this));
        }
Esempio n. 5
0
        public override RingElement <R[]> MultiplyElements(RingElement <R[]> g, RingElement <R[]> h)
        {
            var polyg  = (Polynomial)g;
            var polyh  = (Polynomial)h;
            var len    = polyg.degree() + polyh.degree() + 2;
            var coeffs = new R[len];

            for (var pow = 0; pow < len; ++pow)
            {
                coeffs[pow] = (R)Ring.getZero();
                for (var gi = 0; gi <= pow; ++gi)
                {
                    var hi = pow - gi;
                    coeffs[pow] = (R)(coeffs[pow] + polyg[gi] * polyh[hi]);
                }
            }

            return(new Polynomial(coeffs.ToArray(), this));
        }
Esempio n. 6
0
 public RingElement <I> dividedBy(RingElement <I> d)
 {
     return(this / d);
 }
Esempio n. 7
0
 public RingElement <I> minus(RingElement <I> r)
 {
     return(this - r);
 }
Esempio n. 8
0
 public virtual RingElement <I> plus(RingElement <I> a)
 {
     return(this + a);
 }
Esempio n. 9
0
 public virtual RingElement <I> times(RingElement <I> a)
 {
     return(this * a);
 }
Esempio n. 10
0
 /// <summary>
 ///     Find the multiplicative inverse of the given element in the ring.
 /// </summary>
 /// <param name="g">The element to find the inverse of</param>
 /// <returns>The element g^-1</returns>
 /// <exception> If element has no inverse </exception>
 public abstract RingElement <I> GetMultiplicativeInverse(RingElement <I> g);
Esempio n. 11
0
 /// <summary>
 ///     Find the additive inverse of the given element in the ring.
 /// </summary>
 /// <param name="g">The element to find the inverse of</param>
 /// <returns>The element -g</returns>
 public abstract RingElement <I> GetAdditiveInverse(RingElement <I> g);
Esempio n. 12
0
 /// <summary>
 ///     Find the sum of two elements in the group.
 /// </summary>
 /// <param name="g">The first element to add.</param>
 /// <param name="h">The second element to add.</param>
 /// <returns>The element g+h.</returns>
 public abstract RingElement <I> AddElements(RingElement <I> g, RingElement <I> h);
Esempio n. 13
0
 /// <summary>
 ///     Find the product of two elements in the group.
 /// </summary>
 /// <param name="g">The first element to multiply.</param>
 /// <param name="h">The second element to multiply.</param>
 /// <returns>The element gh.</returns>
 public abstract RingElement <I> MultiplyElements(RingElement <I> g, RingElement <I> h);
Esempio n. 14
0
 public override RingElement <BigInteger> GetAdditiveInverse(RingElement <BigInteger> g)
 {
     return(new IntElement(-g.Identifier, this));
 }
Esempio n. 15
0
 public override RingElement <BigInteger> AddElements(RingElement <BigInteger> g, RingElement <BigInteger> h)
 {
     return(new IntElement(((IntElement)g).Identifier + ((IntElement)h).Identifier, this));
 }