Пример #1
0
        public static Matrix DotVersion0(Matrix leftMatrix, Matrix rightMatrix)
        {
            if (leftMatrix.Shape[1] != rightMatrix.Shape[0])
            {
                throw new ArgumentException("Shapes of matrices aren`t aligned");
            }
            Matrix resultMatrix = new Matrix(leftMatrix.Shape[0], rightMatrix.Shape[1]);

            rightMatrix = Matrix.Transpose(rightMatrix);

            for (Int32 row = 0; row < leftMatrix.Shape[0]; ++row)
            {
                for (Int32 col = 0; col < rightMatrix.Shape[0]; ++col)
                {
                    resultMatrix[row, col] = Matrix.VecMul(leftMatrix[row], rightMatrix[col]);
                }
            }

            return(resultMatrix);
        }