public void ScalarMultiplyTest() { Vector <Complex1> vec1 = Vector <Complex1> .FromValues(new Complex1(1, 1), new Complex1(-2, 3), new Complex1(6, 0)); Vector <Complex1> vec2 = Vector <Complex1> .FromValues(new Complex1(0, 2), new Complex1(-3, 1), new Complex1(2, 2)); Complex1 expected = new Complex1(13, 3); Assert.AreEqual(expected, vec1.ScalarMultiply(vec2)); }
static void Main(string[] args) { // You must create instances of all properties to avoid a NullReferenceException // prior to accessing said properties var complex1 = new Complex1(); complex1.Complex2Property = new Complex2(); // Set property of property complex1.Complex2Property.IntProperty = 7; }
public void DivideTest() { Complex1[] first = new Complex1[] { new Complex1(6, -8), new Complex1(3, 22), new Complex1(-6, -34) }; Complex1[] second = new Complex1[] { new Complex1(0, -2), new Complex1(5, 2), new Complex1(2, -2) }; Complex1[] expected = new Complex1[] { new Complex1(4, 3), new Complex1(59.0 / 29, 104.0 / 29), new Complex1(7, -10) }; for (int i = 0; i < first.Length; ++i) { Assert.AreEqual(expected[i], Complex1.Divide(first[i], second[i]), $"Test #{i}"); } }
public void MultiplyTest() { Complex1[] first = new Complex1[] { new Complex1(6, -8), new Complex1(3, 22), new Complex1(-6, -34) }; Complex1[] second = new Complex1[] { new Complex1(0, -2), new Complex1(5, 2), new Complex1(2, -2) }; Complex1[] expected = new Complex1[] { new Complex1(-16, -12), new Complex1(-29, 116), new Complex1(-80, -56) }; for (int i = 0; i < first.Length; ++i) { Assert.AreEqual(expected[i], Complex1.Multiply(first[i], second[i]), $"Test #{i}"); } }
public void PowTest() { Complex1[] numbers = new Complex1[] { new Complex1(6, -8), new Complex1(3, 22), new Complex1(-6, -34) }; double[] powers = new double[] { 2, 3.14, -2 }; Complex1[] expected = new Complex1[] { new Complex1(-28, -96), new Complex1(-3450.04, -16539.4), new Complex1(-35.0 / 44402, -51.0 / 177608) }; for (int i = 0; i < numbers.Length; ++i) { Complex1 result = numbers[i].Pow(powers[i]); Assert.AreEqual(expected[i].Real, result.Real, 0.1, $"Real in test #{i}"); Assert.AreEqual(expected[i].Imaginary, result.Imaginary, 0.1, $"Imaginary in test #{i}"); } }
public void ParamsTest() { Complex1[] numbers = new Complex1[] { new Complex1(3, 4), new Complex1(-2, 6), new Complex1(5, -4), new Complex1(-3, -6) }; double[] expectedRadius = new double[] { 5, 6.324, 6.403, 6.708 }; double[] expectedPhase = new double[] { 0.927, 1.892, -0.674, -2.034 }; for (int i = 0; i < numbers.Length; ++i) { Assert.AreEqual(expectedRadius[i], numbers[i].Magnitude, 0.01, $"Radius test number {i}"); Assert.AreEqual(expectedPhase[i], numbers[i].Phase, 0.01, $"Phase test number {i}"); } }
public IComplex1 ProvideComplex(Complex1 complex) { return(complex); }
public IComplex1 ProvideComplex(Complex1 complex) => complex;
public ReferenceDataBuilder setProp1(Complex1 value) { this.prop1 = value; return(this); }
public ReferenceData(Complex1 prop1, Complex2 prop2, Complex3 prop3) { this.Prop1 = prop1; this.Prop2 = prop2; this.Prop3 = prop3; }
public DivisionByZeroEventArgs(Complex1 first, Complex1 second) { First = first; Second = second; }