|
18 | 18 | import org.matheclipse.core.expression.F; |
19 | 19 | import org.matheclipse.core.expression.S; |
20 | 20 | import org.matheclipse.core.expression.data.ByteArrayExpr; |
| 21 | +import org.matheclipse.core.expression.data.NumericArrayExpr; |
21 | 22 | import org.matheclipse.core.expression.data.SparseArrayExpr; |
22 | 23 | import org.matheclipse.core.form.output.OutputFormFactory; |
23 | 24 | import org.matheclipse.core.interfaces.IAST; |
@@ -105,11 +106,14 @@ public void testSmartFuzz() { |
105 | 106 | ByteArrayExpr b0a = ByteArrayExpr.newInstance(b0Array); |
106 | 107 | F.x.setAttributes(ISymbol.PROTECTED); |
107 | 108 | F.y.setAttributes(ISymbol.PROTECTED); |
108 | | - |
| 109 | + double[] doubleArr = new double[] {1.0, -1.0, 0.0, 2.0, 100.0, 200.0}; |
| 110 | + int[] dims = new int[] {2, 3}; |
| 111 | + NumericArrayExpr nae = new NumericArrayExpr(doubleArr, dims, NumericArrayExpr.Real64); |
109 | 112 | IAST seedList = |
110 | 113 | F.List( // |
111 | 114 | ba, // |
112 | 115 | b0a, // |
| 116 | + nae, // |
113 | 117 | // F.NIL, // |
114 | 118 | F.complex(-0.5, 0.5), // |
115 | 119 | F.complex(0.0, 0.5), // |
@@ -993,4 +997,28 @@ private void generateASTs( |
993 | 997 | } |
994 | 998 | } |
995 | 999 | } |
| 1000 | + |
| 1001 | + public void testTogether() { |
| 1002 | + // Together(1+SparseArray(Number of elements: 0 Dimensions: {2,2} Default value: 0)) |
| 1003 | + IExpr sa = SparseArrayExpr.newDenseList(F.List(F.List(F.C1, F.C0), F.List(F.C0, F.C1)), F.C0); |
| 1004 | + checkEvaluator(F.Together(F.Plus(F.C1, sa)), // |
| 1005 | + "1+SparseArray(Number of elements: 2 Dimensions: {2,2} Default value: 0)" |
| 1006 | + ); |
| 1007 | + } |
| 1008 | + |
| 1009 | + void checkEvaluator(IAST ast, String expected) { |
| 1010 | + EvalEngine engine = EvalEngine.get(); |
| 1011 | + try { |
| 1012 | + IFunctionEvaluator evaluator = |
| 1013 | + (IFunctionEvaluator) ((IBuiltInSymbol) ast.topHead()).getEvaluator(); |
| 1014 | + if (evaluator instanceof IFunctionEvaluator) { |
| 1015 | + IExpr result = evaluator.evaluate(ast, engine); |
| 1016 | + assertEquals(expected, result.toString()); |
| 1017 | + return; |
| 1018 | + } |
| 1019 | + } catch (RuntimeException rex) { |
| 1020 | + rex.printStackTrace(); |
| 1021 | + } |
| 1022 | + fail(); |
| 1023 | + } |
996 | 1024 | } |
0 commit comments