Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestableComplexMatrixDoubleMatrixElementWiseMultiplication{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 TestableComplexMatrixDoubleMatrixElementWiseMultiplication(
     TExpected expected,
     TestableComplexMatrix left,
     TestableDoubleMatrix right) :
     base(
         expected,
         left,
         right,
         leftWritableRightWritableOps:
         new Func <ComplexMatrix, DoubleMatrix, ComplexMatrix>[1] {
     (l, r) => ComplexMatrix.ElementWiseMultiply(l, r)
 },
         leftReadOnlyRightWritableOps:
         new Func <ReadOnlyComplexMatrix, DoubleMatrix, ComplexMatrix>[1] {
     (l, r) => ReadOnlyComplexMatrix.ElementWiseMultiply(l, r)
 },
         leftWritableRightReadOnlyOps:
         new Func <ComplexMatrix, ReadOnlyDoubleMatrix, ComplexMatrix>[1] {
     (l, r) => ComplexMatrix.ElementWiseMultiply(l, r)
 },
         leftReadOnlyRightReadOnlyOps:
         new Func <ReadOnlyComplexMatrix, ReadOnlyDoubleMatrix, ComplexMatrix>[1] {
     (l, r) => ReadOnlyComplexMatrix.ElementWiseMultiply(l, r)
 }
         )
 {
 }
Exemplo n.º 2
0
        public void Main()
        {
            // Create the left operand.
            var 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 left = ComplexMatrix.Dense(3, 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);

            // Element wise multiply left by right.
            var result = ComplexMatrix.ElementWiseMultiply(left, right);

            Console.WriteLine();
            Console.WriteLine("Element wise multiplication: left * right =");
            Console.WriteLine(result);

            // Class ReadOnlyComplexMatrix supports element wise multiplications
            // where some arguments are read-only matrices.
            // Compute the product using a read-only wrapper of left.
            ReadOnlyComplexMatrix readOnlyLeft = left.AsReadOnly();

            result = ReadOnlyComplexMatrix.ElementWiseMultiply(readOnlyLeft, right);

            Console.WriteLine();
            Console.WriteLine("Element wise multiplication: readOnlyLeft * right =");
            Console.WriteLine(result);
        }