operator -(ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.NegateInplace(); return(ret); }
operator -( ComplexRational rational, ComplexPolynomial polynomial) { ComplexRational ret = new ComplexRational(rational); ret.SubtractInplace(polynomial); return(ret); }
operator -( ComplexRational rational, double n) { ComplexRational ret = new ComplexRational(rational); ret.SubtractInplace(n); return(ret); }
operator *( Complex n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.MultiplyInplace(n); return(ret); }
operator /( ComplexPolynomial polynomial, ComplexRational rational) { ComplexRational ret = rational.Divide(polynomial); ret.InvertInplace(); return(ret); }
operator /( ComplexRational rational, double n) { ComplexRational ret = new ComplexRational(rational); ret.DivideInplace(n); return(ret); }
operator +( Complex n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.AddInplace(n); return(ret); }
operator +( ComplexPolynomial polynomial, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.AddInplace(polynomial); return(ret); }
operator /( double n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.InvertInplace(); ret.MultiplyInplace(n); return(ret); }
CompareTo(ComplexRational rational) { int n = _numerator.CompareTo(rational._numerator); if (n == 0) { n = _denominator.CompareTo(rational._denominator); } return(n); }
Subtract(ComplexRational rational) { if (_denominator.Equals(rational._denominator)) { return(new ComplexRational( _numerator - rational._numerator, _denominator.Clone())); } ComplexPolynomial num = (_numerator * rational._denominator) - (rational._numerator * _denominator); ComplexPolynomial denom = _denominator * rational._denominator; return(new ComplexRational(num, denom)); }
/// <summary> /// Create a new rational as the result of multiplying a rational to this rational. /// </summary> /// <param name="rational">The rational to multiply with.</param> public ComplexRational Multiply(ComplexRational rational) { return new ComplexRational( _numerator * rational._numerator, _denominator * rational._denominator); }
/// <summary> /// Subtract a polynomial from a rational. /// </summary> public static ComplexRational operator -( ComplexRational rational, ComplexPolynomial polynomial) { ComplexRational ret = new ComplexRational(rational); ret.SubtractInplace(polynomial); return ret; }
/// <summary> /// Subtract a rational from a polynomial. /// </summary> public static ComplexRational operator -( ComplexPolynomial polynomial, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.NegateInplace(); ret.AddInplace(polynomial); return ret; }
/// <summary> /// Subtract a real number from a rational. /// </summary> public static ComplexRational operator -( ComplexRational rational, double n) { ComplexRational ret = new ComplexRational(rational); ret.SubtractInplace(n); return ret; }
/// <summary> /// Negate a rational. /// </summary> public static ComplexRational operator -(ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.NegateInplace(); return ret; }
/// <summary> /// Stretch a rational with a real number quotient. /// </summary> public static ComplexRational operator /( ComplexRational rational, double n) { ComplexRational ret = new ComplexRational(rational); ret.DivideInplace(n); return ret; }
/// <summary> /// Stretch a the inverse of a rational with a real number quotient. /// </summary> public static ComplexRational operator /( double n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.InvertInplace(); ret.MultiplyInplace(n); return ret; }
/// <summary> /// Check whether two rationals are equal. /// </summary> public static bool Equals( ComplexRational rational1, ComplexRational rational2) { return rational1.Equals(rational2); }
/// <summary> /// Add a rational to a real number. /// </summary> public static ComplexRational operator +( Complex n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.AddInplace(n); return ret; }
Equals(ComplexRational rational) { return(_numerator.Equals(rational._numerator) && _denominator.Equals(rational._denominator)); }
/// <summary> /// Check whether this rational is equal to another rational. /// </summary> public bool Equals(ComplexRational rational) { return _numerator.Equals(rational._numerator) && _denominator.Equals(rational._denominator); }
/// <summary> /// Create a new rational as the result of dividing a rational from this rational. /// </summary> /// <param name="rational">The rational to divide with.</param> public ComplexRational Divide(ComplexRational rational) { return new ComplexRational( _numerator * rational._denominator, _denominator * rational._numerator); }
/// <summary> /// Compare this rational to another rational. /// </summary> public int CompareTo(ComplexRational rational) { int n = _numerator.CompareTo(rational._numerator); if(n == 0) { n = _denominator.CompareTo(rational._denominator); } return n; }
Divide(ComplexRational rational) { return(new ComplexRational( _numerator * rational._denominator, _denominator * rational._numerator)); }
/// <summary> /// Create a new rational as the result of subtracting a rational from this rational. /// </summary> /// <param name="rational">The rational to subtract.</param> public ComplexRational Subtract(ComplexRational rational) { if(_denominator.Equals(rational._denominator)) { return new ComplexRational( _numerator - rational._numerator, _denominator.Clone()); } ComplexPolynomial num = (_numerator * rational._denominator) - (rational._numerator * _denominator); ComplexPolynomial denom = _denominator * rational._denominator; return new ComplexRational(num, denom); }
Equals( ComplexRational rational1, ComplexRational rational2) { return(rational1.Equals(rational2)); }
/// <summary> /// Initializes a new instance of the ComplexRational class, /// by deep-copy from an existing complex rational. /// </summary> /// <param name="copy">A rational to copy from.</param> public ComplexRational(ComplexRational copy) { _numerator = new ComplexPolynomial(copy._numerator); _denominator = new ComplexPolynomial(copy._denominator); }
ComplexRational(ComplexRational copy) { _numerator = new ComplexPolynomial(copy._numerator); _denominator = new ComplexPolynomial(copy._denominator); }
/// <summary> /// Stretch a polynomial with a real number factor. /// </summary> public static ComplexRational operator *( Complex n, ComplexRational rational) { ComplexRational ret = new ComplexRational(rational); ret.MultiplyInplace(n); return ret; }