Apache Lucene open-source search software
SOLR-11607: Add grandSum, sumRows, sumColumns, scalarDivide, scalarMultiply, scalarAdd, scalarSubtract Stream Evaluators
Joel Bernstein23fe16d3e90b
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.javaindex 2d092ab1bf2..f8f5deac0c9 100644--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java@@ -275,6 +275,13 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,.withFunctionName("precision", PrecisionEvaluator.class).withFunctionName("minMaxScale", MinMaxScaleEvaluator.class).withFunctionName("markovChain", MarkovChainEvaluator.class)+ .withFunctionName("grandSum", GrandSumEvaluator.class)+ .withFunctionName("scalarAdd", ScalarAddEvaluator.class)+ .withFunctionName("scalarSubtract", ScalarSubtractEvaluator.class)+ .withFunctionName("scalarMultiply", ScalarMultiplyEvaluator.class)+ .withFunctionName("scalarDivide", ScalarDivideEvaluator.class)+ .withFunctionName("sumRows", SumRowsEvaluator.class)+ .withFunctionName("sumColumns", SumColumnsEvaluator.class)// Boolean Stream Evaluatorsdiff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GrandSumEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GrandSumEvaluator.javanew file mode 100644index 00000000000..754ca0be78e--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GrandSumEvaluator.java@@ -0,0 +1,54 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class GrandSumEvaluator extends RecursiveObjectEvaluator implements OneValueWorker {+ protected static final long serialVersionUID = 1L;++ public GrandSumEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(1 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting exactly 1 value but found %d",expression,containedEvaluators.size()));+ }+ }++ @Override+ public Object doWork(Object value) throws IOException{+ if(null == value){+ return null;+ } else if (value instanceof Matrix) {+ Matrix matrix = (Matrix) value;+ double[][] data = matrix.getData();+ double grandSum = 0;+ for(double[] row : data) {+ for(double d : row) {+ grandSum += d;+ }+ }+ return grandSum;+ } else {+ throw new IOException("Grand sum function only operates on a matrix");+ }+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MarkovChainEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MarkovChainEvaluator.javaindex 7a7ada2b8ab..714bdde2311 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MarkovChainEvaluator.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MarkovChainEvaluator.java@@ -50,7 +50,7 @@ public class MarkovChainEvaluator extends RecursiveObjectEvaluator implements MaMatrix matrix = (Matrix) values[0];return new MarkovChain(matrix, state);} else {- throw new IOException("matrix parameter expected for transpose function");+ throw new IOException("matrix parameter expected for markovChain function");}}@@ -63,7 +63,7 @@ public class MarkovChainEvaluator extends RecursiveObjectEvaluator implements Madouble[][] data = matrix.getData();if(data.length != data[0].length) {- throw new IOException("Markov chain must be initialized with a square matrix.");+ throw new IOException("markovChain must be initialized with a square matrix.");}this.distributions = new EnumeratedIntegerDistribution[data.length];diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarAddEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarAddEvaluator.javanew file mode 100644index 00000000000..3ae3436fccd--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarAddEvaluator.java@@ -0,0 +1,74 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.ArrayList;+import java.util.List;+import java.util.Locale;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class ScalarAddEvaluator extends RecursiveObjectEvaluator implements TwoValueWorker {+ protected static final long serialVersionUID = 1L;++ public ScalarAddEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(2 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expects exactly 2 values but found %d",expression,containedEvaluators.size()));+ }+ }++ @Override+ public Object doWork(Object value1, Object value2) throws IOException{++ double d = ((Number)value1).doubleValue();+ if(value2 instanceof List){+ List<Number> nums = (List<Number>)value2;+ List<Number> out = new ArrayList();+ for(Number num : nums) {+ out.add(operate(num.doubleValue(), d));+ }++ return out;++ } else if (value2 instanceof Matrix) {+ Matrix matrix = (Matrix) value2;+ double[][] data = matrix.getData();+ double[][] newData = new double[data.length][];+ for(int i=0; i<data.length; i++) {+ double[] row = data[i];+ double[] newRow = new double[row.length];++ for(int j=0; j<row.length; j++) {+ newRow[j] = operate(row[j], d);+ }++ newData[i] = newRow;+ }+ return new Matrix(newData);+ } else {+ throw new IOException("scalar add, subtract, multiply and divide operate on numeric arrays and matrices only.");+ }+ }++ protected double operate(double value, double d) {+ return value+d;+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarDivideEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarDivideEvaluator.javanew file mode 100644index 00000000000..9a9fe08a3e4--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarDivideEvaluator.java@@ -0,0 +1,39 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class ScalarDivideEvaluator extends ScalarAddEvaluator implements TwoValueWorker {+ protected static final long serialVersionUID = 1L;++ public ScalarDivideEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(2 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expects exactly 2 parameters but found %d",expression,containedEvaluators.size()));+ }+ }++ protected double operate(double value, double d) {+ return value/d;+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarMultiplyEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarMultiplyEvaluator.javanew file mode 100644index 00000000000..02de1e50b9c--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarMultiplyEvaluator.java@@ -0,0 +1,39 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class ScalarMultiplyEvaluator extends ScalarAddEvaluator implements TwoValueWorker {+ protected static final long serialVersionUID = 1L;++ public ScalarMultiplyEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(2 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expects exactly 2 parameters but found %d",expression,containedEvaluators.size()));+ }+ }++ protected double operate(double value, double d) {+ return value*d;+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarSubtractEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarSubtractEvaluator.javanew file mode 100644index 00000000000..4f082ed6e84--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ScalarSubtractEvaluator.java@@ -0,0 +1,39 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class ScalarSubtractEvaluator extends ScalarAddEvaluator implements TwoValueWorker {+ protected static final long serialVersionUID = 1L;++ public ScalarSubtractEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(2 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expects exactly 2 parameters but found %d",expression,containedEvaluators.size()));+ }+ }++ protected double operate(double value, double d) {+ return value-d;+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumColumnsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumColumnsEvaluator.javanew file mode 100644index 00000000000..02be8b295bb--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumColumnsEvaluator.java@@ -0,0 +1,71 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;+import java.util.List;+import java.util.ArrayList;++import org.apache.commons.math3.linear.Array2DRowRealMatrix;+import org.apache.commons.math3.linear.RealMatrix;+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class SumColumnsEvaluator extends RecursiveObjectEvaluator implements OneValueWorker {+ protected static final long serialVersionUID = 1L;++ public SumColumnsEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(1 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting exactly 1 value but found %d",expression,containedEvaluators.size()));+ }+ }++ @Override+ public Object doWork(Object value) throws IOException{+ if(null == value){+ return null;+ } else if (value instanceof Matrix) {++ //First transpose the matrix+ Matrix matrix = (Matrix) value;+ double[][] data = matrix.getData();+ RealMatrix realMatrix = new Array2DRowRealMatrix(data);+ realMatrix = realMatrix.transpose();+ data = realMatrix.getData();++ //Now sum the rows.+ List<Number> sums = new ArrayList(data.length);++ for(int i=0; i<data.length; i++) {+ double sum = 0;+ double[] row = data[i];+ for(int j=0; j<row.length; j++){+ sum+=row[j];+ }++ sums.add(sum);+ }++ return sums;+ } else {+ throw new IOException("Grand sum function only operates on a matrix");+ }+ }+}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumRowsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumRowsEvaluator.javanew file mode 100644index 00000000000..a9eeba269ca--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SumRowsEvaluator.java@@ -0,0 +1,63 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.solr.client.solrj.io.eval;++import java.io.IOException;+import java.util.Locale;+import java.util.List;+import java.util.ArrayList;++import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;++public class SumRowsEvaluator extends RecursiveObjectEvaluator implements OneValueWorker {+ protected static final long serialVersionUID = 1L;++ public SumRowsEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{+ super(expression, factory);++ if(1 != containedEvaluators.size()){+ throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting exactly 1 value but found %d",expression,containedEvaluators.size()));+ }+ }++ @Override+ public Object doWork(Object value) throws IOException{+ if(null == value){+ return null;+ } else if (value instanceof Matrix) {++ Matrix matrix = (Matrix) value;+ double[][] data = matrix.getData();+ List<Number> sums = new ArrayList(data.length);++ for(int i=0; i<data.length; i++) {+ double sum = 0;+ double[] row = data[i];+ for(int j=0; j<row.length; j++){+ sum+=row[j];+ }++ sums.add(sum);+ }++ return sums;+ } else {+ throw new IOException("Grand sum function only operates on a matrix");+ }+ }+}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.javaindex 0ed2b919528..e52e7812496 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java@@ -6066,6 +6066,118 @@ public class StreamExpressionTest extends SolrCloudTestCase {}+ @Test+ public void testMatrixMath() throws Exception {+ String cexpr = "let(echo=true, a=matrix(array(1.5, 2.5, 3.5), array(4.5,5.5,6.5)), " ++ "b=grandSum(a), " ++ "c=sumRows(a), " ++ "d=sumColumns(a), " ++ "e=scalarAdd(1, a)," ++ "f=scalarSubtract(1, a)," ++ "g=scalarMultiply(1.5, a)," ++ "h=scalarDivide(1.5, a)," ++ "i=scalarAdd(1.5, array(1.5, 2.5, 3.5))," ++ "j=scalarSubtract(1.5, array(1.5, 2.5, 3.5))," ++ "k=scalarMultiply(1.5, array(1.5, 2.5, 3.5))," ++ "l=scalarDivide(1.5, array(1.5, 2.5, 3.5)))";++ ModifiableSolrParams paramsLoc = new ModifiableSolrParams();+ paramsLoc.set("expr", cexpr);+ paramsLoc.set("qt", "/stream");+ String url = cluster.getJettySolrRunners().get(0).getBaseUrl().toString()+"/"+COLLECTIONORALIAS;+ TupleStream solrStream = new SolrStream(url, paramsLoc);+ StreamContext context = new StreamContext();+ solrStream.setStreamContext(context);+ List<Tuple> tuples = getTuples(solrStream);+ assertTrue(tuples.size() == 1);++ double grandSum = tuples.get(0).getDouble("b");+ assertEquals(grandSum, 24, 0.0);++ List<Number> sumRows = (List<Number>)tuples.get(0).get("c");+ assertEquals(sumRows.size(), 2);+ assertEquals(sumRows.get(0).doubleValue(), 7.5, 0.0);+ assertEquals(sumRows.get(1).doubleValue(), 16.5, 0.0);++ List<Number> sumCols = (List<Number>)tuples.get(0).get("d");+ assertEquals(sumCols.size(), 3);+ assertEquals(sumCols.get(0).doubleValue(), 6.0, 0.0);+ assertEquals(sumCols.get(1).doubleValue(), 8.0, 0.0);+ assertEquals(sumCols.get(2).doubleValue(), 10, 0.0);++ List<List<Number>> scalarAdd = (List<List<Number>>)tuples.get(0).get("e");+ List<Number> row1 = scalarAdd.get(0);+ assertEquals(row1.size(), 3);+ assertEquals(row1.get(0).doubleValue(), 2.5, 0.0);+ assertEquals(row1.get(1).doubleValue(), 3.5, 0.0);+ assertEquals(row1.get(2).doubleValue(), 4.5, 0.0);++ List<Number> row2 = scalarAdd.get(1);+ assertEquals(row2.get(0).doubleValue(), 5.5, 0.0);+ assertEquals(row2.get(1).doubleValue(), 6.5, 0.0);+ assertEquals(row2.get(2).doubleValue(), 7.5, 0.0);++ List<List<Number>> scalarSubtract = (List<List<Number>>)tuples.get(0).get("f");+ row1 = scalarSubtract.get(0);+ assertEquals(row1.size(), 3);+ assertEquals(row1.get(0).doubleValue(), 0.5, 0.0);+ assertEquals(row1.get(1).doubleValue(), 1.5, 0.0);+ assertEquals(row1.get(2).doubleValue(), 2.5, 0.0);++ row2 = scalarSubtract.get(1);+ assertEquals(row2.get(0).doubleValue(), 3.5, 0.0);+ assertEquals(row2.get(1).doubleValue(), 4.5, 0.0);+ assertEquals(row2.get(2).doubleValue(), 5.5, 0.0);++ List<List<Number>> scalarMultiply = (List<List<Number>>)tuples.get(0).get("g");+ row1 = scalarMultiply.get(0);+ assertEquals(row1.size(), 3);+ assertEquals(row1.get(0).doubleValue(), 2.25, 0.0);+ assertEquals(row1.get(1).doubleValue(), 3.75, 0.0);+ assertEquals(row1.get(2).doubleValue(), 5.25, 0.0);++ row2 = scalarMultiply.get(1);+ assertEquals(row2.get(0).doubleValue(), 6.75, 0.0);+ assertEquals(row2.get(1).doubleValue(), 8.25, 0.0);+ assertEquals(row2.get(2).doubleValue(), 9.75, 0.0);++ List<List<Number>> scalarDivide = (List<List<Number>>)tuples.get(0).get("h");+ row1 = scalarDivide.get(0);+ assertEquals(row1.size(), 3);+ assertEquals(row1.get(0).doubleValue(), 1.0, 0.0);+ assertEquals(row1.get(1).doubleValue(), 1.66666666666667, 0.001);+ assertEquals(row1.get(2).doubleValue(), 2.33333333333333, 0.001);++ row2 = scalarDivide.get(1);+ assertEquals(row2.get(0).doubleValue(), 3, 0.0);+ assertEquals(row2.get(1).doubleValue(), 3.66666666666667, 0.001);+ assertEquals(row2.get(2).doubleValue(), 4.33333333333333, 0.001);++ List<Number> rowA = (List<Number>)tuples.get(0).get("i");+ assertEquals(rowA.size(), 3);+ assertEquals(rowA.get(0).doubleValue(), 3.0, 0.0);+ assertEquals(rowA.get(1).doubleValue(), 4.0, 0.0);+ assertEquals(rowA.get(2).doubleValue(), 5.0, 0.0);++ rowA = (List<Number>)tuples.get(0).get("j");+ assertEquals(rowA.size(), 3);+ assertEquals(rowA.get(0).doubleValue(), 0, 0.0);+ assertEquals(rowA.get(1).doubleValue(), 1.0, 0.0);+ assertEquals(rowA.get(2).doubleValue(), 2.0, 0.0);++ rowA = (List<Number>)tuples.get(0).get("k");+ assertEquals(rowA.size(), 3);+ assertEquals(rowA.get(0).doubleValue(), 2.25, 0.0);+ assertEquals(rowA.get(1).doubleValue(), 3.75, 0.0);+ assertEquals(rowA.get(2).doubleValue(), 5.25, 0.0);++ rowA = (List<Number>)tuples.get(0).get("l");+ assertEquals(rowA.size(), 3);+ assertEquals(rowA.get(0).doubleValue(), 1.0, 0.0);+ assertEquals(rowA.get(1).doubleValue(), 1.66666666666667, 0.001);+ assertEquals(rowA.get(2).doubleValue(), 2.33333333333333, 0.001);+ }+@Testpublic void testTranspose() throws Exception {String cexpr = "let(a=matrix(array(1,2,3), array(4,5,6)), b=transpose(a))";