Re: [R] Question regarding lu in package Matrix

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Wed, 09 Jul 2008 12:51:48 -0500

On Wed, Jul 9, 2008 at 12:01 PM, Ulrike Grmping <groemp_at_tfh-berlin.de> wrote:

> Dear R-helpers,

> I have a question regarding LU-decomposition with function lu in package
> Matrix. The following simple example confuses me: Why is as.matrix(elu$U)
> not an upper triangular matrix?

> u3 <-
> matrix(c(1,1,1,1,1,1,-1,1,0,0,0,0,0,-1,1,0,0,0,-1,0,1,0,0,0,0,0,-1,1,0,0),5,6,byrow=T)
> elu <- expand(lu(Matrix(u3,sparse=F)))
> as.matrix(elu$U)

I get

> elu$U

5 x 6 Matrix of class "dtrMatrix"

     [,1] [,2] [,3] [,4] [,5] [,6]

[1,]  1.0000000  0.0000000  0.0000000  0.0000000  1.0000000  1.0000000
[2,]          .  2.0000000  0.0000000  0.0000000  1.0000000  1.0000000
[3,]          .          .  1.5000000  0.0000000  0.0000000  0.5000000
[4,]          .          .          .  1.3333333  0.0000000  0.3333333
[5,]          .          .          .          .  0.0000000  0.0000000

which is about as upper-triangular as it can be, considering that the original matrix is not square.

The help page for 'lu' does say that it gives the triangular decomposition of a square matrix, although the decomposition is defined for non-square. It's just not as useful as it would be for square matrices.

Are you suggesting that we should check the argument to lu and report an error if it is not square?

> I only have very limited experience with the package and its different types
> of matrices, and I am lost where to start looking for a reason.
>
> Regards,
> Ulrike Grmping
>
>
> --
> View this message in context: http://www.nabble.com/Question-regarding-lu-in-package-Matrix-tp18366291p18366291.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 09 Jul 2008 - 17:57:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Jul 2008 - 20:33:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive