Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void multiplySquareMtxSimple(Node node)
- {
- int myId = node.getMyId();
- int meshSideSize = (int) Math.sqrt(node.getNumberOfAllNodes());
- int myRow = Topology.meshRowOfId(myId, meshSideSize);
- int myCol = Topology.meshColOfId(myId, meshSideSize);
- int nNodes = node.getNumberOfAllNodes();
- // TODO
- // ...
- // System.out.println(myId + " " + myRow + " " + myCol);
- double[] myDataA = node.A.getMatrixRowwise();
- double[] myDataB = node.B.getMatrixRowwise();
- // Matrix otherDtataA = new Matrix(node.A.getNRows(), node.A.getNCols());
- // Matrix otherDtataB = new Matrix(node.B.getNRows(), node.B.getNCols());
- //
- // Matrix resultData = new Matrix(node.A.getNRows(), node.B.getNCols());
- // .Matrix(node.A.getNRows(), node.B.getNCols(), data );
- Matrix[] dataA = new Matrix[meshSideSize];
- /* for (int i = 0; i < meshSideSize; i++)
- {
- dataA[i] = new Matrix(node.A.getNRows(), node.A.getNCols());
- }
- */
- Matrix[] dataB = new Matrix[meshSideSize];
- /*for (int i = 0; i < meshSideSize; i++)
- {
- dataB[i] = new Matrix(node.B.getNRows(), node.B.getNCols());
- }*/
- int ACounter = 0;
- int BCounter = 0;
- double[] otherData;
- for (int i=0; i<nNodes; i++)
- {
- if (myRow == Topology.meshRowOfId(i, node.A.getNRows())& i!=myId)
- {
- otherData = BasicCommunication.exchangeWith(node, i, myDataA);
- dataA[ACounter] = new Matrix(node.A.getNRows(), node.A.getNCols(), otherData);
- //ACounter++;
- //System.out.println(myId + " -> " + i);
- }
- if (i==myId)
- {
- dataA[ACounter] = new Matrix(node.A.getNRows(), node.A.getNCols(), myDataA);
- //ACounter++;
- }
- if (myCol == Topology.meshColOfId(i, node.B.getNCols())& i!=myId)
- {
- otherData = BasicCommunication.exchangeWith(node, i, myDataB);
- dataB[BCounter] = new Matrix(node.B.getNRows(), node.B.getNCols(), otherData);
- BCounter++;
- //System.out.println(myId + " -> " + i);
- }
- if (i==myId)
- {
- dataB[BCounter] = new Matrix(node.B.getNRows(), node.B.getNCols(), myDataB);
- BCounter++;
- }
- }
- Matrix resultMatrix = new Matrix(node.A.getNRows(), node.B.getNCols());
- for (int i = 0; i < meshSideSize; i++)
- {
- for (int j = 0; j < meshSideSize; j++)
- resultMatrix.addInPlace(dataA[i].times(dataB[j]));
- }
- if (true)
- {
- System.out.println(myId);
- }
- node.C = resultMatrix.divideInPlace(meshSideSize);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement