예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestableComplexMatrixDoubleMatrixDivision{TExpected}"/> class.
 /// </summary>
 /// <param name="expected">The expected result or exception.</param>
 /// <param name="left">The left operand.</param>
 /// <param name="right">The right operand.</param>
 public TestableComplexMatrixDoubleMatrixDivision(
     TExpected expected,
     TestableComplexMatrix left,
     TestableDoubleMatrix right) :
     base(
         expected,
         left,
         right,
         leftWritableRightWritableOps:
         new Func <ComplexMatrix, DoubleMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ComplexMatrix.Divide(l, r)
 },
         leftReadOnlyRightWritableOps:
         new Func <ReadOnlyComplexMatrix, DoubleMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ReadOnlyComplexMatrix.Divide(l, r)
 },
         leftWritableRightReadOnlyOps:
         new Func <ComplexMatrix, ReadOnlyDoubleMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ComplexMatrix.Divide(l, r)
 },
         leftReadOnlyRightReadOnlyOps:
         new Func <ReadOnlyComplexMatrix, ReadOnlyDoubleMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ReadOnlyComplexMatrix.Divide(l, r)
 }
         )
 {
 }
예제 #2
0
        public void Main()
        {
            // Create the left operand.
            var data = new Complex[4] {
                new Complex(0, 0), new Complex(2, 2),
                new Complex(1, 1), new Complex(3, 3)
            };
            var left = ComplexMatrix.Dense(2, 2, data, StorageOrder.RowMajor);

            Console.WriteLine("left =");
            Console.WriteLine(left);

            // Create the right operand.
            data = new Complex[6] {
                new Complex(1, -1), new Complex(5, -5),
                new Complex(2, -2), new Complex(6, -6),
                new Complex(3, -3), new Complex(7, -7)
            };
            var right = ComplexMatrix.Dense(3, 2, data, StorageOrder.RowMajor);

            Console.WriteLine("right =");
            Console.WriteLine(right);

            // Divide left by right.
            var result = left / right;

            Console.WriteLine();
            Console.WriteLine("left / right =");
            Console.WriteLine(result);

            // In .NET languages that do not support overloaded operators,
            // you can use the alternative methods named Divide.
            result = ComplexMatrix.Divide(left, right);

            Console.WriteLine();
            Console.WriteLine("ComplexMatrix.Divide(left, right) returns");
            Console.WriteLine();
            Console.WriteLine(result);

            // Both operators and alternative methods are overloaded to
            // support read-only matrix arguments.
            // Compute the division using a read-only wrapper of left.
            ReadOnlyComplexMatrix readOnlyLeft = left.AsReadOnly();

            result = readOnlyLeft / right;

            Console.WriteLine();
            Console.WriteLine("readOnlyLeft / right =");
            Console.WriteLine(result);
        }
예제 #3
0
 public TestableComplexMatrixDoubleScalarDivision(
     TExpected expected,
     TestableComplexMatrix left,
     double right) :
     base(
         expected,
         left,
         right,
         leftWritableRightScalarOps:
         new Func <ComplexMatrix, double, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ComplexMatrix.Divide(l, r)
 },
         leftReadOnlyRightScalarOps:
         new Func <ReadOnlyComplexMatrix, double, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ReadOnlyComplexMatrix.Divide(l, r)
 }
         )
 {
 }
 public TestableDoubleScalarComplexMatrixDivision(
     TExpected expected,
     double left,
     TestableComplexMatrix right) :
     base(
         expected,
         left,
         right,
         leftScalarRightWritableOps:
         new Func <double, ComplexMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ComplexMatrix.Divide(l, r)
 },
         leftScalarRightReadOnlyOps:
         new Func <double, ReadOnlyComplexMatrix, ComplexMatrix>[2] {
     (l, r) => l / r,
     (l, r) => ReadOnlyComplexMatrix.Divide(l, r)
 }
         )
 {
 }