[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help
The task is not strictly defined: the two matrices Tri provided are
different in size. Therefore, I treated it as a general problem. Here is
a 1-line solution for any size matrix:
print, (bindgen(k*m+m-1, x) mod m) eq 0
Here,
m is the length of the cycle within a row,
k is an integer multiplier to obtain the necessary row length,
x - arbitrary number of rows.
Example with m=4, k=3, x=5:
IDL> print, (bindgen(3*4+3, 5) mod 4) eq 0
1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
0 1 0 0 0 1 0 0 0 1 0 0 0 1 0
0 0 1 0 0 0 1 0 0 0 1 0 0 0 1
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0
1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
Resulting matrix can be trimmed in any fashion you desire. Or, maybe I
could just type matrices in, if they were needed precisely and only in the
way Tri sent them?...
Cheers,
Pavel
Tri VU KHAC wrote:
> Hi folks,
>
> I'm looking for an efficient way to produce the matrix of type (I woulk
> like to be able to avoid the FOR statement)
>
> 0 1 0 1 0 1 0 1
> 1 0 1 0 1 0 1 0
> 0 1 0 1 0 1 0 1
> 1 0 1 0 1 0 1 0
>
> OR
>
> 1 0 0 1 0 0 1
> 0 1 0 0 1 0 0
> 0 0 1 0 0 1 0
> 1 0 0 1 0 0 1
>
> ETC.
>
> Best regards,
> Tri.