//------------------------------------------------------------------------------------- //Скалярное произведение public static double operator *(RealVector operandOne, RealVector operandTwo) { double scalarProduct = ArrayOperator.ScalarProduct (operandOne.dataArray, operandTwo.dataArray); return(scalarProduct); }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ //Умножение матриц public static IntegerMatrix operator *(IntegerMatrix matrixOne, IntegerMatrix matrixTwo) { int rowCountMatrixOne = matrixOne.rowCount; int rowCountMatrixTwo = matrixTwo.rowCount; int columnCountMatrixOne = matrixOne.columnCount; int columnCountMatrixTwo = matrixTwo.columnCount; if (columnCountMatrixOne != rowCountMatrixTwo) { throw new MatrixException(); } IntegerMatrix resultMatrix = new IntegerMatrix(rowCountMatrixOne, columnCountMatrixTwo); for (int row = 0; row < rowCountMatrixOne; row++) { int[] dataRow = matrixOne.GetRow(row); for (int column = 0; column < columnCountMatrixTwo; column++) { int[] dataColumn = matrixTwo.GetColumn(column); int result = ArrayOperator.ScalarProduct(dataRow, dataColumn); resultMatrix[row, column] = result; } } return(resultMatrix); }
//------------------------------------------------------------------------------------- //Скалярное произведение public static int operator *(IntegerVector operandOne, IntegerVector operandTwo) { int scalarProduct = ArrayOperator.ScalarProduct (operandOne.dataArray, operandTwo.dataArray); return(scalarProduct); }
//------------------------------------------------------------------------------------------ //Умножение на вектор public static IntegerVector operator *(IntegerMatrix matrix, IntegerVector vector) { int columnCountMatrix = matrix.columnCount; int sizeVector = vector.Size; if (columnCountMatrix != sizeVector) { throw new MatrixException(); } IntegerVector newVector = new IntegerVector(sizeVector); int rowCountMatrix = matrix.rowCount; int[] dataVector = vector.GetDataArray(); for (int row = 0; row < rowCountMatrix; row++) { int[] dataRow = matrix.GetRow(row); int value = ArrayOperator.ScalarProduct(dataRow, dataVector); newVector[row] = value; } return(newVector); }