Exemplo n.º 1
0
        public FieldElement Multiply(FieldElement val1, FieldElement val2)
        {
            HalfComplex c = null;
            BigInt      i = null;

            if (val1 is HalfComplex)
            {
                if (val2 is HalfComplex)
                {
                    throw new ArgumentException("The inputs cannot be both HalfComplex numbers");
                }
                if (val2 is BigInt)
                {
                    c = (HalfComplex)val1;
                    i = (BigInt)val2;
                }
                else
                {
                    throw new ArgumentException("The second input is of a unsupported type");
                }
            }

            if (val2 is HalfComplex)
            {
                if (val1 is HalfComplex)
                {
                    throw new ArgumentException("The inputs cannot be both HalfComplex numbers");
                }
                if (val1 is BigInt)
                {
                    c = (HalfComplex)val2;
                    i = (BigInt)val1;
                }
                else
                {
                    throw new ArgumentException("The first input is of a unsupported type");
                }
            }

            return(c.Multiply(i));
        }
Exemplo n.º 2
0
        public override bool Equals(Object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            HalfComplex other = (HalfComplex)obj;

            if (field == null)
            {
                if (other.field != null)
                {
                    return(false);
                }
            }
            else if (!field.Equals(other.field))
            {
                return(false);
            }
            if (real == null)
            {
                if (other.real != null)
                {
                    return(false);
                }
            }
            else if (!real.Equals(other.real))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
 public HalfComplex Subtract(HalfComplex p)
 {
     return(new HalfComplex(this.field, (BigInt)this.field.Subtract(this.real, p.real)));
 }
Exemplo n.º 4
0
 public HalfComplex Add(HalfComplex p)
 {
     return(new HalfComplex(this.field, (BigInt)this.field.Add(this.real, p.real)));
 }