return multiple arrays

Hi, I just had a quick question about a node I'm making. I'm making an LU Factorization node, and it's working fine and everything except for what I'm returning. So far, what I've been doing (and I've run into this problem before with QR Factorization as well) is just returning a single array that contains both the L and the U arrays, one on top of the other. However, I need to make use of both arrays, so is there any way for me to return an L array and a U array separately? Thanks any help you can give on this, I appreciate it.

-James

dizmangj wrote:
However, I need to make use of both arrays, so is there any way for me to return an L array and a U array separately?

Hi James,

in the constructor of your NodeModel you probably call super(1, 1);
The first integer is the number of inports, and the second integer is the number of outports of your NodeModel. Simply define two outports -> super(1, 2); and provide L in one outport and U in the other.

How to do this? The execute method returns an array of BufferedDataTables. The position in the returned array corresponds to the outport it is provided at. That's it. Hope it helps.

Regards,

Fabian

ohh so that's how it's done, I kept trying to just send it to different indices in the BufferedDataTable array I was returning. Thanks for the help!

Hey, I'm sorry, but I had one more question about this. For one of my nodes, I'm taking in a matrix and splitting it up into two different matrices as the output. I changed the call to super to be super(1,2) and I changed the .xml file to account for two outputs. However, when I run the node, I'm getting the following error: Output spec-array length invalid: 1 <> 2

If I right-click the node after I execute it, and select the Data Outports, I can see that it splits up the matrices like I want it to, but when I try to use those matrices, I get errors in the nodes that use them as input. I'm guessing it's because of this error. Thank you so much for your help, I really appreciate it.

dizmangj wrote:
For one of my nodes, I'm taking in a matrix and splitting it up into two different matrices as the output. I changed the call to super to be super(1,2) and I changed the .xml file to account for two outputs. However, when I run the node, I'm getting the following error: Output spec-array length invalid: 1 <> 2

Hey James,

you have done it all correctly, but missed only one little step. KNIME pushes the data through the pipelines is a two-step process. First the DataTableSpec, i.e. the structure and meta information about the tables is propagated. This is after configuration and before the execution. After the execution the actual data is propagated.

What you have to do is to adapt the data table specs for your output, hence
"Output spec-array length invalid: 1 <> 2". This is done in the configure method, where at the end an array of DataTableSpecs is returned. Add here the DataTableSpec for your second output and it will work well.

Hope that helps. See also:
http://www.knime.org/extension.html#configure

Regards,

Fabian