[R] a simple question about a matrix

Douglas Bates bates at stat.wisc.edu
Mon Feb 23 00:44:21 CET 2004


"Liaw, Andy" <andy_liaw at merck.com> writes:

> If the matrix is real, then isn't that just
> sqrt(eigen(crossprod(x))$values[1]) ??
> 
> Andy
> 
> > From: li xian
> > 
> > suppose x is a matrix.
> > how to define ||x|| in R?
> >  

The symbol ||x|| could mean many different things when x is a matrix.
I presume that you mean some kind of matrix norm.  Could you be more
specific about which norm you want?  (There are several.)

The one-norm, the Frobenius norm, and the infinity norm are all
available in the new version of the Matrix package, which is currently
available only for the development version of R (to be R-1.9.0).

> mm = Matrix(rnorm(9), nrow = 3)
> mm
           [,1]       [,2]      [,3]
[1,] -1.0210873  0.9941221  2.363475
[2,] -0.5171302 -0.3243187 -1.455873
[3,] -2.3793565  0.5223258 -1.034270
> norm(mm, '1')
[1] 4.853617
> norm(mm, 'O')   # the one norm
[1] 4.853617
> norm(mm, 'I')   # the infinity norm
[1] 4.378684
> norm(mm, 'F')   # the Frobenius norm
[1] 4.136781
> norm(mm, 'M')   # the Maximum modulus (not really a norm)
[1] 2.379356




More information about the R-help mailing list