Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

RE: Re: Changing delayed formula

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35523] RE: [mg35487] Re: [mg35461] Changing delayed formula
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Wed, 17 Jul 2002 02:09:21 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

For large arrays, one method might be much faster than another, and
we've gotten into little wars, looking for the fastest.  Distribute is
far more intuitive than the others, if the matrix isn't huge.

If the matrix IS huge, you might need a more complicated solution than
any of the ones you've seen so far.

Bobby

-----Original Message-----
From: Julio Vera [mailto:jvera at adinet.com.uy] 
To: mathgroup at smc.vnet.net
Subject: [mg35523] [mg35487] Re: [mg35461] Changing delayed formula

Thanks, Bobby. This way it works exactly the same as Outer.

It appears to me that there is only slight differences between certain
Mathematica formulas, like Array, Outer, or Distribute.

Julio
----- Original Message -----
From: "DrBob" <majort at cox-internet.com>
To: mathgroup at smc.vnet.net
Subject: [mg35523] [mg35487] RE: [mg35461] Changing delayed formula


> I forgot you were trying to distribute And, rather than List:
>
> des = {{11, 12, 13, 14}, {21, 22, 23}, {31, 32}, {41, 42, 43, 44,
45}};
> Distribute[And @@ des, List]
>
> Bobby
>
> -----Original Message-----
> From: Julio Vera [mailto:jvera at adinet.com.uy]
To: mathgroup at smc.vnet.net
> Sent: Saturday, July 13, 2002 2:49 AM
> Subject: [mg35523] [mg35487] [mg35461] Changing delayed formula
>
>
> Hi,
>
> I have a list of lists. it's length (the number of sublists it
> contains) varies.
>
> In[1]:= des={{11,12,13,14},{21,22,23},{31,32},{41,42,43,44,45}}
>
> Out[1]:= {{11,12,13,14},{21,22,23},{31,32},{41,42,43,44,45}}
>
> The length of each of the sublists is arbitrary, too. So I have this
> list of lengths.
>
> In[2]:= elems=Flatten[Table[Dimensions[des[[i]]],{i,Length[des]}]]
>
> Out[2]:= {4,3,2,5}
>
> I want to obtain the list of all combinations of one element of each
> sublist, bounded by &&. This will be a list of 120 elements, each of
> them with 4 components. I define a delayed formula, and apply Array to
> it (the characters printed as bold are subscripts in the Mathematica
> notebook).
>
> In[3]:=
> cond4[a_,b_,g_,d_]:=des[[1,a]]&&des[[2,b]]&&des[[3,g]]&&des[[4,d]]
>
> In[4]:= combi=Flatten[Array[condLength[des],elems]]
>
> Out[4]:=
> {11&&21&&31&&41,11&&21&&31&&42,11&&21&&31&&43,11&&21&&31&&44,...
>
>   ...14&&23&&32&&42,14&&23&&32&&43,14&&23&&32&&44,14&&23&&32&&45}
>
> Since the length of des varies, I would have to define cond each time.
> For instance:
>
> cond3[a_,b_,g_,d_]:=des[[1,a]]&&des[[2,b]]&&des[[3,g]]
>
> I would like to make a definition for cond that would adapt to these
> changes automatically.
>
> I arrived to this solution, which is not rejected by Mathematica, but
> does not work, either.
>
> In[5]:= d[a_,b_]:=des[[a,b<>"_"]]
>
> In[6]:= Unprotect[ReplaceAll]
>
> Out[6]:= {ReplaceAll}
>
> In[7]:=
>
condLength[des][Table[FromCharacterCode[944+i]<>"_",{i,Length[des]}]]/.{
>
a__}=AEa:=Apply[And,Table[d[i,FromCharacterCode[944+i]<>"_"],{i,Length[d
> es]}]]
>
> In fact, I quit the kernel and rerun all the cells except the one
> written here as In[3]. If not, the definition for cond4 remains as it
> was. I was not able to clear cond4 individually.
>
> Thanks very much for anything you can suggest.
>
> Best regards,
>
> Julio Vera
>
>
>
>






  • Prev by Date: Re: How to select all polynomials which have degree greater than a give number out of a list of polynomials!
  • Next by Date: Re: Re: Re: Factoring question
  • Previous by thread: Re: Changing delayed formula
  • Next by thread: Re: White border in plots(2)