Here you can find the source of matrixMultiplyWithThreadOffset(double[] A, double[] Adiag, double[] B, int aHeight, int bWidth, int comm, int bz, int threadRowOffset, int rowOffset, double[] C)
public static void matrixMultiplyWithThreadOffset(double[] A, double[] Adiag, double[] B, int aHeight, int bWidth, int comm, int bz, int threadRowOffset, int rowOffset, double[] C)
//package com.java2s; //License from project: Apache License public class Main { public static void matrixMultiplyWithThreadOffset(double[] A, double[] Adiag, double[] B, int aHeight, int bWidth, int comm, int bz, int threadRowOffset, int rowOffset, double[] C) { int aHeightBlocks = aHeight / bz; // size = Height of A int aLastBlockHeight = aHeight - (aHeightBlocks * bz); if (aLastBlockHeight > 0) { aHeightBlocks++;/*w ww. j a v a2 s .c o m*/ } int bWidthBlocks = bWidth / bz; // size = Width of B int bLastBlockWidth = bWidth - (bWidthBlocks * bz); if (bLastBlockWidth > 0) { bWidthBlocks++; } int commnBlocks = comm / bz; // size = Width of A or Height of B int commLastBlockWidth = comm - (commnBlocks * bz); if (commLastBlockWidth > 0) { commnBlocks++; } int aBlockHeight = bz; int bBlockWidth = bz; int commBlockWidth = bz; double kTmp; double kiAdiag; int iOffset; for (int ib = 0; ib < aHeightBlocks; ib++) { if (aLastBlockHeight > 0 && ib == (aHeightBlocks - 1)) { aBlockHeight = aLastBlockHeight; } bBlockWidth = bz; commBlockWidth = bz; for (int jb = 0; jb < bWidthBlocks; jb++) { if (bLastBlockWidth > 0 && jb == (bWidthBlocks - 1)) { bBlockWidth = bLastBlockWidth; } commBlockWidth = bz; for (int kb = 0; kb < commnBlocks; kb++) { if (commLastBlockWidth > 0 && kb == (commnBlocks - 1)) { commBlockWidth = commLastBlockWidth; } for (int i = ib * bz; i < (ib * bz) + aBlockHeight; i++) { iOffset = i * bWidth; for (int j = jb * bz; j < (jb * bz) + bBlockWidth; j++) { for (int k = kb * bz; k < (kb * bz) + commBlockWidth; k++) { kiAdiag = 0; if (i + rowOffset == k) { kiAdiag = Adiag[i]; } else { //reverse the value from weight kiAdiag = -(A[(i + threadRowOffset) * comm + k]); } kTmp = B[k * bWidth + j]; if (kiAdiag != 0 && kTmp != 0) { C[iOffset + j] += kiAdiag * kTmp; } } } } } } } } }