MathGroup Archive 2009

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

Search the Archive

Re: rules on vector sequence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98065] Re: rules on vector sequence
  • From: Francesco <b.gatessucks at gmail.com>
  • Date: Sun, 29 Mar 2009 02:45:33 -0500 (EST)
  • References: <gqkurj$47q$1@smc.vnet.net>

Not practical for n>~6 :

n = 4;
elements = {-2, -1, 0, 1, 2};
rules[entry_] :=
  Total[entry] ==
    0 && (Count[entry, 0] == (n - 2) || Count[entry, 0] == (n - 4) )
Select[Tuples[elements, n], rules[#] &]

-Francesco

Filippo Miatto wrote:
> Dear all,
> I need to generate all the vectors, of a given length N, that have  
> these three properties:
> 
> 1- the entries have to be among -2,-1,0,1,2
> 2- the sum of all the entries has to be 0
> 3- only two or four of the entries can be different from 0
> 
> do you have any suggestions on how i can do that? i tried something  
> but without success.. expecially i don't know how to implement the  
> third rule..
> thank you in advance!
> Filippo
> 


  • Prev by Date: Re: How include a online help for Package in the Documentation Center
  • Next by Date: Re: rules on vector sequence
  • Previous by thread: Re: rules on vector sequence
  • Next by thread: Re: rules on vector sequence