bsnes-libretro/nall/matrix.hpp
Tim Allen f9adb4d2c6 Update to v106r58 release.
byuu says:

The main thing I worked on today was emulating the MBC7 EEPROM.

And... I have many things to say about that, but not here, and not now...

The missing EEPROM support is why the accelerometer was broken. Although
it's not evidently clear that I'm emulating the actual values
incorrectly. I'll think about it and get it fixed, though.

bsnes went from ~308fps to ~328fps, and I don't even know why. Probably
something somewhere in the 140KB of changes to other things made in this
WIP.
2018-08-21 13:17:12 +10:00

34 lines
729 B
C++

#pragma once
namespace nall { namespace Matrix {
template<typename T> inline auto Multiply(
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 Multiply(
const T* xdata, uint xrows, uint xcols,
const T* ydata, uint yrows, uint ycols
) -> vector<T> {
vector<T> output;
output.resize(xrows * ycols);
Multiply(output.data(), xdata, xrows, xcols, ydata, yrows, ycols);
return output;
}
}}