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:
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..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s