'Return the Norm of a Matrix or Vector.
In the simplest case this is the geometric size of the vector
Other norms can be specified by the ord parameter
ord    norm for matrices             norm for vectors
None   Frobenius norm                2-norm
\'fro\'  Frobenius norm                - does not exist
inf    --                            max(abs(x))
-inf   --                            min(abs(x))
1      --                            as below
-1     --                            as below
2      2-norm (largest sing. value)  as below
-2     smallest singular value       as below
other  - does not exist              sum(abs(x)**ord)**(1./ord)
Examples
>>> from sympy import Matrix, Symbol, trigsimp, cos, sin, oo
>>> x = Symbol(\'x\', real=True)
>>> v = Matrix([cos(x), sin(x)])
>>> trigsimp( v.norm() )
1
>>> v.norm(10)
(sin(x)**10 + cos(x)**10)**(1/10)
>>> A = Matrix([[1, 1], [1, 1]])
>>> A.norm(2)# Spectral norm (max of |Ax|/|x| under 2-vector-norm)
2
>>> A.norm(-2) # Inverse spectral norm (smallest singular value)
0
>>> A.norm() # Frobenius Norm
2
>>> Matrix([1, -2]).norm(oo)
2
>>> Matrix([-1, 2]).norm(-oo)
1
See Also
normalized'

def norm(self, ord=None):

    vals = (list(self.values()) or [0])
    if ((self.rows == 1) or (self.cols == 1)):
        if ((ord == 2) or (ord is None)):
            return sqrt(Add(*((abs(i) ** 2) for i in vals)))
        elif (ord == 1):
            return Add(*(abs(i) for i in vals))
        elif (ord == S.Infinity):
            return Max(*[abs(i) for i in vals])
        elif (ord == S.NegativeInfinity):
            return Min(*[abs(i) for i in vals])
        try:
            return Pow(Add(*((abs(i) ** ord) for i in vals)), (S(1) / ord))
        except (NotImplementedError, TypeError):
            raise ValueError('Expected    order    to    be    Number,    Symbol,    oo')
    elif (ord == 2):
        return Max(*self.singular_values())
    elif (ord == (-2)):
        return Min(*self.singular_values())
    elif ((ord is None) or (isinstance(ord, string_types) and (ord.lower() in ['f', 'fro', 'frobenius', 'vector']))):
        return self.vec().norm(ord=2)
    else:
        raise NotImplementedError('Matrix    Norms    under    development')
