MathGroup Archive 2003

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

Search the Archive

RE: Help Providing a Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39718] RE: [mg39696] Help Providing a Module
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Mon, 3 Mar 2003 23:48:54 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: flip [mailto:flip_alpha at safebunch.com]
To: mathgroup at smc.vnet.net
>Sent: Sunday, March 02, 2003 4:06 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg39718] [mg39696] Help Providing a Module
>
>
>Hello,
>
>can someone help with this?
>
>I have
>
>a = {-1, 2, 3, 61};
>q = {{{-1, 1}, {3, 2}}, 
>     {{-1, 1}, {2, 3}, {3, 6}, {61, 1}},
>     {{2, 2}, {61, 1}}}
>
>I want a module vects[a_, q_ ] that will  produce (notice, the 
>number of
>vectors is the length of q and the number of values within 
>each vector is
>the length of "a":
>
>evects = {{1 , 0, 0, 0} , {1, 0, 0, 1}, {0, 1, 0, 0}}
>
>We see that the first values of the submatrices in q have -1 and 3, and
>those exist in "a", so in each position where the values in a 
>exists, we
>take the mod base 2 of the second value of that value.
>
>So for example, we have {-1, 1} and {-1} exists in a, thus we 
>take Mod[1, 2] = 1 
>as the first evect.  Then we see that there is no 2 in q, so we have a
>zero,  Then we have 3 in q and that does exist, so we take 
>Mod[2, 2] = 0 as
>the value in the evect.  Then, there is no 61, so we have a zero.
>
>Thus, the first vector is {1, 0, 0, 0}. (The values in this vector are
>either zero if the value in the first position of the submatrix doesn't
>exist, otherwise we take the Mod[*, 2] of the second value for 
>the value in
>the vector).  I hope that makes sense.
>
>We then look at he second submatrix in q and it contains as 
>the first value
>of each submatrix, so we can take Mod[*, 2] of each second 
>value and get 
>{1, 1, 0, 1}.
>
>The third would be {0, 0, 0, 1}.  And so on (as q could be larger).
>
>Thus, the vect[a, q] will return (in this example): 
>{{1, 0, 0, 0}, {1, 1, 0, 1}, {0, 0, 0, 1}}
>
>The length of a varies and the length of q varies.
>
>We could have a = {-1, 2} and 
>q = {{{-1, 1},{2, 3}, {5, 6}, {7, 8}}, {{-1, 1}, {3, 2}}}, for example.
>
>I tried doing this, but made a mess of things.  Can someone 
>provide such a
>module?
>
>Thank you, Flip
>
>To email me remove "_alpha".
>
>
>

Flip,

perhaps this is of interest to you:

In[26]:=
Replace[a, Append[#, _ -> 0], {1}] & /@ Apply[#1 -> Mod[#2, 2] &, q, {2}]
Out[26]=
{{1, 0, 0, 0}, {1, 1, 0, 1}, {0, 0, 0, 1}}


--
Hartmut Wolf



  • Prev by Date: RE: Antiderivatives and Definite Integrals
  • Next by Date: RE[2]: ugly Plot Eigenvalues ?
  • Previous by thread: Re: Help Providing a Module
  • Next by thread: how use NDSolve with an ODE having parameters