[Rd] (PR#4450)

Douglas Bates bates at stat.wisc.edu
Tue Oct 7 17:00:01 MEST 2003


This is fixed (sort of) in R-1.8.0 which explicitly says that the det
function does not handle complex matrices.

> m = matrix(complex(re=rnorm(9),im=rnorm(9)),3,3)
> det(m)
Error in determinant.matrix(x, logarithm = TRUE, ...) : 
	determinant not currently defined for complex matrices

R.P.P.P.Grasman at uva.nl writes:

> This is a multi-part message in MIME format.
> 
> ------_=_NextPart_001_01C38CE4.8296F0E8
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> Hello,
> 
> When I use det() and qr() on complex matrices the result is in some =
> cases indeterministic. The documentation speaks of numeric matrices (and =
> not of complex matrices) but det() uses qr() which should handle complex =
> matrices correctly. I've also tried using only qr() with=20
> 
> similar results. det() returns a value that is not the determinant of =
> the complex matrix (in accordance with documentations limitation to =
> numeric matrices), whereas the product of the eigenvalues obtained with =
> eigen() does evaluate to the determinant of the matrix.
> 
> To repeat the error in a simple as possible example I did the following:
> 
> I freshly started R without loading any previously stored image.
> 
> > m =3D matrix(complex(re=3Drnorm(9),im=3Drnorm(9)),3,3)     # multiple =
> m's were tried
> > m
>                        [,1]                   [,2]                  [,3]
> [1,] -0.56135706+0.9346292i  0.3626032+0.73012622i -0.6629864+0.9328771i
> [2,] -0.05999599-0.6931185i -1.4558785+0.66410894i  0.8503606-1.0104882i
> [3,] -1.29420594-1.0878549i  0.7834801+0.01872038i -0.6378357-0.6318547i
> 
> > y =3D sapply(1:10000,function(i) det(m)); plot.ts(y)   # may need =
> repetition
> > var(y)
> [1] 3.940272
> 
> The plot shows that the sign of det alternates indeterministically (at =
> least for some m generated this way, like the m attached in the m.RData =
> file).
> 
> I note that a similar problem was reported in =
> http://www.r-project.org/nocvs/mail/r-devel/2002/0139.html but I =
> couldn't find a report of this particular problem.
> 
> I would suggest to make det compatible with complex matrices, or at =
> least give a warning.
> 
> Regards,
> 
> Raoul
> 
> --please do not edit the information below--
> 
> Version:
>  platform =3D i386-pc-mingw32
>  arch =3D i386
>  os =3D mingw32
>  system =3D i386, mingw32
>  status =3D=20
>  major =3D 1
>  minor =3D 6.2
>  year =3D 2003
>  month =3D 01
>  day =3D 10
>  language =3D R
> 
> Windows 2000 Professional (build 2195) Service Pack 4.0
> 
> Search Path:
>  .GlobalEnv, package:ctest, Autoloads, package:base
> 
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D=3D
> Raoul Grasman=20
> Dept. Psychology, University of Amsterdam,=20
> Roetersstraat 15,=20
> NL-1018WB Amsterdam,=20
> the Netherlands=20
> 
> ------_=_NextPart_001_01C38CE4.8296F0E8
> Content-Type: application/octet-stream;
> 	name="m.RData"
> Content-Transfer-Encoding: base64
> Content-Description: m.RData
> Content-Disposition: attachment;
> 	filename="m.RData"
> 
> UkRYMgpYCgAAAAIAAQYCAAEEAAAABAIAAAABAAAUCQAAAAFtAAAGDwAAAAm/4fajFV1ooD/t6HuU
> QlCJv663y3lnKNW/5i4GxKJJfb/0tRFJVJHWv/Fn2oR6dZo/1zTj5yLpqz/nXTGnpxkHv/dLRzco
> N1o/5UBhZata/j/pEkTh+iUSP5Mrb6S0Og6/5TcvVgz0Qj/t2iEFmcxnP+s2J4Vrlz2/8Cr1pNXk
> t7/kaSZQc/rMv+Q4J2iz9qUAAAQCAAAAAQAAFAkAAAADZGltAAAEDQAAAAIAAAADAAAAAwAAAP4A
> AAD+
> 
> ------_=_NextPart_001_01C38CE4.8296F0E8--
> 
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

-- 
Douglas Bates                            bates at stat.wisc.edu
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/



More information about the R-devel mailing list