On 09.10.2012 09:49, Nozomi Kodama wrote:
FLOAT temp[25];
CONST FLOAT coeff[]={
matrix->u.m[1][0] * matrix->u.m[0][0], matrix->u.m[1][1] * matrix->u.m[0][1],
matrix->u.m[1][1] * matrix->u.m[2][1], matrix->u.m[1][0] * matrix->u.m[2][0],
matrix->u.m[2][0] * matrix->u.m[2][0], matrix->u.m[2][2] * matrix->u.m[2][2],
matrix->u.m[2][1] * matrix->u.m[2][1], matrix->u.m[0][0] * matrix->u.m[2][0],
matrix->u.m[0][1] * matrix->u.m[2][1], matrix->u.m[0][1] * matrix->u.m[0][1],
matrix->u.m[1][0] * matrix->u.m[1][0], matrix->u.m[1][1] * matrix->u.m[1][1],
matrix->u.m[0][0] * matrix->u.m[0][0], matrix->u.m[1][2] * matrix->u.m[1][2], };
out[4] = temp[0] * in[4] + temp[1] * in[5] + temp[2] * in[6] + temp[3] * in[7] + temp[4] * in[8];
Do we really need that much temps? They aren't reused? What are the coeff used for and why are they calculated separately? Are those variables used more than once (coeff[5] and [13] are only used once), maybe it's a mathematical background?
What about something like:
temp = (matrix->u.m[1][1] * matrix->u.m[0][0] + matrix->u.m[0][1] * matrix->u.m[1][0]) * in[4]; temp -= (matrix->u.m[1][0] * matrix->u.m[2][1] + matrix->u.m[1][1] * matrix->u.m[2][0]) * in[5]; temp += ... out[4] = temp; (using out[4] += may also work, but I'm not sure for cases where in = out, if it's working, we don't need the temp at all, it may be needed to reorder the calculation in that case to start with the index needed in the result ... out[5] = y * in[5]; out[5] += x * in[4]; out[5] += z * in[6]; ...).
Cheers Rico