/** IBM SOFTWARE DISCLAIMER Java array package (draft 0.2). Copyright (1998), International Business Machines Corporation. Permission to use, copy, modify and distribute this software for any noncommercial purpose and without fee is hereby granted, provided that this copyright and permission notice appear on all copies of the software. The name of the IBM Corporation may not be used in any advertising or publicity pertaining to the use of the software. IBM makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. IBM shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software. */ import array.*; public class MatMul { public static double inner(doubleArray1D a, doubleArray1D b) throws NonconformingArrayException { /* * Compute the inner product of two vectors, a and b, represented * as one-dimensional arrays. The two vectors must have the * same number of elements. */ int n = a.size(); if (n != b.size()) throw new NonconformingArrayException(); double sum = 0.0; for (int i=0; i] [-n ] [-p

] [-print]"); return; } System.out.println("matrix multiply: "+m+" x "+n+" x "+p); /* * Initialize the matrices A(mxn) and B(nxp) so that * row i of each has all elements equal to i. */ doubleArray2D A = new doubleArray2D(m,n); doubleArray2D B = new doubleArray2D(n,p); for (int i=0; i 0) System.out.println(); if (p > 0) System.out.print(C.get(i,0)); for (int j=1; j eps) { System.out.println("error in result"); return; } } } double mflops = 1.0e-3*(2.0*m*n*p)/etime; System.out.println("mflops: "+mflops); } }