double array2[][] = UtilFns.toDoubleMatrix(args[1]);
//if array dimension mismatch, can't do anymore, return #VALUE! error
if (array1[0].length != array2.length)
{
throw new SSErrorXelException(SSError.VALUE);
}
else
{
RealMatrix m1 = new RealMatrixImpl(array1);
RealMatrix m2 = new RealMatrixImpl(array2);
try{
//now do the really matrix multiplication.
RealMatrix mmultResult = m1.multiply(m2);
Double result[][] = new Double[mmultResult.getRowDimension()][mmultResult.getColumnDimension()];
for(int row =0; row < mmultResult.getRowDimension(); row++)
{
for(int column =0; column < mmultResult.getColumnDimension(); column++)
{
// put the answer to return matrix and use toDouble15() to get around the floating-point arithm conversion problem.
result[row][column] = UtilFns.toDouble15(mmultResult.getEntry(row, column), BigDecimal.ROUND_HALF_UP);
}
}
return result;
}
//shouldn't happen to run into this exception. because the dimensions had been checked above.
catch(IllegalArgumentException e){
throw new SSErrorXelException(SSError.VALUE);
}
}
}