MathGroup Archive 2003

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

Search the Archive

Re: Help Providing a Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39700] Re: [mg39696] Help Providing a Module
  • From: BobHanlon at aol.com
  • Date: Mon, 3 Mar 2003 04:24:47 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 3/1/03 11:41:08 PM, flip_alpha at safebunch.com writes:


> 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 tird 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?
>
I'm not sure what you want since your example and explanation appears to be
inconsistent.   However, this should give you an idea of how to approach it:

vects[a_?VectorQ, q_List] :=

     PadRight[#, Max[Length /@ q]]& /@

       Map[If[MemberQ[a, First[#]], Mod[Last[#], 2], 0]&, q, {2}];



a = {-1, 2, 3, 61};

q = {{{-1, 1}, {3, 2}}, {{-1, 1}, {2, 3}, {3, 6}, {61, 1}}, {{2, 2}, {61,
1}}};



vects[a,q]



{{1, 0, 0, 0}, {1, 1, 0, 1}, {0, 1, 0, 0}}


Bob Hanlon



  • Prev by Date: RE: Testing for invertible matrix
  • Next by Date: Re: Incrementing a "For" loop - "For loop.nb" 5893 Bytes yEnc
  • Previous by thread: Help Providing a Module
  • Next by thread: Re: Help Providing a Module