Hello all,
I am looking for an object that will create any number of "embedded" iterators. The best analogy would be having a bunch of embedded "for" loops, like this:
for (i = i_init; i < i_limit; i += i_inc) for (j = j_init; j < j_limit; j += j_inc) doSomething();
I have created an abstraction that acts as a single loop, and I am using "until" to control the loops iterations. I would like to be able to not use "until" as this forces a restriction of making sure that all operations be performed within the same "time-interval" as all others. I would like to be able to send a single bang to the "top of the loop", and have it output the next set of iterators. For example
[iterator 0 10 1 100 1000 100]
banging on the iterator would produce the follow excerpt:
0 100
0 200
...etc
0 1000
1 100
1 200
...etc
Is there an external that does something like this?
Thanks,
Mike
Hallo, Michael McGonagle hat gesagt: // Michael McGonagle wrote:
I am looking for an object that will create any number of "embedded" iterators. The best analogy would be having a bunch of embedded "for" loops, like this:
for (i = i_init; i < i_limit; i += i_inc) for (j = j_init; j < j_limit; j += j_inc) doSomething();
I have created an abstraction that acts as a single loop, and I am using "until" to control the loops iterations. I would like to be able to not use "until" as this forces a restriction of making sure that all operations be performed within the same "time-interval" as all others. I would like to be able to send a single bang to the "top of the loop", and have it output the next set of iterators. For example
[iterator 0 10 1 100 1000 100]
banging on the iterator would produce the follow excerpt:
0 100 0 200 ...etc 0 1000 1 100 1 200 ...etc
Isn't this simply a combination of two counters with [select i_limit]?
I attached an example, that solves, how I understood the question...
Frank Barknecht _ ______footils.org__
Frank,
Thanks for the reply. After looking at your code, I did find that I was "limiting" my thinking in that I had to put the "inner" loops inside of the other loops, instead of going from the inner-most loop to the outer, as you do in your example.
One problem that I see with your implementation is that it assumes that all the "iterators" will divide evenly, but that can be changed.
Basically, what I am trying to do is to create a means of iterating over a set of variable ranges (for use in a fractal search algorithm). And, I need to be able to have as many as 12 (and possibly more) loops embedded. While yours is a workable solution, I am trying to avoid having to build a set of iterators for each dimension that I am trying to create. It would be nice to have a single "iterator" that can handle more than a single loop.
The specs for what I "need" are:
number of embedded loops to create), or a list of numbers (the same as the list from 2.).
data. These values need to be easily changed.
Takes a reset message to "reset to initial conditions".
Takes a bang message to iterate to the next set of values.
An incoming bang once all the iterators have completed, will do nothing.
Has either (I don't which is best) a single outlet which will output
a list of all the iteration values, or a separate outlet for each iterator variable.
Does this need to have another outlet to indicate that the loop has completed? (ie a bang on the right-most outlet of the iterator).
Thanks,
Mike
Frank Barknecht wrote:
Hallo, Michael McGonagle hat gesagt: // Michael McGonagle wrote:
I am looking for an object that will create any number of "embedded" iterators. The best analogy would be having a bunch of embedded "for" loops, like this:
for (i = i_init; i < i_limit; i += i_inc) for (j = j_init; j < j_limit; j += j_inc) doSomething();
I have created an abstraction that acts as a single loop, and I am using "until" to control the loops iterations. I would like to be able to not use "until" as this forces a restriction of making sure that all operations be performed within the same "time-interval" as all others. I would like to be able to send a single bang to the "top of the loop", and have it output the next set of iterators. For example
[iterator 0 10 1 100 1000 100]
banging on the iterator would produce the follow excerpt:
0 100 0 200 ...etc 0 1000 1 100 1 200 ...etc
Isn't this simply a combination of two counters with [select i_limit]?
I attached an example, that solves, how I understood the question...
ciao
#N canvas 218 217 450 300 10; #X obj 122 41 inlet; #X obj 110 230 outlet; #X obj 152 102 f $1; #X obj 188 102 + $3; #X obj 176 139 select $2; #X obj 237 171 f $1; #X obj 237 206 s $0-reset; #X obj 175 40 r $0-reset; #X obj 110 208 f; #X obj 122 70 t b b; #X obj 176 174 outlet; #X connect 0 0 9 0; #X connect 2 0 4 0; #X connect 2 0 8 1; #X connect 3 0 2 1; #X connect 4 0 5 0; #X connect 4 0 10 0; #X connect 4 1 3 0; #X connect 5 0 6 0; #X connect 7 0 2 1; #X connect 8 0 1 0; #X connect 9 0 8 0; #X connect 9 1 2 0;
#N canvas 631 235 450 300 10; #X obj 100 114 metro 250; #X floatatom 214 187 5 0 0 0 - - -; #X obj 100 88 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X obj 100 135 iter 100 1000 100; #X floatatom 100 189 5 0 0 0 - - -; #X obj 214 159 iter 0 10 1; #X connect 0 0 3 0; #X connect 2 0 0 0; #X connect 3 0 4 0; #X connect 3 1 5 0; #X connect 5 0 1 0;
On Wed, 28 May 2003, Michael McGonagle wrote:
Hello all,
I am looking for an object that will create any number of "embedded" iterators. The best analogy would be having a bunch of embedded "for" loops, like this:
for (i = i_init; i < i_limit; i += i_inc) for (j = j_init; j < j_limit; j += j_inc) doSomething();
I have created an abstraction that acts as a single loop, and I am using "until" to control the loops iterations. I would like to be able to not use "until" as this forces a restriction of making sure that all operations be performed within the same "time-interval" as all others. I would like to be able to send a single bang to the "top of the loop", and have it output the next set of iterators. For example
[iterator 0 10 1 100 1000 100]
banging on the iterator would produce the follow excerpt:
0 100 0 200 ...etc 0 1000 1 100 1 200 ...etc
Is there an external that does something like this?
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
The following patch does what you want:
#N canvas 56 333 589 504 10; #X obj 73 309 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 10 256; #X obj 297 311 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 1000 256; #X msg 59 36 bang; #X obj 60 115 k_cext 7 2 0 0 10 1 100 1000 100 ; int i , j ; for(i=I(1) SC i<=I(2) SC i+=I(3)) BEGIN ; . for(j=I(4) SC j<=I(5) SC j+=I(6)) BEGIN ; . . O0(i) ; . . O1(j) ; . END ; END ;; #X connect 2 0 3 0; #X connect 3 0 0 0; #X connect 3 1 1 0;
Hallo, Kjetil S. Matheussen hat gesagt: // Kjetil S. Matheussen wrote:
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
Also pyext and the scheme external come to mind.
Frank Barknecht _ ______footils.org__
On Thu, 29 May 2003, Frank Barknecht wrote:
Hallo, Kjetil S. Matheussen hat gesagt: // Kjetil S. Matheussen wrote:
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
Also pyext and the scheme external come to mind.
Yes, but you cant edit directly in the pd-window with them. And you dont get the raw speed of C either.
Hi Kjetil, k_cext seems to be very interesting.... my questions:
compilation delay handled?) 2) which C compilers can be used (and where are they configured)? 3) are there platform-dependencies?
best greetings, Thomas
----- Original Message ----- From: "Kjetil S. Matheussen" k.s.matheussen@notam02.no To: "Frank Barknecht" fbar@footils.org Cc: pd-list@iem.kug.ac.at Sent: Thursday, May 29, 2003 2:12 PM Subject: Re: [PD] An Iterator object
On Thu, 29 May 2003, Frank Barknecht wrote:
Hallo, Kjetil S. Matheussen hat gesagt: // Kjetil S. Matheussen wrote:
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
Also pyext and the scheme external come to mind.
Yes, but you cant edit directly in the pd-window with them. And you dont get the raw speed of C either.
--
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
On Thu, 29 May 2003, Thomas Grill wrote:
Hi Kjetil, k_cext seems to be very interesting.... my questions:
- does the scripted C code get compiled on the fly? (and how is the
compilation delay handled?)
The c code is compiled, linked, and dynamically loaded only when an k_cext object is created.
from k_cext.c:
void k_cext_setup(void) { k_cext_class = class_new(gensym("k_cext"), (t_newmethod)k_cext_new, (t_method)k_cext_free, sizeof(t_k_cext), 0, A_GIMME, 0);
... }
static void *k_cext_new(t_symbol *s, t_int argc, t_atom* argv) {
<some initialization> <for each atom in argv>: <generate c code> <compile c code> <link c code> <dynamically load c code into pd> <delete c code source and object files> }
- which C compilers can be used (and where are they configured)?
gcc for linux, and microsoft compiler for window.
- are there platform-dependencies?
Yes, but its not a big problem. It does work for linux and windows, and should work for macosx too. See the k_cext_<os>.c files.
best greetings, Thomas
----- Original Message ----- From: "Kjetil S. Matheussen" k.s.matheussen@notam02.no To: "Frank Barknecht" fbar@footils.org Cc: pd-list@iem.kug.ac.at Sent: Thursday, May 29, 2003 2:12 PM Subject: Re: [PD] An Iterator object
On Thu, 29 May 2003, Frank Barknecht wrote:
Hallo, Kjetil S. Matheussen hat gesagt: // Kjetil S. Matheussen wrote:
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
Also pyext and the scheme external come to mind.
Yes, but you cant edit directly in the pd-window with them. And you dont get the raw speed of C either.
--
PD-list mailing list PD-list@iem.kug.ac.at http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
Kjetil S. Matheussen wrote:
Doing things like this is nice with my k_cext external: http://www.notam02.no/~kjetism/pd/bin/
The following patch does what you want:
#N canvas 56 333 589 504 10; #X obj 73 309 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 10 256; #X obj 297 311 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -6 0 10 -262144 -1 -1 1000 256; #X msg 59 36 bang; #X obj 60 115 k_cext 7 2 0 0 10 1 100 1000 100 ; int i , j ; for(i=I(1) SC i<=I(2) SC i+=I(3)) BEGIN ; . for(j=I(4) SC j<=I(5) SC j+=I(6)) BEGIN ; . . O0(i) ; . . O1(j) ; . END ; END ;; #X connect 2 0 3 0; #X connect 3 0 0 0; #X connect 3 1 1 0;
Wow Kjetil, this is impressive. I do have a question about the initial input values to the iterator code, can they be attached to an inlet, and be adjusted at run time? I don't say real-time, as I don't expect to be changing the iterator limits or step in a performance situation. Does the 'I(1)' refer to the "creation argument" of that number or are the inlet assignments? (or both?)
Also, does the compiled object have to be compiled everytime that the patch is opened? Or are the object files (the ones linked to PD) kept around from run to run? If they do need to be recreated each time, how much time does this add to the loading?
Are you using this as a "prototyping" system, where you take the finished C code and turn it into a full-fledged external?
Mike
On Thu, 29 May 2003, Michael McGonagle wrote:
Wow Kjetil, this is impressive. I do have a question about the initial input values to the iterator code, can they be attached to an inlet, and be adjusted at run time?
Yes, thats what the inlets in the object are for.
I don't say real-time, as I don't expect to be changing the iterator limits or step in a performance situation. Does the 'I(1)' refer to the "creation argument" of that number or are the inlet assignments? (or both?)
Both.
Also, does the compiled object have to be compiled everytime that the patch is opened?
Yes.
Or are the object files (the ones linked to PD) kept around from run to run?
No.
If they do need to be recreated each time, how much time does this add to the loading?
The example object takes 1/10th of a second (or something like that.) to create on a 733Mzh piii, using gcc3 with -O2. In other words; you hardly notice the compile-time.
Are you using this as a "prototyping" system, where you take the finished C code and turn it into a full-fledged external?
Guess, you can, but its not very good for big tasks. I use it instead of making small sub-patches with pd. Much more compact and easier to read, and faster to create.