MathGroup Archive 2011

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

Search the Archive

Re: Table with conditions

"J. Jesus Rico Melgoza" wrote:

> I am constructing a Table
> h=60
> hi=60
> P1 = Flatten[
>     Table[{Pk[k].Fl[l], k + l}, {k, -h, 
>       h}, {l, -hi, hi}], 1]
> This yields a table with two columns. First column contains vector of order n and column 2 contains an scalar
> I want to add conditions to generate the elements in the Table
> -h<=k+l<=h. 
> I do not know how to do this with the function Table[..] of Mathematica. I am asking for your help.
> I do not want rows in my table that do not satisfy the condition.  
> Pk[k] is matrix and Fl[l] is a column vector
> Thanks in advance
> Jesus Rico-Melgoza

This seams to work:

h = 60; hi = 60;
p1 = Table[{Pk[k].Fl[l], k + l}, {k, -h, h}, {l, -hi, hi}]
Flatten[Select[#, -h <= #[[2]] <= h &] & /@ p1, 1] // TableForm

Peter Breitfeld, Bad Saulgau, Germany --

  • Prev by Date: Re: Table with conditions
  • Next by Date: Re: what's in a name? (legal and conventional constructions of identifiers)
  • Previous by thread: Re: Table with conditions
  • Next by thread: MPI-style message passing in pure Mathematica