Magic infinite loop inside foreach
MrSmith
mrsmith33 at yandex.ru
Thu Jan 30 15:08:27 PST 2014
On Thursday, 30 January 2014 at 22:56:46 UTC, MrSmith wrote:
> I have some function which does some matrix calculations and
> prints them. It is actually calculationg determinant of the
> matrix and i need to call those functions several times in the
> loop, until i get the final result. Here is the code.
>
> void solveAndPrint(T : CoeffMatrix!(ElementType, ElementType),
> ElementType)(T _matrix)
> {
> auto matrix = _matrix;
> TempMatrix!ElementType temp;
>
> foreach(_; 0..3) //3 is just for debug
> {
> writeln(matrix);
> temp = makeTemp(matrix);
>
> writeln(temp);
> matrix = solveTemp(temp);
>
> writeln("done1");
> stdout.flush();
> }
> writeln("done2");
> stdout.flush();
> }
>
> The problem is that after 'done1' is printed it is running
> infinitely consuming all the processor just like if has
> infinite loop inside. done2 is never printed.
Somehow if i comment out
//matrix = solveTemp(temp);
it works, but this method works fine, and after it done1 is
printed. Strange.
More information about the Digitalmars-d-learn
mailing list