Multiply() public method

public Multiply ( BigInteger b ) : SimpleBigDecimal
b BigInteger
return SimpleBigDecimal
        /**
         * Computes the norm of an element <code>&#955;</code> of
         * <code><b>R</b>[&#964;]</code>, where <code>&#955; = u + v&#964;</code>
         * and <code>u</code> and <code>u</code> are real numbers (elements of
         * <code><b>R</b></code>).
         * @param mu The parameter <code>&#956;</code> of the elliptic curve.
         * @param u The real part of the element <code>&#955;</code> of
         * <code><b>R</b>[&#964;]</code>.
         * @param v The <code>&#964;</code>-adic part of the element
         * <code>&#955;</code> of <code><b>R</b>[&#964;]</code>.
         * @return The norm of <code>&#955;</code>.
         */
        public static SimpleBigDecimal Norm(sbyte mu, SimpleBigDecimal u, SimpleBigDecimal v)
        {
            SimpleBigDecimal norm;

            // s1 = u^2
            SimpleBigDecimal s1 = u.Multiply(u);

            // s2 = u * v
            SimpleBigDecimal s2 = u.Multiply(v);

            // s3 = 2 * v^2
            SimpleBigDecimal s3 = v.Multiply(v).ShiftLeft(1);

            if (mu == 1)
            {
                norm = s1.Add(s2).Add(s3);
            }
            else if (mu == -1)
            {
                norm = s1.Subtract(s2).Add(s3);
            }
            else
            {
                throw new ArgumentException("mu must be 1 or -1");
            }

            return(norm);
        }
Beispiel #2
0
		/**
        * Computes the norm of an element <code>&#955;</code> of
        * <code><b>R</b>[&#964;]</code>, where <code>&#955; = u + v&#964;</code>
        * and <code>u</code> and <code>u</code> are real numbers (elements of
        * <code><b>R</b></code>). 
        * @param mu The parameter <code>&#956;</code> of the elliptic curve.
        * @param u The real part of the element <code>&#955;</code> of
        * <code><b>R</b>[&#964;]</code>.
        * @param v The <code>&#964;</code>-adic part of the element
        * <code>&#955;</code> of <code><b>R</b>[&#964;]</code>.
        * @return The norm of <code>&#955;</code>.
        */
		public static SimpleBigDecimal Norm(sbyte mu, SimpleBigDecimal u, SimpleBigDecimal v)
		{
			SimpleBigDecimal norm;

			// s1 = u^2
			SimpleBigDecimal s1 = u.Multiply(u);

			// s2 = u * v
			SimpleBigDecimal s2 = u.Multiply(v);

			// s3 = 2 * v^2
			SimpleBigDecimal s3 = v.Multiply(v).ShiftLeft(1);

			if(mu == 1)
			{
				norm = s1.Add(s2).Add(s3);
			}
			else if(mu == -1)
			{
				norm = s1.Subtract(s2).Add(s3);
			}
			else
			{
				throw new ArgumentException("mu must be 1 or -1");
			}

			return norm;
		}