1+ import Utilities as utils;
12
23export proc square(x: int ): int {
34 writeln (x, " * " , x, " = " , x * x);
@@ -14,9 +15,32 @@ export proc sumArray(a: [] int): int {
1415export proc printArray(a: [] int ): void {
1516 writeln (a);
1617}
17- export proc getNewFrame(frame: [] real (32 ),height: int , width: int ,channels: int ): [] real (32 ) {
18- const ret = frame;
19- return ret;
18+ export proc getNewFrame(ref frame: [] real (32 ),height: int , width: int ,channels: int ): [] real (32 ) {
19+ // const dom = {0..<height,0..<width,0..<channels};
20+ // const rgb: [dom] real(32) = reshape(frame,dom);
21+ // const ret = reshape(rgb,{0..<dom.size});
22+ // return ret;
23+ // return [x in frame] x * 1.2;
24+
25+ // const dom = {0..<height,0..<width,0..<channels};
26+ // const rgb: [dom] real(32) = reshape(frame,dom);
27+
28+ // const m = max reduce frame;
29+ // return [x in frame] m;
30+
31+ const shape = (height,width,channels);
32+ forall (i,color) in zip (0 ..< frame.size,frame) {
33+ const idx = utils.indexAt(i,(...shape));
34+ const (h,w,c) = idx;
35+ // const color = frame[i];
36+ // if h < width {
37+ // frame[utils.linearIdx(shape,(h,w,c))] = frame[utils.linearIdx(shape,(h,w,c-1))];
38+ // }
39+ if h < width {
40+ frame[ utils.linearIdx(shape,(h,w,0 ))] = 1.0 ;
41+ }
42+ }
43+ return frame;
2044}
2145
2246
0 commit comments