/** * Computes the norm of an element <code>λ</code> of * <code><b>R</b>[τ]</code>, where <code>λ = u + vτ</code> * and <code>u</code> and <code>u</code> are real numbers (elements of * <code><b>R</b></code>). * @param mu The parameter <code>μ</code> of the elliptic curve. * @param u The real part of the element <code>λ</code> of * <code><b>R</b>[τ]</code>. * @param v The <code>τ</code>-adic part of the element * <code>λ</code> of <code><b>R</b>[τ]</code>. * @return The norm of <code>λ</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); }
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)); }
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"); } }
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); }
/** * Computes the norm of an element <code>λ</code> of * <code><b>R</b>[τ]</code>, where <code>λ = u + vτ</code> * and <code>u</code> and <code>u</code> are real numbers (elements of * <code><b>R</b></code>). * @param mu The parameter <code>μ</code> of the elliptic curve. * @param u The real part of the element <code>λ</code> of * <code><b>R</b>[τ]</code>. * @param v The <code>τ</code>-adic part of the element * <code>λ</code> of <code><b>R</b>[τ]</code>. * @return The norm of <code>λ</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; }