Skip to content

Commit 921dbbe

Browse files
feat: Upgrade for use with 3d api
1 parent af9f1a6 commit 921dbbe

File tree

4 files changed

+601
-376
lines changed

4 files changed

+601
-376
lines changed

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,31 @@ import * as MatrixLog from 'matrix-log';
1616

1717

1818
// create a matrix log that will have dependencies called
19-
const matrixLog = new MatrixLog(parentMatrixName, width, height);
19+
const matrixLog = new MatrixLog(parentMatrixName, width, height, depth); //depth is optional
2020

21+
matrixLog.at({
22+
x: parentX,
23+
y: parentY,
24+
z: parentZ // optional
25+
});
2126

2227
// in your algorithm, perhaps many times
23-
matrixLog.add(childMatrixName, parentX, parentY, childX, childY, childWidth, childHeight);
28+
matrixLog.add({
29+
name: childMatrixName,
30+
x: childX,
31+
y: childY,
32+
z: childZ, // optional
33+
width: childWidth,
34+
height: childHeight,
35+
depth: childDepth // optional
36+
});
2437

2538

2639
// after your algorithm
2740
const childMatrixLog = matrixLog.toString(childMatrixName);
2841
```
2942

30-
31-
## What does a log (output of `.toString(string)`) look like?
43+
## What does a 2d log (output of `.toString(string)`) look like?
3244

3345
```
3446
test-matrix x=0,y=0 child-matrix
@@ -87,7 +99,7 @@ for (let y = 0; y < 4; y++) {
8799
console.log(filters); // -> [ [ 14, 22 ], [ 46, 54 ] ]
88100
```
89101

90-
This code doesn't directly work on the GPU, because we can only _either_ read or write to arrays. Currently `filters` violates this. However, we could use MatrixLog to _help us_ (note, there is a little thinking that needs to take place) solve this issue by finding the algorithm that `filters` needs.
102+
This code doesn't directly work on the GPU, because we can only _either_ read or write to arrays there. Currently `filters` violates this. However, we could use MatrixLog to _help us_ (note, there is a little thinking that needs to take place) solve this issue by finding the algorithm that `filters` needs.
91103

92104
2. Convert the code as follows and see the output below:
93105
```js
@@ -110,7 +122,8 @@ for (let y = 0; y < 4; y++) {
110122
for (let x = 0; x < 4; x++) {
111123
let filterX = x < filter.length ? 0 : 1;
112124
filters[filterY][filterX] += weights[y][x];
113-
matrixLog.add('weights', filterX, filterY, x, y, weights[0].length, weights.length);
125+
matrixLog
126+
.add('weights', filterX, filterY, x, y, weights[0].length, weights.length);
114127
}
115128
}
116129

0 commit comments

Comments
 (0)