cartprod

Parameters

Parameter label

I/O type

Data type

Mandatory parameter?

Default value

inputVec1

input

vector / scalar

yes

inputVec2

input

vector / scalar

yes

inputVec3

input

vector / scalar

no

N/A

inputVec4

input

vector / scalar

no

N/A

inputVec5

input

vector / scalar

no

N/A

paddingMode

input

string ("front"|"back")

no

“front”

paddingValue

input

scalar

no

0

outputVec

output

vector / scalar

N/A

N/A

Functionality

Module creates the Cartesian product of 2 up to 5 input vectors. Here’s a simple example:

inputVec1 = [0,1,2,3]
inputVec2 = [2,2,4,4]
...
outputVec = ([0,2],[1,2],[2,4],[3,4])

If the input vectors have different lengths, the shorter vectors are filled up with paddingValue in the front, if paddingMode="front" or in the back, if paddingMode="back" before the Cartesian product is generated.

Here’s an example for the padding (taken from the module’s unit test):

m = MelopyFeatureModuleCartProd()
m.setParameterValue("inputVec1", np.array([1,2,3,4,5,6]))
m.setParameterValue("inputVec2", np.array([11,22,33,44,55]))
m.setParameterValue("inputVec3", np.array([111,222,333,444]))

# front padding
m.setParameterValue("paddingMode", "front")
m.process()
self.assertEqual(m.getParameterValue("outputVec"), \
    ([1, 0, 0], [2, 11, 0], [3, 22, 111], [4, 33, 222], [5, 44, 333], [6, 55, 444]))

# back padding
m.setParameterValue("paddingMode", "back")
m.process()
self.assertEqual(m.getParameterValue("outputVec"), \
    ([1, 11, 111], [2, 22, 222], [3, 33, 333], [4, 44, 444], [5, 55, 0], [6, 0, 0]))