Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a matrix containing on each position a pair of numbers $(a,b)$. I would like to compute the norm of each vector $(a,b)$ and keep the result in form of a matrix.

So basically, I need to apply the function Norm elementwise to a matrix of vectors. How could I do that?

share|improve this question
3  
Use Map or Apply and take a look at their 3rd argument in documentation center. –  Kuba Sep 10 '13 at 12:34
    
Ok. I'll try that. –  Beni Bogosel Sep 10 '13 at 12:36
add comment

closed as off-topic by m_goldberg, István Zachar, Kuba, Pinguin Dirk, Artes Sep 10 '13 at 15:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, István Zachar, Kuba, Pinguin Dirk, Artes
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

m = {{{a, b}, {c, d}}, {{e, f}, {g, h}}};

Compute the 2-norm.

Map[Norm, m, {2}] // MatrixForm

$\left( \begin{array}{cc} \sqrt{\left| a\right| ^2+\left| b\right| ^2} & \sqrt{\left| c\right| ^2+\left| d\right| ^2} \\ \sqrt{\left| e\right| ^2+\left| f\right| ^2} & \sqrt{\left| g\right| ^2+\left| h\right| ^2} \\ \end{array} \right)$

The $\infty$-norm

Map[Norm[#, Infinity] &, m, {2}] // MatrixForm

$\left( \begin{array}{cc} \max (\left| a\right| ,\left| b\right| ) & \max (\left| c\right| ,\left| d\right| ) \\ \max (\left| e\right| ,\left| f\right| ) & \max (\left| g\right| ,\left| h\right| ) \\ \end{array} \right)$

share|improve this answer
add comment

Norm has a Frobenius option that should help

Norm[Matrix, “Frobenius”]

share|improve this answer
    
I'm afraid it's not what OP is looking for. It doesn't even work for the described object like RandomReal[1, {3, 3, 2}] –  Kuba Sep 10 '13 at 15:07
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.