Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Sequence@@List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64644] Sequence@@List
  • From: Martin Schoenecker <ms_usenet at gmx.de>
  • Date: Sat, 25 Feb 2006 02:53:06 -0500 (EST)
  • Organization: Technische Universitaet Darmstadt
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

I want to construct the corresponding variable list to a
CoefficientList[poly, {var1, var2, var3,...}].

The following code does the work:

---------------------------------------------------------
In[472]:=
vl = {x, y, z}
dims = {2, 3, 2}
r = Dimensions[dims]

Out[472]=
{x,y,z}

Out[473]=
{2,3,2}

Out[474]=
{3}

In[475]:=
Table[vl[[1]]^a*vl[[2]]^b*
    vl[[3]]^c, {a, 0,
    dims[[1]] - 1},
   {b, 0, dims[[2]] - 1},
   {c, 0, dims[[3]] - 1}]

Out[475]=
\!\({{{1, z}, {y, y\ z}, {y\^2, y\^2\ z}}, {{x, x\
         z}, {x\ y, x\ y\ z}, {x\ y\^2, x\ y\^2\ z}}}\)
-----------------------------------------------------------

To do the job automated (so that a different variable list vl can be 
used easily, as well as the output of Dimensions[CoefficientList[...]] 
can be used as dims, for veriable polynomials and variables) I tried

------------------------------------------------------------
In[477]:=
body = Product[vl[[k]]^i[k],
    {k, 1, Dimensions[vl][[1]]}]
iterator = Table[{i[ind], 0,
     dims[[ind]] - 1},
    {ind, 1, r[[1]]}]
Table[body, Sequence @@ iterator]

Out[477]=
x^i[1]*y^i[2]*z^i[3]

Out[478]=
{{i[1], 0, 1}, {i[2], 0, 2},
   {i[3], 0, 1}}

 From In[481]:=
Table::"itform":"Argument \!\(Sequence @@ iterator\) at position \!\(2\) 
does \
not have the correct form for an iterator. \!\(\*ButtonBox[\"Mehrâ?¦\", \
ButtonStyle->\"RefGuideLinkText\", ButtonFrame->None, \
ButtonData:>\"General::itform\"]\)"
---------------------------------------------------------------

which does not work because in this case, because Sequence does not 
strip the outer List brackets, while using it as the only argument to 
some function, e.g.

---------------------------------------------------------------
In[480]:=
f[Sequence @@ iterator]

Out[480]=
f[{i[1], 0, 1}, {i[2], 0, 2},
   {i[3], 0, 1}]
---------------------------------------------------------------

does work.

Any help regarding using Sequence in a function accepting more than just 
one argument is appreciated!

Thank you,
Martin


  • Prev by Date: Re: Plot -> axes inversion
  • Next by Date: Re: Plot -> axes inversion
  • Previous by thread: Nonlinear Fit of Complex functions
  • Next by thread: Limit