|
|
@@ -132,9 +132,9 @@ class GaussianJordanLinearSolver(Solver):
|
|
|
# Get low-level dependency
|
|
|
resolveBlock = lambda possibleDep, output_port: possibleDep if not isinstance(possibleDep, CBD) else possibleDep.getBlockByName(output_port)
|
|
|
|
|
|
- # Get list of low-level dependencies from two inputs
|
|
|
+ # Get list of low-level dependencies from n inputs
|
|
|
def getBlockDependencies2(block):
|
|
|
- return (resolveBlock(b, output_port) for (b, output_port) in [block.getBlockConnectedToInput("IN1"), block.getBlockConnectedToInput("IN2")])
|
|
|
+ return (resolveBlock(b, output_port) for (b, output_port) in [block.getBlockConnectedToInput(x) for x in block.getInputPortNames()])
|
|
|
|
|
|
for i, block in enumerate(strongComponent):
|
|
|
if block.getBlockType() == "AdderBlock":
|
|
|
@@ -143,11 +143,13 @@ class GaussianJordanLinearSolver(Solver):
|
|
|
M1[i, i] = -1
|
|
|
|
|
|
for compInStrong in [x for x in getBlockDependencies2(block) if x in strongComponent]:
|
|
|
- M1[i, indexdict[compInStrong]] = 1
|
|
|
+ M1[i, indexdict[compInStrong]] += 1
|
|
|
elif block.getBlockType() == "ProductBlock":
|
|
|
# M2 can stay 0
|
|
|
M1[i, i] = -1
|
|
|
- M1[i, indexdict[[x for x in getBlockDependencies2(block) if x in strongComponent][0]]] = reduce(lambda x, y: x * y, [x.getSignal()[curIteration].value for x in getBlockDependencies2(block) if x not in strongComponent])
|
|
|
+ fact = reduce(lambda x, y: x * y, [x.getSignal()[curIteration].value for x in getBlockDependencies2(block) if x not in strongComponent])
|
|
|
+ for compInStrong in [x for x in getBlockDependencies2(block) if x in strongComponent]:
|
|
|
+ M1[i, indexdict[compInStrong]] += fact
|
|
|
elif block.getBlockType() == "NegatorBlock":
|
|
|
# M2 can stay 0
|
|
|
M1[i, i] = -1
|
|
|
@@ -224,6 +226,8 @@ class GaussianJordanLinearSolver(Solver):
|
|
|
for k in range(n):
|
|
|
M1[k, indxr[l]], M1[k, indxc[l]] = M1[k, indxc[l]], M1[k, indxr[l]]
|
|
|
|
|
|
+ return solverInput[1]
|
|
|
+
|
|
|
|
|
|
class Matrix:
|
|
|
"""Custom, efficient matrix class. This class is used for efficiency purposes.
|