1

I can't quite figure out how to initialize a, say 101 x 101 f32 array with the value, say, sin ((xindex-50)*(xindex-50) + (yindex-50*yindex-50)).

I could do

array x(seq(-50,50), 101);   // get one of the indices
array pic(101, 101);         // result

but here I halt, as I can't see how to do a cross product of indices.

pic(seq(-50,50), seq(-50,50)) = ....  // what do I put on the RHS that will work?

I'm sure when I wake up tomorrow it'll all be obvious, but I can't quite see it now. (It's so easy in Halide...)

Walt Donovan
  • 357
  • 1
  • 10
  • Hmm, brain tells me to use gfor upon waking up. After I run some errands, I'll read the documentation on that and see if that works. It's possible there's no way to express the above in array "notation" i.e. using array functions and class members on the RHS. – Walt Donovan Nov 24 '15 at 17:25

1 Answers1

1

The above problem can be solved by using iota(). For a 50 x 50 array for example,

array rows = iota(dim4(50), dim4(1, 50));  // y values
array cols = iota(dim4(1,50), dim4(50));   // x values
array pic = sin (rows*rows + cols*cols);   // function of x and y per element
Walt Donovan
  • 357
  • 1
  • 10