Error handling in solve.default (PR#8494)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Error handling in solve.default (PR#8494)

Elizabeth Purdom
Hi, this is a minor problem in solve.default but I didn't see anyone
mention it. The function does not give "correct" error-handling if given
non-square matrix, LINPACK=F, and matrix has names attributes (either
row or column names).

Demo:
##"correct" error handling of non-square matrix
 > temp<-diag(1,5)[,1:4]
 > solve(temp,LINPACK=F)
Error in solve.default(diag(1, 5)[, 1:4], LINPACK = F) :
        'A' (5 x 4) must be square

#indeciferable error handling when same matrix is given names attributes
 > temp<-diag(1,5)[,1:4]
 > rownames(temp)<-as.character(1:5)
 > colnames(temp)<-as.character(1:4)
 > solve(temp,LINPACK=F)
Error in "rownames<-"(`*tmp*`, value = c("1", "2", "3", "4")) :
        length of 'dimnames' [1] not equal to array extent

I think the problem is that if LINPACK=F, then the error handling of the
argument "a" is not done until after creating a matrix "b", when none
was given. Then, the function creates a square identity matrix for "b",
to which it tries to assign row and column names of "a". Of course,
since "a" is not square, they are not of the correct length.

Best,
Elizabeth

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel