org.ejml.dense.block.InnerMultiplication_FDRB Maven / Gradle / Ivy
Show all versions of ejml-fdense Show documentation
/*
* Copyright (c) 2009-2020, Peter Abeles. All Rights Reserved.
*
* This file is part of Efficient Java Matrix Library (EJML).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ejml.dense.block;
import javax.annotation.Generated;
import org.ejml.data.FMatrixRBlock;
/**
*
* Matrix multiplication for the inner row major blocks, typically inside of a {@link FMatrixRBlock}.
*
*
*
* This code was auto generated by GeneratorBlockInnerMultiplication and should not be modified directly.
*
*
* @author Peter Abeles
*/
@Generated("org.ejml.dense.block.InnerMultiplication_DDRB")
public class InnerMultiplication_FDRB {
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + A * B
*
*/
public static void blockMultPlus( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < heightA; i++ ) {
// for( int k = 0; k < widthA; k++ ) {
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];
// }
// }
// }
int a = indexA;
int rowC = indexC;
for (int i = 0; i < heightA; i++, rowC += widthC) {
int b = indexB;
final int endC = rowC + widthC;
final int endA = a + widthA;
while (a != endA) {//for( int k = 0; k < widthA; k++ ) {
float valA = dataA[a++];
int c = rowC;
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] += valA*dataB[b++];
}
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + AT * B
*
*/
public static void blockMultPlusTransA( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < widthA; i++ ) {
// for( int k = 0; k < heightA; k++ ) {
// float valA = dataA[k*widthA + i + indexA];
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += valA * dataB[k*widthC + j + indexB];
// }
// }
// }
int rowC = indexC;
for (int i = 0; i < widthA; i++, rowC += widthC) {
int colA = i + indexA;
int endA = colA + widthA*heightA;
int b = indexB;
// for( int k = 0; k < heightA; k++ ) {
while (colA != endA) {
float valA = dataA[colA];
int c = rowC;
final int endB = b + widthC;
//for( int j = 0; j < widthC; j++ ) {
while (b != endB) {
dataC[c++] += valA*dataB[b++];
}
colA += widthA;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + A * BT
*
*/
public static void blockMultPlusTransB( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
for (int i = 0; i < heightA; i++) {
for (int j = 0; j < widthC; j++) {
float val = 0;
for (int k = 0; k < widthA; k++) {
val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];
}
dataC[i*widthC + j + indexC] += val;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C - A * B
*
*/
public static void blockMultMinus( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < heightA; i++ ) {
// for( int k = 0; k < widthA; k++ ) {
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];
// }
// }
// }
int a = indexA;
int rowC = indexC;
for (int i = 0; i < heightA; i++, rowC += widthC) {
int b = indexB;
final int endC = rowC + widthC;
final int endA = a + widthA;
while (a != endA) {//for( int k = 0; k < widthA; k++ ) {
float valA = dataA[a++];
int c = rowC;
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] -= valA*dataB[b++];
}
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C - AT * B
*
*/
public static void blockMultMinusTransA( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < widthA; i++ ) {
// for( int k = 0; k < heightA; k++ ) {
// float valA = dataA[k*widthA + i + indexA];
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += valA * dataB[k*widthC + j + indexB];
// }
// }
// }
int rowC = indexC;
for (int i = 0; i < widthA; i++, rowC += widthC) {
int colA = i + indexA;
int endA = colA + widthA*heightA;
int b = indexB;
// for( int k = 0; k < heightA; k++ ) {
while (colA != endA) {
float valA = dataA[colA];
int c = rowC;
final int endB = b + widthC;
//for( int j = 0; j < widthC; j++ ) {
while (b != endB) {
dataC[c++] -= valA*dataB[b++];
}
colA += widthA;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C - A * BT
*
*/
public static void blockMultMinusTransB( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
for (int i = 0; i < heightA; i++) {
for (int j = 0; j < widthC; j++) {
float val = 0;
for (int k = 0; k < widthA; k++) {
val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];
}
dataC[i*widthC + j + indexC] -= val;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = A * B
*
*/
public static void blockMultSet( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < heightA; i++ ) {
// for( int k = 0; k < widthA; k++ ) {
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];
// }
// }
// }
int a = indexA;
int rowC = indexC;
for (int i = 0; i < heightA; i++, rowC += widthC) {
int b = indexB;
final int endC = rowC + widthC;
final int endA = a + widthA;
while (a != endA) {//for( int k = 0; k < widthA; k++ ) {
float valA = dataA[a++];
int c = rowC;
if (b == indexB) {
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] = valA*dataB[b++];
}
} else {
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] += valA*dataB[b++];
}
}
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = AT * B
*
*/
public static void blockMultSetTransA( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < widthA; i++ ) {
// for( int k = 0; k < heightA; k++ ) {
// float valA = dataA[k*widthA + i + indexA];
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += valA * dataB[k*widthC + j + indexB];
// }
// }
// }
int rowC = indexC;
for (int i = 0; i < widthA; i++, rowC += widthC) {
int colA = i + indexA;
int endA = colA + widthA*heightA;
int b = indexB;
// for( int k = 0; k < heightA; k++ ) {
while (colA != endA) {
float valA = dataA[colA];
int c = rowC;
final int endB = b + widthC;
//for( int j = 0; j < widthC; j++ ) {
if (b == indexB) {
while (b != endB) {
dataC[c++] = valA*dataB[b++];
}
} else {
while (b != endB) {
dataC[c++] += valA*dataB[b++];
}
}
colA += widthA;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = A * BT
*
*/
public static void blockMultSetTransB( final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
for (int i = 0; i < heightA; i++) {
for (int j = 0; j < widthC; j++) {
float val = 0;
for (int k = 0; k < widthA; k++) {
val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];
}
dataC[i*widthC + j + indexC] = val;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + α A * B
*
*/
public static void blockMultPlus( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < heightA; i++ ) {
// for( int k = 0; k < widthA; k++ ) {
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];
// }
// }
// }
int a = indexA;
int rowC = indexC;
for (int i = 0; i < heightA; i++, rowC += widthC) {
int b = indexB;
final int endC = rowC + widthC;
final int endA = a + widthA;
while (a != endA) {//for( int k = 0; k < widthA; k++ ) {
float valA = alpha*dataA[a++];
int c = rowC;
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] += valA*dataB[b++];
}
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + α AT * B
*
*/
public static void blockMultPlusTransA( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < widthA; i++ ) {
// for( int k = 0; k < heightA; k++ ) {
// float valA = dataA[k*widthA + i + indexA];
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += valA * dataB[k*widthC + j + indexB];
// }
// }
// }
int rowC = indexC;
for (int i = 0; i < widthA; i++, rowC += widthC) {
int colA = i + indexA;
int endA = colA + widthA*heightA;
int b = indexB;
// for( int k = 0; k < heightA; k++ ) {
while (colA != endA) {
float valA = alpha*dataA[colA];
int c = rowC;
final int endB = b + widthC;
//for( int j = 0; j < widthC; j++ ) {
while (b != endB) {
dataC[c++] += valA*dataB[b++];
}
colA += widthA;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = C + α A * BT
*
*/
public static void blockMultPlusTransB( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
for (int i = 0; i < heightA; i++) {
for (int j = 0; j < widthC; j++) {
float val = 0;
for (int k = 0; k < widthA; k++) {
val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];
}
dataC[i*widthC + j + indexC] += alpha*val;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = α A * B
*
*/
public static void blockMultSet( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < heightA; i++ ) {
// for( int k = 0; k < widthA; k++ ) {
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += dataA[i*widthA + k + indexA] * dataB[k*widthC + j + indexB];
// }
// }
// }
int a = indexA;
int rowC = indexC;
for (int i = 0; i < heightA; i++, rowC += widthC) {
int b = indexB;
final int endC = rowC + widthC;
final int endA = a + widthA;
while (a != endA) {//for( int k = 0; k < widthA; k++ ) {
float valA = alpha*dataA[a++];
int c = rowC;
if (b == indexB) {
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] = valA*dataB[b++];
}
} else {
while (c != endC) {//for( int j = 0; j < widthC; j++ ) {
dataC[c++] += valA*dataB[b++];
}
}
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = α AT * B
*
*/
public static void blockMultSetTransA( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
// for( int i = 0; i < widthA; i++ ) {
// for( int k = 0; k < heightA; k++ ) {
// float valA = dataA[k*widthA + i + indexA];
// for( int j = 0; j < widthC; j++ ) {
// dataC[ i*widthC + j + indexC ] += valA * dataB[k*widthC + j + indexB];
// }
// }
// }
int rowC = indexC;
for (int i = 0; i < widthA; i++, rowC += widthC) {
int colA = i + indexA;
int endA = colA + widthA*heightA;
int b = indexB;
// for( int k = 0; k < heightA; k++ ) {
while (colA != endA) {
float valA = alpha*dataA[colA];
int c = rowC;
final int endB = b + widthC;
//for( int j = 0; j < widthC; j++ ) {
if (b == indexB) {
while (b != endB) {
dataC[c++] = valA*dataB[b++];
}
} else {
while (b != endB) {
dataC[c++] += valA*dataB[b++];
}
}
colA += widthA;
}
}
}
/**
*
* Performs the follow operation on individual inner blocks:
*
* C = α A * BT
*
*/
public static void blockMultSetTransB( float alpha, final float[] dataA, final float[] dataB, final float[] dataC,
int indexA, int indexB, int indexC,
final int heightA, final int widthA, final int widthC ) {
for (int i = 0; i < heightA; i++) {
for (int j = 0; j < widthC; j++) {
float val = 0;
for (int k = 0; k < widthA; k++) {
val += dataA[i*widthA + k + indexA]*dataB[j*widthA + k + indexB];
}
dataC[i*widthC + j + indexC] = alpha*val;
}
}
}
}