From f1745ba1057356366c4b4b08b7f219fa05a19b67 Mon Sep 17 00:00:00 2001 From: npgit Date: Thu, 28 Nov 2024 12:26:08 -0500 Subject: [PATCH] Broadcasting rules are properly applied to length 1 numberlists --- src/aya/util/VectorizedFunctions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/aya/util/VectorizedFunctions.java b/src/aya/util/VectorizedFunctions.java index 817b21b3..8f1a65fc 100644 --- a/src/aya/util/VectorizedFunctions.java +++ b/src/aya/util/VectorizedFunctions.java @@ -72,8 +72,18 @@ private static List vectorizeObjList(ExecutionContext context, Operator op, Obj // private static List vectorizeListList(ExecutionContext context, Operator op, List a, List b, NumberListOp nlop) { - if (a.isa(NUMBERLIST) && b.isa(NUMBERLIST) && a.length() == b.length()) { - return new List(nlop.ll(asNumberList(a), asNumberList(b))); + if (a.isa(NUMBERLIST) && b.isa(NUMBERLIST)) { + final int a_len = a.length(); + final int b_len = b.length(); + if (a_len == b_len) { + return new List(nlop.ll(asNumberList(a), asNumberList(b))); + } else if (a_len == 1) { + return new List(nlop.nl(asNumberList(a).get(0), asNumberList(b))); + } else if (b_len == 1) { + return new List(nlop.ln(asNumberList(a), asNumberList(b).get(0))); + } else { + return vectorizeListList(context, op, a, b); + } } else { return vectorizeListList(context, op, a, b); }