> def sqnorm(x):
>     x = x.ravel()
>     return np.dot(x, x)

Actually, maybe you can do something like:

<pre>
   if x.flags['F_CONTIGUOUS']:
      x = x.T.ravel()
   else:
      x = x.ravel()
</pre>

to avoid a memory copy for fortran-ordered arrays (the ravel is already
avoiding one for C-ordered arrays).

This function should be a helper that goes in utils, IMHO