Tcl Library Source Code

View Ticket
Login
Ticket UUID: 91c114ee9271a9cff06b4c0facd6defb9b895f7d
Title: ::math::linearalgebra::solveGauss gives overflow for matrices with a row of zeros
Type: Bug Version: math::linearalgebra 1.1.7
Submitter: anonymous Created on: 2024-08-29 20:27:58
Subsystem: math :: linearalgebra Assigned To: arjenmarkus
Priority: 5 Medium Severity: Critical
Status: Open Last Modified: 2024-09-05 06:56:57
Resolution: None Closed By: nobody
    Closed on:
Description:
When a matrix has a row consisting of zero's we get an error:
(bin) 49 % package require math::linearalgebra
1.1.7
(bin) 49 % set b {{2 3 4} {-2 3 4} {1 1 1}}
{2 3 4} {-2 3 4} {1 1 1}
(bin) 50 %    set M {{0 0 0} {-2 3 4} {1 1 1}}
{0 0 0} {-2 3 4} {1 1 1}
(bin) 51 % math::linearalgebra::solveGauss $M $b
domain error: argument not in valid range
(bin) 52 % 
I don't know how this algorithm works, but looking in the code I see division by a factor $sweep_fact where sweep_fact is taken directly from a matrix value, so that would give problems anyhow.
Groeten,
Harm Olthof
User Comments: arjenmarkus added on 2024-09-05 06:56:57:
With a row of zeroes the matrix is singular and therefore there is no (ordinary) unique solution. The code might be made more robust, so that such errors are handled more decently. 

You might instead look for solutions using singular value decomposition, such as leastSquaresSVD.