Java Reference
In-Depth Information
private Matrix a, b, c;
private int row;
MatMult(Matrix a, Matrix b, Matrix c)
{
this(a, b, c, -1);
}
MatMult(Matrix a, Matrix b, Matrix c, int row)
{
if (a.getCols() != b.getRows())
throw new IllegalArgumentException("rows/columns
mismatch");
this.a = a;
this.b = b;
this.c = c;
this.row = row;
}
@Override
public void compute()
{
if (row == -1)
{
List<MatMult> tasks = new ArrayList<>();
for (int row = 0; row < a.getRows(); row++)
tasks.add(new MatMult(a, b, c, row));
invokeAll(tasks);
}
else
multiplyRowByColumn(a, b, c, row);
}
static void multiplyRowByColumn(Matrix a, Matrix b, Mat-
rix c, int row)
{
for (int j = 0; j < b.getCols(); j++)
for (int k = 0; k < a.getCols(); k++)
c.setValue(row,
j,
c.getValue(row,
j)+a.getValue(row, k)*
Search WWH ::




Custom Search