Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14893 > unrolled thread
| Started by | amannucci <Anthony.J.Mannucci@jpl.nasa.gov> |
|---|---|
| First post | 2013-06-16 09:12 +0000 |
| Last post | 2013-06-17 10:18 +0000 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Working with arrays amannucci <Anthony.J.Mannucci@jpl.nasa.gov> - 2013-06-16 09:12 +0000
Re: Working with arrays David Bailey <dave@removedbailey.co.uk> - 2013-06-17 10:15 +0000
Re: Working with arrays amannucci <Anthony.J.Mannucci@jpl.nasa.gov> - 2013-06-17 10:17 +0000
Re: Working with arrays David Bailey <dave@removedbailey.co.uk> - 2013-06-19 05:20 +0000
Re: Working with arrays "Kevin J. McCann" <kjm@KevinMcCann.com> - 2013-06-17 10:17 +0000
Re: Working with arrays Roland Franzius <roland.franzius@uos.de> - 2013-06-17 10:18 +0000
| From | amannucci <Anthony.J.Mannucci@jpl.nasa.gov> |
|---|---|
| Date | 2013-06-16 09:12 +0000 |
| Subject | Working with arrays |
| Message-ID | <kpjvhm$9n8$1@smc.vnet.net> |
I thought I understood variables. This sequence completely mystifies me:
Clear[lA, xtest]
lA = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
xtest = {4, 5, 6};
lA\[CenterDot]xtest (* First case *)
{{a, b}, {c, d}} . {x, y} (* Second case *)
The output is:
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}\[CenterDot]{4, 5, 6}
{a x + b y, c x + d y}
How do I force matrix multiplication to actually occur, as in the second answer? Why does Mathematica do the matrix multiply in the second case but not the first?
Thanks for any help.
-Tony
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-06-17 10:15 +0000 |
| Message-ID | <kpmnkk$h33$1@smc.vnet.net> |
| In reply to | #14893 |
On 16/06/2013 10:12, amannucci wrote:
> I thought I understood variables. This sequence completely mystifies me:
> Clear[lA, xtest]
> lA = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
> xtest = {4, 5, 6};
> lA\[CenterDot]xtest (* First case *)
> {{a, b}, {c, d}} . {x, y} (* Second case *)
>
> The output is:
>
> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}\[CenterDot]{4, 5, 6}
>
> {a x + b y, c x + d y}
>
> How do I force matrix multiplication to actually occur, as in the second answer? Why does Mathematica do the matrix multiply in the second case but not the first?
>
> Thanks for any help.
>
> -Tony
>
In the first example, you used CenterDot, which is an operator with no
built in meaning. In the second case you used Dot, which will do
vector/matrix multiplication!
I must say, I never use these operators, because they can be confused
with each other, and a decimal point, and dots also mean repetition in
patterns!
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | amannucci <Anthony.J.Mannucci@jpl.nasa.gov> |
|---|---|
| Date | 2013-06-17 10:17 +0000 |
| Message-ID | <kpmnn5$h3b$1@smc.vnet.net> |
| In reply to | #14893 |
On Sunday, June 16, 2013 2:12:22 AM UTC-7, amannucci wrote:
> I thought I understood variables. This sequence completely mystifies me:
>
> Clear[lA, xtest]
>
> lA = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
>
> xtest = {4, 5, 6};
>
> lA\[CenterDot]xtest (* First case *)
>
> {{a, b}, {c, d}} . {x, y} (* Second case *)
>
>
>
> The output is:
>
>
>
> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}\[CenterDot]{4, 5, 6}
>
>
>
> {a x + b y, c x + d y}
>
>
>
> How do I force matrix multiplication to actually occur, as in the second answer? Why does Mathematica do the matrix multiply in the second case but not the first?
>
>
>
> Thanks for any help.
>
>
>
> -Tony
I appreciate the replies I have received. Yes, CenterDot is the wrong operator! I am a little rusty here. I appreciate the helpful comments.
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-06-19 05:20 +0000 |
| Message-ID | <kprf3k$15m$1@smc.vnet.net> |
| In reply to | #14915 |
On 17/06/2013 11:17, amannucci wrote:
>
> I appreciate the replies I have received. Yes, CenterDot is the wrong operator! I am a little rusty here. I appreciate the helpful comments.
>
If you find an expression that doesn't seem to evaluate correctly, one
of the first things to try is to examine the FullForm of the held
expression (to suppress its evaluation):
lA\[CenterDot]xtest //Hold//FullForm
{{a, b}, {c, d}} . {x, y} //Hold //FullForm
FullForm cracks a certain percentage of the problems presented in this
forum instantaneously!
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | "Kevin J. McCann" <kjm@KevinMcCann.com> |
|---|---|
| Date | 2013-06-17 10:17 +0000 |
| Message-ID | <kpmnoe$h3j$1@smc.vnet.net> |
| In reply to | #14893 |
Use a period instead of a CenterDot, as you did in the "Second case".
Cheers,
Kevin
On 6/16/2013 5:12 AM, amannucci wrote:
> I thought I understood variables. This sequence completely mystifies me:
> Clear[lA, xtest]
> lA = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
> xtest = {4, 5, 6};
> lA\[CenterDot]xtest (* First case *)
> {{a, b}, {c, d}} . {x, y} (* Second case *)
>
> The output is:
>
> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}\[CenterDot]{4, 5, 6}
>
> {a x + b y, c x + d y}
>
> How do I force matrix multiplication to actually occur, as in the second answer? Why does Mathematica do the matrix multiply in the second case but not the first?
>
> Thanks for any help.
>
> -Tony
>
[toc] | [prev] | [next] | [standalone]
| From | Roland Franzius <roland.franzius@uos.de> |
|---|---|
| Date | 2013-06-17 10:18 +0000 |
| Message-ID | <kpmnp2$h3l$1@smc.vnet.net> |
| In reply to | #14893 |
Am 16.06.2013 11:12, schrieb amannucci:
> lA = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
> xtest = {4, 5, 6};
> lA\[CenterDot]xtest (* First case *)
> {{a, b}, {c, d}} . {x, y} (* Second case *)
>
> The output is:
>
> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}\[CenterDot]{4, 5, 6}
>
> {a x + b y, c x + d y}
The Dot-multiplication operator is overloaded with conventional physical
applications.
In the mathematical sense you may declare matrix multiplication from the
left with row vectors
{1,2,3}.{{1,2,3},{4,5,6},{7,8,9}}
or multiplication from the right with column vectors
{{1,2,3},{4,5,6},{7,8,9}.{{1},{2},{3}}
But since the most common three bilinear procedures on higher
dimensional objects of maximal tensor rank 2:
1) scalar multiplication with implicitely assumed euclidean metrics,
2) applying forms on vectors and tensors of rank 2
3) matrix multiplication procedures
are obcsured in physics textbooks, completely, Mathematica, as a user
friendly package, deliberately is guessing if a given Dot product may
make any sense.
A hint to the background of this strange behavour is given in the "more
information" statement in the Help for Dot:
" When its arguments are not lists or sparse arrays, Dot remains
unevaluated"
Evaluate[lA].Evaluate[xtest]
is working as expected.
Take it as a hint that Dot is a generic name for a library of highly
specialized subfunctions, that will be called with the arguments by name
and not by value or on the stack.
It is the same reason why Plot or Integrate do not Evaluate the
functional arguments. If needed, the values explicitely have to be
handed over with an Evaluate beforehand in order to replace the name by
its value in an argument at a Hold position.
But this behaviour is not documented for Dot.
Attributes[Dot] ...
Perhaps this behaviour may force numerical linear programmers to use the
correct mathematical tensor categories even in case of simple numerics
with numerical arrays -- or perhaps they will use other packages not so
sophisticated.
--
Roland Franzius
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web