swh:1:snp:3a44eb759780145deea094ac2a25c5049546a085
Tip revision: 415368d78ea30230e9017d72e83432baec81b1c9 authored by Han Lin Shang on 11 May 2010, 00:00:00 UTC
version 1.7
version 1.7
Tip revision: 415368d
norm.r
norm = function (A, p = 2)
{
A <- as.matrix(A)
if (min(dim(A)) == 1)
A <- t(A)
if (p == 1)
return(as.matrix(max(colSums(abs(A)))))
else if (p == 2) {
A.sv <- La.svd(A)$d
return(as.matrix(max(A.sv)))
}
else if (p > 1e+09)
return(as.matrix(max(rowSums(abs(A)))))
else stop("Unknown norm")
}