I've read in the book of Mr.Tiller (chapter 6, page 152) that piece of code related to nested for loops
CODE
Real A[5,3];
Real B[3,7];
Real C[5,7];
algorithm
C = fill(0,5,7);
for i in 1:size(A,1) loop
for j in 1:size(B,2) loop
for k in 1:size(A,2) loop
C[i,j] = C[i, j] + A[i, k]*B[k, j];
end for;
end for;
end for;
Real B[3,7];
Real C[5,7];
algorithm
C = fill(0,5,7);
for i in 1:size(A,1) loop
for j in 1:size(B,2) loop
for k in 1:size(A,2) loop
C[i,j] = C[i, j] + A[i, k]*B[k, j];
end for;
end for;
end for;
but while simulation it gives Singularity Error
QUOTE
The problem is structurally singular for the element type Real.
The number of scalar Real unknown elements are 71.
The number of scalar Real equation elements are 140.
The problem for Real elements is overdetermined.
The number of scalar Real unknown elements are 71.
The number of scalar Real equation elements are 140.
The problem for Real elements is overdetermined.
The problem is that :
The nested for loops generate the whole equations at the begining and then try to solve, and this means that we have always more equations than the variables
Is that true? and if so, how to solve such problem in order to use looping as we know in all programming languages?
