[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: array dimensions
David Fanning wrote:
> Richard G. French (firstname.lastname@example.org) writes:
> > Now that you mention SMOOTH, one of my pet peeves is that
> > y=SMOOTH(array,n) gives an error message when n=1. There are lots of
> > instances where the degree of smoothing is calculated on the fly,
> > and one common instance is that you want no smoothing at all - i.e.
> > just give me the original array, unsmoothed. I've ended up writing
> > my own routine MYSMOOTH which is identical to smooth except that
> > it does not barf when n=1. Perhaps this has been changed recently,
> > but I don't think so. Does anyone have a good explanation for why
> > n=1 does not have the expected behavior of returning the array
> > unsmoothed? Or is there a keyword I have not been noticing that
> > can handle this case?
> Having had some modest experience these past few years
> writing programs for public consumption, allow me to
> make an observation or two.
> I don't know how it is done in the real world, but
> in my world a program idea is generated as a result
> of a problem I have encountered (usually more than once)
> in my own work. I come up with what I almost always
> mistakenly believe is a clever idea and I code it up.
> The program stays at this stage for some indeterminate
> amount of time, usually until someone runs into a similar
> problem and asks a question on the newsgroup. "Oh", I think,
> "I have a clever solution to *that* problem. I'll clean
> it up for them and offer it on my web page."
> In the course of "cleaning it up", I usually discover
> that my clever solution is really not as clever as I
> thought it was and that it tends to work only in the
> narrow confines of its original purpose. So I
> make it more general. In fact, I usually try to imagine
> all the ways it might be used.
> Now, I am known in some circles as having a pretty
> fertile imagination, but I have to admit that one of the
> things that would *never* occur to me if I was writing
> a SMOOTH function is that someone would use it if they
> *didn't* want to smooth anything. Are you sure it would
> have occurred to you?
It would have occurred to me; part of my group's standard testing
routine is to check all boundary cases, which would have focused my
attention on n=1. One of my own design rules is to avoid interpreting
unusual values for arguments as errors unless I have to. I look for ways
to interpret them as instructions to do something unusual (but
consistent with the meaning attached to more normal values). Thus, I
don't normally treat a count of 0 as an error, but as an instruction to
process 0 of whatever is being counted; i.e., to skip processing.