Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public FractionMatrix multiply(FractionMatrix that)
- {
- Fraction sum = new Fraction( 0, 1 );
- if (this.numberColumns() != that.numberRows())
- throw new MatrixException("incompatible matrix dimensions");
- Fraction[][] product = new Fraction[this.numberRows()][that.numberColumns()];
- int constant = this.numberRows();
- for (int row = 0; row < this.numberRows(); row++)
- {
- for (int col = 0; col < that.numberColumns(); col++)
- {
- for( int a = 0; a <= constant; a++ )
- {
- sum = sum.add( this.get( row, a ).multiply( that.get( a, col ) ) );
- System.out.println( sum );
- }
- product[row][col] = sum;
- sum = new Fraction( 0 , 1 );
- }
- }
- return new FractionMatrix( product );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement