Feature suggestion: Cross Product Math node

Dear Knimers,

Suppose I have a table
image

and I want to multiply every row with
image

to obtain
image

I can think of several ways to do this. Method 1:
image

Method 2:
image

Method 3:

Method 4:

Method 1 has computationally expensive “Transpose” nodes, method 2 has “Unpivoting/Pivoting” nodes that are not much better, method 3 has a Column List loop that slow for large tables, and method 4 is probably the fastest but also the ugliest. None of them are pretty.

To summarize, to my knowledge there is no elegant way to perform this relatively simple operation.

I suggest a “Cross Product Math (Multi Column)” (or, more generally, “Cross Operation Math”) node that takes two tables and where mathematical operations can be carried out on the intersection of the Column names (of the numerical columns). The result is a table that has a length of (length of table 1) x (length of table 2).

Best
Aswin

2 Likes

Hello @Aswin,

The last approach can be pretty if wrapped in a Metanode :smiley:

Added your request to existing ticket whee similar request are noted (AP-12924).

Br,
Ivan

3 Likes

Even I can be pretty if I wrap myself in a metanode :grin:

Great to read that a node like this is under consideration!

3 Likes

I would go with variable und column expressions
save

1 Like

Thank you for your suggestion @Daniel_Weikert … but can this be easily scaled to 200 columns instead of 2?

As the Column Expressions node takes Javascript code, perhaps it is possible to loop over the columns of the input table and the variables corresponding to the column names, but then each expression can only have one output column… this output column would then need be an array/collection, to be expanded later… and some extra magic would be necessary to assign the correct column names to these expanded columns…