bsnes/higan/nall/matrix.hpp
Tim Allen 75dab443b4 Update to v092r08 release.
byuu says:

Changelog:
- fixed cartridge load window focus on Windows
- lots of updates to nall, ruby and phoenix
- ethos and Emulator::Interface updated from "foo &bar" to "foo& bar"
  syntax (work-in-progress)

Before I had mixed the two ways to declare variables/arguments all over
the place, so the goal is to unify them all for consistency. So the
changelog for this release will be massive (750KB >.>) due to the syntax
change. Yeah, that's what I spent the last three days working on ...
2013-05-02 21:25:45 +10:00

34 lines
814 B
C++

#ifndef NALL_MATRIX_HPP
#define NALL_MATRIX_HPP
namespace nall {
namespace Matrix {
template<typename T> inline void Multiply(T* output, const T* xdata, unsigned xrows, unsigned xcols, const T* ydata, unsigned yrows, unsigned ycols) {
if(xcols != yrows) return;
for(unsigned y = 0; y < xrows; y++) {
for(unsigned x = 0; x < ycols; x++) {
T sum = 0;
for(unsigned z = 0; z < xcols; z++) {
sum += xdata[y * xcols + z] * ydata[z * ycols + x];
}
*output++ = sum;
}
}
}
template<typename T> inline vector<T> Multiply(const T* xdata, unsigned xrows, unsigned xcols, const T* ydata, unsigned yrows, unsigned ycols) {
vector<T> output;
output.resize(xrows * ycols);
Multiply(output.data(), xdata, xrows, xcols, ydata, yrows, ycols);
return output;
}
}
}
#endif