Files
@ r20718:cc912091a170
Branch filter:
Location: cpp/openttd-patchpack/source/src/3rdparty/squirrel/samples/matrix.nut - annotation
r20718:cc912091a170
887 B
text/plain
(svn r25756) -Update from WebTranslator v3.0:
indonesian - 2 changes by UseYourIllusion
indonesian - 2 changes by UseYourIllusion
r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 r11225:37853e3b55c7 | /*
*
* Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
*
*/
local SIZE=30;
function mkmatrix(rows, cols) {
local i, j, count = 1;
local m = []; m.resize(rows);
for (i = 0; i < rows; i+=1) {
m[i] = [];m[i].resize(cols)
for (j = 0; j < cols; j+=1) {
m[i][j] = count+=1;
}
}
return m;
}
function mmult(rows, cols, m1, m2, m3) {
local i, j, k, val;
for (i = 0; i < rows; i+=1) {
for (j = 0; j < cols; j+=1) {
val = 0;
for (k = 0; k < cols; k+=1) {
val += m1[i][k] * m2[k][j];
}
m3[i][j] = val;
}
}
return m3;
}
local n = ARGS.len()!=0?ARGS[0].tointeger():1
local m1 = mkmatrix(SIZE, SIZE);
local m2 = mkmatrix(SIZE, SIZE);
local mm = mkmatrix(SIZE, SIZE);
for (local i = 0; i < n; i+=1) {
mmult(SIZE, SIZE, m1, m2, mm);
}
print(mm[0][0]+" "+mm[2][3]+" "+mm[3][2]+" "+mm[4][4]);
|