Multiply() public method

public Multiply ( BigInteger b ) : SimpleBigDecimal
b BigInteger
return SimpleBigDecimal
Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static SimpleBigDecimal Norm(sbyte mu, SimpleBigDecimal u, SimpleBigDecimal v)
        {
            SimpleBigDecimal num2 = u.Multiply(u);
            SimpleBigDecimal b    = u.Multiply(v);
            SimpleBigDecimal num4 = v.Multiply(v).ShiftLeft(1);

            if (mu == 1)
            {
                return(num2.Add(b).Add(num4));
            }
            if (mu != -1)
            {
                throw new ArgumentException("mu must be 1 or -1");
            }
            return(num2.Subtract(b).Add(num4));
        }
Exemplo n.º 3
0
        public static SimpleBigDecimal Norm(sbyte mu, SimpleBigDecimal u, SimpleBigDecimal v)
        {
            //IL_004b: Unknown result type (might be due to invalid IL or missing references)
            SimpleBigDecimal simpleBigDecimal = u.Multiply(u);
            SimpleBigDecimal b  = u.Multiply(v);
            SimpleBigDecimal b2 = v.Multiply(v).ShiftLeft(1);

            switch (mu)
            {
            case 1:
                return(simpleBigDecimal.Add(b).Add(b2));

            case -1:
                return(simpleBigDecimal.Subtract(b).Add(b2));

            default:
                throw new ArgumentException("mu must be 1 or -1");
            }
        }
Exemplo n.º 4
0
        public static SimpleBigDecimal Norm(sbyte mu, SimpleBigDecimal u, SimpleBigDecimal v)
        {
            SimpleBigDecimal simpleBigDecimal = u.Multiply(u);
            SimpleBigDecimal b  = u.Multiply(v);
            SimpleBigDecimal b2 = v.Multiply(v).ShiftLeft(1);
            SimpleBigDecimal result;

            if (mu == 1)
            {
                result = simpleBigDecimal.Add(b).Add(b2);
            }
            else
            {
                if (mu != -1)
                {
                    throw new ArgumentException("mu must be 1 or -1");
                }
                result = simpleBigDecimal.Subtract(b).Add(b2);
            }
            return(result);
        }
Exemplo n.º 5
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;
        }