MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Problems with Outer

  • Subject: [mg2873] Problems with Outer
  • From: ross at zeus.mpce.mq.edu.au ("Ross Moore <ross at zeus.mpce.mq.edu.au>")
  • Date: 2 Jan 1996 05:50:35 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.com


Hi there. 
Can someone please explain the following behaviour.


I want to create the outer product of some lists, whose
elements themselves may be lists.
The obvious function to use is  Outer .

(Zeus2.2.2) In[1]:= ?Outer
Outer[f, list1, list2, ...] gives the
   generalized outer product of the listi.


This works fine...

(Zeus2.2.2) In[2]:= Outer[{#1,#2}&
	, {aa[a,a,a],bb[b,b,b]}
	, {cc[c,c,c],dd[d,d,d]}]//MatrixForm

(Zeus2.2.2) Out[2]//MatrixForm=
aa[a, a, a]   aa[a, a, a]
cc[c, c, c]   dd[d, d, d]

bb[b, b, b]   bb[b, b, b]
cc[c, c, c]   dd[d, d, d]


But when the heads of the elements are  List , the result
is quite different...

(Zeus2.2.2) In[3]:= Outer[{#1,#2}&
	, {List[a,a,a],List[b,b,b]}
	, {List[c,c,c],List[d,d,d]}]//MatrixForm

(Zeus2.2.2) Out[3]//MatrixForm=
a a a   a a a   a a a
c c c   c c c   c c c
a a a   a a a   a a a
d d d   d d d   d d d

b b b   b b b   b b b
c c c   c c c   c c c
b b b   b b b   b b b
d d d   d d d   d d d


Without the MatrixForm there is a mess of extra bracketings.
Where do they come from, and why?


Of course I can get the answer I want using those
extraneous heads...

(Zeus2.2.2) In[4]:=
%1/.{aa->List,bb->List,cc->List,dd->List}//MatrixForm

(Zeus2.2.2) Out[4]//MatrixForm=
a a a   a a a
c c c   d d d

b b b   b b b
c c c   d d d

... or in a 1-liner ...


(Zeus2.2.2) In[9]:= Outer[{#1,#2}&
	, aa@@#&/@{{a,a,a},{b,b,b}}
	, aa@@#&/@{{c,c,c},{d,d,d}}]/.{aa->List}//MatrixForm

(Zeus2.2.2) Out[9]//MatrixForm=
a a a   a a a
c c c   d d d

b b b   b b b
c c c   d d d


... but it seems overly cumbersome to have to do it this way.


Explanations please?
...or alternative simple workarounds that you may already use
to overcome this bug(?).


	Regards,

		Ross

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ross Moore                         Internet: ross at mpce.mq.edu.au
Mathematics Department                Work:       +61 2 850-8955
Macquarie University                   Home:   please do not try
North Ryde, Sydney                     Fax:       +61 2 850-8114
Australia  2109			http://www.mpce.mq.edu.au/~ross/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~


  • Prev by Date: Problems with Outer
  • Next by Date: ?packages for group representation theory
  • Previous by thread: Problems with Outer
  • Next by thread: Re: Problems with Outer