コード例 #1
0
ファイル: Matrix2.java プロジェクト: Chabernac/p2pmessenger
 @Override
 public AbstractMatrix multiply(AbstractMatrix aMatrix) throws MatrixException {
   if (getColumns() != aMatrix.getRows()) {
     throw new MatrixException(
         "Could not multiply matrices ["
             + getRows()
             + ","
             + getColumns()
             + "] x ["
             + aMatrix.getRows()
             + ","
             + aMatrix.getColumns()
             + "]");
   }
   Matrix2 theMatrix = new Matrix2(getRows(), aMatrix.getColumns());
   double theValue = 0;
   for (int theMultiplyColumn = 0; theMultiplyColumn < aMatrix.getColumns(); theMultiplyColumn++) {
     for (int theMultiplyRow = 0; theMultiplyRow < getRows(); theMultiplyRow++) {
       theValue = 0;
       for (int thePosition = 0; thePosition < getColumns(); thePosition++) {
         theValue +=
             getValueAt(theMultiplyRow, thePosition)
                 * aMatrix.getValueAt(thePosition, theMultiplyColumn);
       }
       theMatrix.setValueAt(theMultiplyRow, theMultiplyColumn, theValue);
     }
   }
   return theMatrix;
 }