Exemple #1
0
 /// <summary>
 /// Constructor for creation element belongs to <paramref name="field"/> with number representation <paramref name="representation"/>
 /// </summary>
 /// <param name="field">Field which element belongs</param>
 /// <param name="representation">Element number representation</param>
 public FieldElement(GaloisField field, int representation)
 {
     if (field == null)
     {
         throw new ArgumentException("field");
     }
     if (field.IsFieldElement(representation) == false)
     {
         throw new ArgumentException(string.Format("{0} is not an element of {1}", representation, field));
     }
     Field          = field;
     Representation = representation;
 }
Exemple #2
0
        /// <summary>
        /// Constructor for creation element belongs to <paramref name="field"/> with number representation <paramref name="representation"/>
        /// </summary>
        /// <param name="field">Field which element belongs</param>
        /// <param name="representation">Element number representation</param>
        public FieldElement(GaloisField field, int representation)
        {
            if (field == null)
            {
                throw new ArgumentException("field");
            }
            if (field.IsFieldElement(representation) == false)
            {
                throw new ArgumentException($"{representation} is not an element of {field}");
            }

            Field          = field;
            Representation = representation;
        }
Exemple #3
0
        /// <summary>
        /// Constructor for creation polynomial over field <paramref name="field"/> with coefficients <paramref name="coefficients"/>
        /// </summary>
        /// <param name="field">Field from which the coefficients of the polynomial</param>
        /// <param name="coefficients">Coefficients of the new polynomial</param>
        public Polynomial(GaloisField field, params int[] coefficients)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }
            if (coefficients == null)
            {
                throw new ArgumentNullException(nameof(coefficients));
            }

            Field = field;

            _coefficients = coefficients.ToList();
            if (_coefficients.Any(x => Field.IsFieldElement(x) == false))
            {
                throw new ArgumentException(nameof(coefficients));
            }

            Truncate();
        }