public static Matrix multiply(Matrix matrixA, Matrix matrixB) throws 
            IllegalSizesException, MatrixIndexOutOfBoundsException {

        Matrix matrixC = null;
        int rowsA = matrixA.getRowsCount();
        int colsA = matrixA.getColsCount();
        int rowsB = matrixB.getRowsCount();
        int colsB = matrixB.getColsCount();
        System.out.println("Multiplication of matrixes A" + rowsA
                + "x" + colsA + " and B" + rowsB + "x" + colsB + ".");

        if ((rowsA != colsB) && (colsA != rowsB)) {
            throw new IllegalSizesException("Illegal matrix dimensions.");
        }

        dataTypeA = matrixA.getDataType();
        dataTypeB = matrixB.getDataType();
        //creates the matrix analising data type of matrixes A and B
        if (dataTypeA.equals(dataTypeB)) {
            matrixC = MatrixSelector.getMatrix(rowsA, colsB, DataType.getDataType(dataTypeA));
            //throw new IncorrectFormatOfData("Data of matrixes are not identical.");
        } else {
            matrixC = MatrixSelector.getMatrix(rowsA, colsB, DataType.DOUBLE);
        }

        System.out.println("Type of data is " + dataTypeA + ".");

        matrixC = MatrixSelector.getMatrix(rowsA, colsB, DataType.getDataType(dataTypeA));
        //temporary variable
        double temp = 0;
        //It is one-tenth of the number of rows of the matrix
        int stepProgress = rowsA / 10;
        //run time
        long startTime = System.currentTimeMillis();

        for (int i = 0; i < rowsA; i++) {

            if ((rowsA >= 1000) && (i % stepProgress == 0)) {
                //Multiplication progress
                System.out.println("Multiplication progress " + i / stepProgress * 10 + "%.");
            }
            for (int j = 0; j < colsB; j++) {
                for (int k = 0; k < colsA; k++) {
                    temp += matrixA.getValue(i, k) * matrixB.getValue(k, j);
                }
                matrixC.setValue(i, j, temp);
                temp = 0;
            }
        }

        //run time
        long endTime = System.currentTimeMillis();
        long time = endTime - startTime;

        System.out.println("Multiplication of matrixes lasted " + time + " ms.");

        return matrixC;
    }