R/inf.norm.R

Defines functions inf.norm

Documented in inf.norm

inf.norm <- function( x )
{
###
### This function returns the p = Inf norm wich is the maximum absolute row sum
### of the matrix x
###
### argument
### x = a numeric vector or matrix
###
    if ( !is.numeric( x ) ) {
        stop( "argument x is not numeric" )
    }
    if ( is.matrix( x ) ) {
        Xmat <- x
    }
    else {
        if ( is.vector( x ) ) {
            Xmat <- matrix( x, nrow=length(x), ncol=1 )
        }
        else {
            stop( "argument x is neither a matrix nor a vector" )
        }
    }
    norm <- max( apply( abs( Xmat ), 1, sum ) )
    return( norm )
}

Try the matrixcalc package in your browser

Any scripts or data that you put into this service are public.

matrixcalc documentation built on Sept. 15, 2022, 1:05 a.m.