mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-27 02:50:32 +00:00
903d1e4012
* GB: integrated SameBoy v0.12.1 by Lior Halphon * SFC: added HG51B169 (Cx4) math tables into bsnes binary
37 lines
792 B
C++
Executable File
37 lines
792 B
C++
Executable File
#pragma once
|
|
|
|
//matrix multiplication primitives
|
|
//used in: ruby/opengl/quark
|
|
|
|
namespace nall {
|
|
|
|
template<typename T> inline auto MatrixMultiply(
|
|
T* output,
|
|
const T* xdata, uint xrows, uint xcols,
|
|
const T* ydata, uint yrows, uint ycols
|
|
) -> void {
|
|
if(xcols != yrows) return;
|
|
|
|
for(uint y : range(xrows)) {
|
|
for(uint x : range(ycols)) {
|
|
T sum = 0;
|
|
for(uint z : range(xcols)) {
|
|
sum += xdata[y * xcols + z] * ydata[z * ycols + x];
|
|
}
|
|
*output++ = sum;
|
|
}
|
|
}
|
|
}
|
|
|
|
template<typename T> inline auto MatrixMultiply(
|
|
const T* xdata, uint xrows, uint xcols,
|
|
const T* ydata, uint yrows, uint ycols
|
|
) -> vector<T> {
|
|
vector<T> output;
|
|
output.resize(xrows * ycols);
|
|
MatrixMultiply(output.data(), xdata, xrows, xcols, ydata, yrows, ycols);
|
|
return output;
|
|
}
|
|
|
|
}
|