Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 43d3d5d

Browse files
hkielOpenModelica-Hudson
authored andcommitted
fix Matching.removeEdgesForNoDerivativeFunctionInputs
Belonging to [master]: - #1904
1 parent 11df6e6 commit 43d3d5d

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

Compiler/BackEnd/Matching.mo

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,7 +5666,7 @@ algorithm
56665666
arrayUpdate(m,idx,row);
56675667
//update mt
56685668
for varIdx in varIdxs loop
5669-
row := arrayGet(m,varIdx);
5669+
row := arrayGet(mt,varIdx);
56705670
row := List.deleteMember(row,idx);
56715671
arrayUpdate(mt,varIdx,row);
56725672
end for;
@@ -5677,30 +5677,18 @@ algorithm
56775677
mtOut := mt;
56785678
end removeEdgesForNoDerivativeFunctionInputs;
56795679

5680-
protected function countincidenceMatrixElementEntries
5681-
input Integer i;
5682-
input Integer inCount;
5683-
output Integer outCount;
5684-
algorithm
5685-
outCount := if intGt(i,0) then inCount+1 else inCount;
5686-
end countincidenceMatrixElementEntries;
5687-
56885680
protected function countincidenceMatrixEntries
5689-
input Integer i;
5681+
input Integer n;
56905682
input BackendDAE.IncidenceMatrix m;
5691-
input Integer inCount;
5692-
output Integer outCount;
5683+
output Integer outCount = 0;
56935684
algorithm
5694-
outCount := match(i,m,inCount)
5695-
local
5696-
Integer l;
5697-
case(0,_,_) then inCount;
5698-
else
5699-
equation
5700-
l = List.fold(m[i], countincidenceMatrixElementEntries, inCount);
5701-
then
5702-
countincidenceMatrixEntries(i-1,m,l);
5703-
end match;
5685+
for i in 1:n loop
5686+
for e in m[i] loop
5687+
if intGt(e,0) then
5688+
outCount := outCount + 1;
5689+
end if;
5690+
end for;
5691+
end for;
57045692
end countincidenceMatrixEntries;
57055693

57065694
public function matchingExternalsetIncidenceMatrix
@@ -5712,7 +5700,7 @@ public function matchingExternalsetIncidenceMatrix
57125700
protected
57135701
Integer nz;
57145702
algorithm
5715-
nz := countincidenceMatrixEntries(ne,m,0);
5703+
nz := countincidenceMatrixEntries(ne,m);
57165704
BackendDAEEXT.setIncidenceMatrix(nv,ne,nz,m);
57175705
end matchingExternalsetIncidenceMatrix;
57185706

0 commit comments

Comments
 (0)