Example #1
0
        public void ComplexIsReal()
        {
            Complex <double> complex1 = new Complex <double>(1, 0);
            bool             result   = complex1.IsReal();

            Assert.IsTrue(result);
        }
Example #2
0
        public static string FullVisualization(this Complex num)
        {
            string output = string.Empty;

            output += num.Real.ToString();
            if (!num.IsReal())
            {
                output += " +i" + num.Imaginary.ToString();
            }
            return(output);
        }
Example #3
0
 public static Complex Modulus(this Complex num1, Complex num2)
 {
     if (!num1.IsReal())
     {
         ErrorLog.Add(new ErrorMessage("Imaginary part ignored for first parameter"));
     }
     if (!num2.IsReal())
     {
         ErrorLog.Add(new ErrorMessage("Imaginary part ignored for second parameter"));
     }
     return(new Complex(num1.Real % num2.Real, 0));
 }
Example #4
0
 public static Complex Factorial(this Complex num)
 {
     if (!num.IsReal())
     {
         ErrorLog.Add(new ErrorMessage("Imaginary part ignored"));
     }
     if (Math.Floor(num.Real) != num.Real)
     {
         ErrorLog.Add(new ErrorMessage("Rounded to the nearest integer"));
     }
     return(new Complex(MathNet.Numerics.Combinatorics.Permutations((int)num.Real), 0));
 }
Example #5
0
        public void CanDetermineIfRealNumber()
        {
            var complex = new Complex(-1, 0);

            Assert.IsTrue(complex.IsReal(), "Is a real number.");
        }
Example #6
0
        public void CanDetermineIfRealNonNegativeNumber()
        {
            var complex = new Complex(1, 0);

            Assert.IsTrue(complex.IsReal(), "Is a real non-negative number.");
        }
Example #7
0
 public void CanDetermineIfRealNumber()
 {
     var complex = new Complex(-1, 0);
     Assert.IsTrue(complex.IsReal(), "Is a real number.");
 }
Example #8
0
 public void CanDetermineIfRealNonNegativeNumber()
 {
     var complex = new Complex(1, 0);
     Assert.IsTrue(complex.IsReal(), "Is a real non-negative number.");
 }
Example #9
0
 /// <summary>
 /// The Square (power 2) of this <c>Complex</c>
 /// </summary>
 /// <param name="complex">The <see cref="Complex"/> number to perform this operation on.</param>
 /// <returns>
 /// The square of this complex number.
 /// </returns>
 public static Complex Square(this Complex complex)
 => complex.IsReal() ?
 new Complex(complex.Real * complex.Real, 0.0) :
 new Complex(complex.Real * complex.Real - complex.Imaginary * complex.Imaginary, 2 * complex.Real * complex.Imaginary);