Re: Arbitrarily Many Nested Loops
- From: "Jacob JKW" <jacobcdf@xxxxxxxxx>
- Date: 29 Mar 2006 18:40:06 -0800
Ilya Zakharevich wrote:
[A complimentary Cc of this posting was sent toI was definitely a bt lacadaisical in my proofreading efforts. What I
A. Sinan Unur
<1usa@xxxxxxxxxxxxxxxxxxx>], who wrote in article <Xns9795CB63AB7DAasu1cornelledu@xxxxxxxxx>:
You need to work a little on explaining the problem and algorithm.I'm afraid the problem is on your side. The explanation-by-code looks
Neither the code snippet above nor your verbal description makes any
sense to me
absolutely clear to me.
*should* have written was:
But that's obviously messy and more imprtantly I'd like to be able to
decide at run time how many nested levels I'll need.
Possibly that's vaguely more clear.
Looks like there is a multi-dimensional array of unknown-in-advanceYou got it exactly. :-)
dimension. It is known that it is "rectangular"; the sizes are stored
in another vector (one size per dimension).
[OT Description - I'm using this to create a binomial-style probability
distribution where the success probability differs between trials. For
example. If I flip n different coins, each one biased to a known
extent, m(i) times each what would the probability be of flipping x
heads?]
One wants a CONVENIENT way to run through the elements of this array.The way I'd put it would be that I want a way to run through the
elements of the array without having to resort to copy-and-paste.
One hint to OP: since you do not know the dimension at compileMost definitely . I had just posted the first kludge I came up with.
time, you cannot be sure that the index of 1st,2nd,3rd etc
dimensions is $k, $l, $m etc. So the only solution is to have the
running index to be an array too: $I[0], $I[1], $I[3] etc.
This more or less immediately suggests a possible solution...I have to admit, I don't really see the possible solution you have in
mind here ...
P.S. One could also use Math::Pari's forvec(); might be a little bitSelf-promote much? ;-)
heavy-weight solution, but maybe then you will find some use for
other functions in Math::Pari too. ;-)
.
- References:
- Arbitrarily Many Nested Loops
- From: Jacob JKW
- Re: Arbitrarily Many Nested Loops
- From: A. Sinan Unur
- Re: Arbitrarily Many Nested Loops
- From: Ilya Zakharevich
- Arbitrarily Many Nested Loops
- Prev by Date: Re: Arbitrarily Many Nested Loops
- Next by Date: SSH
- Previous by thread: Re: Arbitrarily Many Nested Loops
- Next by thread: Re: Arbitrarily Many Nested Loops
- Index(es):
Relevant Pages
|