Quantcast
Viewing all articles
Browse latest Browse all 20

ICE element-wise addition of two arrays of different sizes

For example, given the arrays [1,2] and [1,2,3,4], produce this array: [2,3,4,5,3,4,5,6].

In Python, this would look like this:

a = [1,2]
b = [1,2,3,4]
c = []
for x in a:
	for y in b:
		c.append( x + y )
		
print c
#  [2, 3, 4, 5, 3, 4, 5, 6]

In ICE, one way to do this would be to add
[1,1,1,1,2,2,2,2]
to
[1,2,3,4,1,2,3,4]

Here’s an ICE tree that does just that:
Image may be NSFW.
Clik here to view.
add_arrays_diff_sizes

This ICE tree uses the modulo trick, and the scalar-to-integer truncation trick.

You can see a variation of this in this Softimage mailing list post..


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 20

Trending Articles