On Tue, Mar 4, 2014 at 11:02 AM, Andreas Noack Jensen <
andreasnoackjen...@gmail.com> wrote:

>
> makes really good sense. The distinction between arrays and and matrices
> in Numpy has been confusing to me, but actually it appear that Numpy agrees
> with how Julia is doing it right now
>
> In [1]: import numpy as np
> In [2]: np.linalg.norm(np.matrix([1,2,3]),1)
> Out[2]: 3
> In [3]: np.linalg.norm(np.matrix([1,2,3]).transpose(),1)
> Out[3]: 6
>

That is correct, but the other difference with numpy is that np.array and
np.matrix are not aliases (in julia, AFAIK, Matrix is equivalent to
Array{T,2}).
What this means is the following:

X = np.array([[1,2,3],[4,5,6]])
M = np.matrix([[1,2,3],[4,5,6]])

# but norm() behaves differently for each case:

np.linalg.norm(X[0,:],1)   # --> 6
np.linalg.norm(M[0,:],1)  # --> 3


therefore this opens another question: shall a matrix be conceptually the
same as a 2D array?
It is not only numpy that takes it differently, but also Eigen for example.

in such case, we would need

norm(Vector) -> vector norm
norm(Matrix) -> matrix norm
norm(Array)  -> maybe undefined, or vector if 1xN or Nx1 array, matrix norm
otherwise


Things get more tricky then, I don't know which is the best solution, but
there always will be trade-off.

Reply via email to