Skip to content

Commit 358f510

Browse files
committed
[NF] Fix ExpandExp.makeScalarProduct.
- Fixed broken logic for returning 0 when multiplying empty arrays.
1 parent 3ee0043 commit 358f510

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

.CI/compliance-newinst.failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ ModelicaCompliance.Algorithms.For.ShadowedIterator
1010
ModelicaCompliance.Algorithms.For.StringRange
1111
ModelicaCompliance.Arrays.Functions.Conversion.DimConversionMatrix
1212
ModelicaCompliance.Arrays.Functions.Reductions.Deduce
13-
ModelicaCompliance.Arrays.Operations.MatrixProduct.ArrayVectorVectorMul3
1413
ModelicaCompliance.Classes.Declarations.Long.QuotedIdentifiers.?abfnrtv
1514
ModelicaCompliance.Classes.Declarations.PartialSimulationModel
1615
ModelicaCompliance.Classes.Declarations.Short.PartialClass

OMCompiler/Compiler/NFFrontEnd/NFExpandExp.mo

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -719,22 +719,23 @@ public
719719
output Expression exp;
720720
protected
721721
list<Expression> expl1, expl2;
722-
Type ty, tyUnlift;
722+
Type ty, elem_ty;
723723
Operator mul_op, add_op;
724724
algorithm
725725
Expression.ARRAY(ty, expl1) := exp1;
726726
Expression.ARRAY( _, expl2) := exp2;
727-
tyUnlift := Type.unliftArray(ty);
727+
elem_ty := Type.unliftArray(ty);
728728

729729
if listEmpty(expl1) then
730730
// Scalar product of two empty arrays. The result is defined in the spec
731731
// by sum, so we return 0 since that's the default value of sum.
732-
exp := Expression.makeZero(tyUnlift);
732+
exp := Expression.makeZero(elem_ty);
733+
else
734+
mul_op := Operator.makeMul(elem_ty);
735+
add_op := Operator.makeAdd(elem_ty);
736+
expl1 := list(SimplifyExp.simplifyBinaryOp(e1, mul_op, e2) threaded for e1 in expl1, e2 in expl2);
737+
exp := List.reduce(expl1, function SimplifyExp.simplifyBinaryOp(op = add_op));
733738
end if;
734-
mul_op := Operator.makeMul(tyUnlift);
735-
add_op := Operator.makeAdd(tyUnlift);
736-
expl1 := list(SimplifyExp.simplifyBinaryOp(e1, mul_op, e2) threaded for e1 in expl1, e2 in expl2);
737-
exp := List.reduce(expl1, function SimplifyExp.simplifyBinaryOp(op = add_op));
738739
end makeScalarProduct;
739740

740741
function expandBinaryMatrixProduct

0 commit comments

Comments
 (0)