swh:1:snp:3a44eb759780145deea094ac2a25c5049546a085
Tip revision: f0c4a61d2b5f089aa6457ceb4425d51c3d2a8ac7 authored by Han Lin Shang on 08 January 2012, 07:19:40 UTC
version 2.9
version 2.9
Tip revision: f0c4a61
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")
}