예제 #1
0
        /// <summary>
        /// Method for dividing current field element by field element <paramref name="b"/>
        /// </summary>
        /// <param name="b">Divider</param>
        /// <returns>Quotient</returns>
        public FieldElement Divide(FieldElement b)
        {
            ValidateArgument(b);
            if (b.Representation == 0)
            {
                throw new ArgumentException("Cannot divide by zero");
            }

            Representation = Field.Divide(Representation, b.Representation);
            return(this);
        }
예제 #2
0
 /// <summary>
 /// Constructor for creation copy of element <paramref name="element"/>
 /// </summary>
 /// <param name="element">Copied field element</param>
 public FieldElement(FieldElement element)
 {
     Field          = element.Field;
     Representation = element.Representation;
 }
예제 #3
0
        /// <summary>
        /// Inverts field element <paramref name="a"/> for multiplication
        /// </summary>
        /// <param name="a">Invetible element</param>
        /// <returns>Inversed element</returns>
        public static FieldElement InverseForMultiplication(FieldElement a)
        {
            var b = new FieldElement(a);

            return(b.InverseForMultiplication());
        }
예제 #4
0
        /// <summary>
        /// Exponentiation of field element <paramref name="a"/> to the degree <paramref name="degree"/>
        /// </summary>
        /// <param name="a">Element for exponentiation</param>
        /// <param name="degree">Power for exponentiation</param>
        public static FieldElement Pow(FieldElement a, int degree)
        {
            var c = new FieldElement(a);

            return(c.Pow(degree));
        }
예제 #5
0
        /// <summary>
        /// Method for dividing field element <paramref name="a"/> by field element <paramref name="b"/>
        /// </summary>
        /// <param name="a">Dividend</param>
        /// <param name="b">Divider</param>
        /// <returns>Quotient</returns>
        public static FieldElement Divide(FieldElement a, FieldElement b)
        {
            var c = new FieldElement(a);

            return(c.Divide(b));
        }
예제 #6
0
        /// <summary>
        /// Method for multiplying field element <paramref name="a"/> to field element <paramref name="b"/>
        /// </summary>
        /// <param name="a">First factor</param>
        /// <param name="b">Second factor</param>
        /// <returns>Product</returns>
        public static FieldElement Multiply(FieldElement a, FieldElement b)
        {
            var c = new FieldElement(a);

            return(c.Multiply(b));
        }
예제 #7
0
        /// <summary>
        /// Method for subtracting field element <paramref name="b"/> from field element <paramref name="a"/>
        /// </summary>
        /// <param name="a">Minuend</param>
        /// <param name="b">Subtrahend</param>
        /// <returns>Difference</returns>
        public static FieldElement Subtract(FieldElement a, FieldElement b)
        {
            var c = new FieldElement(a);

            return(c.Subtract(b));
        }
예제 #8
0
        /// <summary>
        /// Method for adding field element <paramref name="a"/> to field element <paramref name="b"/>
        /// </summary>
        /// <param name="a">First term</param>
        /// <param name="b">Second term</param>
        /// <returns>Sum</returns>
        public static FieldElement Add(FieldElement a, FieldElement b)
        {
            var c = new FieldElement(a);

            return(c.Add(b));
        }
예제 #9
0
 /// <summary>
 /// Method for checking the equality of the current field element to the <paramref name="other"/>
 /// </summary>
 /// <param name="other">Another field element</param>
 /// <returns>Checking result</returns>
 private bool Equals(FieldElement other)
 {
     return(Equals(Field, other.Field) && Representation == other.Representation);
 }