Displaying 20 results from an estimated 10000 matches similar to: "diag(-1) produces weird result"
2018 Sep 18
0
diag(-1) produces weird result
Yes, both are rooted in age-old design infelicities (in which, basically, interactive expedience has taken precedence over consistency and generality).
Unfortunately, they are quite difficult to rectify, because there are bound to be countless uses of, say, diag(5) as a 5x5 identity matrix which would break if it suddenly meant the 1x1 matrix(5) instead.
We'd need a very carefully
2018 Sep 17
3
diag(-1) produces weird result
Dear list
A strange bug in the psych package is due to the behavior of the diag function:
It gives the expected values for 1, a vector (-1,1), but not for -1
Is this a known feature?
> diag(1)
[,1]
[1,] 1
> diag(c(-1,1))
[,1] [,2]
[1,] -1 0
[2,] 0 1
> diag(-1)
Error in diag(-1) : invalid 'nrow' value (< 0)
Bill
William Revelle
2018 Sep 17
0
diag(-1) produces weird result
I would say it is a mis-feature. If the 'x' argument of diag() is a
vector of length 1, then it creates an identity matrix of that size,
instead of creating a 1x1 matrix with the given value:
? diag(3)
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 0 1 0
[3,] 0 0 1
Of course this makes it cumbersome to use diag() in a package, when
you are not sure if the input vector is
2018 Jul 26
2
Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo
On Thu, Jul 26, 2018 at 12:22 AM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:
> I am trying to control a background R session, connected via a fifo /
> named pipe.
Is the fifo significant here? If I read the same R code from a file
via `<` I get the input echoed (R 3.4.4, Ubuntu).
Barry
2018 Jul 26
2
Possible bug: R --slave --interactive stdin echo on Linux when stdin is a fifo
On Thu, 26 Jul 2018, G?bor Cs?rdi wrote:
> On Thu, Jul 26, 2018 at 12:25 PM Barry Rowlingson
> <b.rowlingson at lancaster.ac.uk> wrote:
>>
>> On Thu, Jul 26, 2018 at 12:22 AM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:
>>> I am trying to control a background R session, connected via a fifo /
>>> named pipe.
>>
>> Is the fifo
2013 May 01
1
diag() when input is a numeric scalar
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
2010 Jan 07
1
"diag", "diag<-" and "[" , "[<-"
Dear all
I have the following problem.
M <- matrix(0,3,3) # dimension of M is dinamic and this can lead to the
next subscript
diag(M[1,1]) <- rep(100,1)
#Error in `diag<-`(`*tmp*`, value = 100) :
# only matrix diagonals can be replaced
diag(M[1,1,drop=F]) <- rep(100,1)
#Error in diag(M[1, 1, drop = F]) <- rep(100, 1) :
# incorrect number of subscripts
diag(M[2:3,1:2]) <-
2003 Sep 17
2
possible bug in diag()
It concerns trival diagonal matrices:
> diag(1)
[,1]
[1,] 1
> diag(rnorm(1))
<0 x 0 matrix>
> diag(rnorm(1),nrow=1)
[,1]
[1,] 0.4843697
There's an obvious work around... but I thought it was worth notifying the
list.
Regards,
John Marsland
**********************************************************************
This is a commercial communication from
1998 Sep 09
2
diag() losing dimnames
Using diag() to extract the diagonal of a matrix loses all but the first dimname
(R 0.62.3). The problem seems to be in [ ]:
>
> x <- matrix(1:9,3,3)
> dimnames(x) <- list(c("a", "b", "c"), c("a", "b", "c"))
> x
a b c
a 1 4 7
b 2 5 8
c 3 6 9
> diag(x)
a NA NA
1 5 9
> x[c(1,5,9)]
a NA NA
1 5 9
>
Paul
2012 May 26
2
[PATCH] Update diag/mbr instruction to match the current filename.
From: Jean-Christian de Rivaz <jc at eclis.ch>
I suspect that some instructions about how to use the diag/mbr was not
updated when the source file was renamed to handoff.S. Here is a simple
proposition to fix that.
Jean-Christian de Rivaz
---
diag/mbr/README | 4 ++--
diag/mbr/handoff.S | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/diag/mbr/README
2015 May 13
1
Why is the diag function so slow (for extraction)?
> From: Martin Maechler <maechler at lynne.stat.math.ethz.ch>
> diag() should not work only for pure matrices, but for all
> "matrix-like" objects for which ``the usual methods'' work, such
> as
> as.vector(.), c(.)
>
> That's why there has been the c(.) in there.
>
> You can always make code faster if you write the code so it only
>
2014 Aug 07
1
RFC: diag(x, n) not preserving integer and logical x
This is not at all something new(*). As maintainer of the
Matrix package, I don't like this inconsistency of base R's diag().
We have had the following -- forever, almost surely inherited
from S and S+ :
diag(x) preserves the storage mode of x for 'complex' and
'double' precision, but converts integer and logicals to double :
> storage.mode(x <- 1i + 1:7);
2006 Nov 05
1
diag()<- in Matrix?
Dear all,
I am trying to use the Matrix package to do some calculations on rather
large and sparse matrices. An example of such a matrix is given below.
mig<-0.2
side<-10
np<-side^2
mig.mat<-matrix(0,np,np)
diag(mig.mat[1:(np-side),(side+1):np])<-mig/4
diag(mig.mat[(side+1):np,1:(np-side)])<-mig/4
diag(mig.mat[-np,-1])<-mig/4
2018 Dec 18
1
[PATCH] virtio-ccw: diag 500 may return a negative cookie
If something goes wrong in the kvm io bus handling, the virtio-ccw
diagnose may return a negative error value in the cookie gpr.
Document this.
Signed-off-by: Cornelia Huck <cohuck at redhat.com>
---
Even if the virtio spec is the correct place to specify what diag 500
subcode 3 does, we also should mention here that the cookie may be
an error.
---
2011 Apr 30
2
[PATCH][git-pull] diag/geodsp
git://git.zytor.com/users/genec/syslinux.git
Branch diag-geodsp-for-hpa
http://git.zytor.com/?p=users/genec/syslinux.git;a=shortlog;h=refs/heads/diag-geodsp-for-hpa
Updates to diag/geodsp/Makefile and an additional variable (XZ) in
mk/syslinux.mk. This removes unnecessary parts and makes the recipes
more generic by using make variables.
--
-Gene
2013 Apr 09
2
Behaviors of diag() with character vector in R 3.0.0
Dear all,
According to CHANGES IN R 3.0.0:
o diag() as used to generate a diagonal matrix has been re-written
in C for speed and less memory usage. It now forces the result
to be numeric in the case diag(x) since it is said to have 'zero
off-diagonal entries'.
diag(x) does not work for character vector in R 3.0.0 any more. For example,
v <- c("a",
2015 May 12
2
Why is the diag function so slow (for extraction)?
>>>>> Steve Bronder <sbronder at stevebronder.com>
>>>>> on Thu, 7 May 2015 11:49:49 -0400 writes:
> Is it possible to replace c() with .subset()?
It would be possible, but I think "entirely" wrong.
.subset() is documented to be an internal function not to be
used "lightly" and more to the point it is documented to *NOT*
2000 May 25
1
diag() (PR#555)
Full_Name: David Duffy
Version: 1.0.1
OS: Linux
Submission from: (NULL) (152.98.96.21)
Documentation for diag() states that "If x is a vector (or a
1-d array) then diag(x) returns a diagonal matrix whose diagonal
is x."
> m<-matrix(1:4,ncol=1)
> diag(m)
[1] 1
diag(as.vector(m)) gives the advertised performance.
Fix: Change documentation.
2005 Oct 19
3
diag() problem
Hi
I have a matrix "u", for which diag() gives an error:
u <- structure(c(5.42334674128216, -2.31319389204264, -5.83059042218476,
-1.64112369640695, -2.31319389212801, 3.22737617646609,
1.85200668021569,
-0.57102273078531, -5.83059042231881, 1.85200668008156,
11.9488923894962,
-3.5525537165941, -1.64112369587405, -0.571022730886046,
-3.55255371755604,
2015 May 13
1
Why is the diag function so slow (for extraction)?
As kindly pointed out to me (oh my decaying gray matter), is.object()
is better suited for this test;
$ svn diff src/library/base/R/diag.R
Index: src/library/base/R/diag.R
===================================================================
--- src/library/base/R/diag.R (revision 68345)
+++ src/library/base/R/diag.R (working copy)
@@ -23,9 +23,11 @@
stop("'nrow' or