コード例 #1
0
        // INNER PRODUCT
        public IComplexMatrix Multiplication(IComplexMatrix matrixA, IComplexMatrix matrixB)
        {
            int maxRow = System.Math.Min(matrixA.getNumRows(), matrixB.getNumRows());
            int maxCol = System.Math.Min(matrixA.getNumCols(), matrixB.getNumCols());
            //if (matrixA.getNumRows() != matrixB.getNumCols()) { throw new ExceptionMatrixDimension(); };

            IComplexMatrix resultMatrix = ComplexMatrixFactory.GenerateComplexMatrix(maxRow, maxCol, false);
            IComplexMatrix vectorA, vectorB;
            IComplexNumber coefficient;
            for (int i = 0; i < maxRow; i++)
            {
                for (int j = 0; j < maxCol; j++)
                {
                    vectorA = matrixA.extractRowAsVector(i);
                    vectorB = matrixB.extractColAsVector(j);
                    coefficient = ComplexMatrixFactory.Operations.Dot(vectorA, vectorB);
                    resultMatrix.setElement(coefficient, i, j);
                }
            }

            return resultMatrix;
        }