From rphilip.chalmers at gmail.com  Thu May  2 01:35:16 2013
From: rphilip.chalmers at gmail.com (philchalmers)
Date: Wed, 1 May 2013 16:35:16 -0700 (PDT)
Subject: [Rd] diag() when input is a numeric scalar
Message-ID: <1367451316781-4665986.post@n4.nabble.com>

Hi All,

I'm wondering why when passing a single numeric value that contains any
decimals to diag() that the value is silently coerced to a integer for
constructing an identify matrix. To me, an input like diag(5.435) seems
fairly ambiguous and is more than likely a programming mistake, since it's
not obvious that a 5x5 identity matrix should be created. I've seen some
code where other writers have been burned on this as well, especially when
trying extract diagonal elements but forget about the scalar case. A warning
or message would help track this problem down really quickly to force the
author to use diag(floor(5.435)) explicitly, if indeed that is there
intention. Thoughts?

Phil



--
View this message in context: http://r.789695.n4.nabble.com/diag-when-input-is-a-numeric-scalar-tp4665986.html
Sent from the R devel mailing list archive at Nabble.com.



[Rd] diag() when input is a numeric scalar
philchalmers