Format example scripts better.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
// This script simulates multi-dimensional matrix calculations.
|
||||
|
||||
const SIZE = 50;
|
||||
|
||||
fn new_mat(x, y) {
|
||||
let row = [];
|
||||
row.pad(y, 0.0);
|
||||
|
||||
|
||||
let matrix = [];
|
||||
matrix.pad(x, row);
|
||||
|
||||
|
||||
matrix
|
||||
}
|
||||
|
||||
@@ -20,13 +22,13 @@ fn mat_gen() {
|
||||
m[i][j] = tmp * (i - j) * (i + j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m
|
||||
}
|
||||
|
||||
fn mat_mul(a, b) {
|
||||
let b2 = new_mat(a[0].len, b[0].len);
|
||||
|
||||
|
||||
for i in 0..a[0].len {
|
||||
for j in 0..b[0].len {
|
||||
b2[j][i] = b[i][j];
|
||||
@@ -38,7 +40,7 @@ fn mat_mul(a, b) {
|
||||
for i in 0..c.len {
|
||||
for j in 0..c[i].len {
|
||||
c[i][j] = 0.0;
|
||||
|
||||
|
||||
for z in 0..a[i].len {
|
||||
c[i][j] += a[i][z] * b2[j][z];
|
||||
}
|
||||
|
Reference in New Issue
Block a user