Skip to content
Back to formatted view

Raw Message

Message-ID: <6rfzd2vfvu.fsf@bates4.stat.wisc.edu>
Date: 2004-02-22T23:44:21Z
From: Douglas Bates
Subject: a simple question about a matrix
In-Reply-To: <3A822319EB35174CA3714066D590DCD504AF7824@usrymx25.merck.com>

"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