From: David Young on 6 May 2010 17:39 Sorry to add to this rather long discussion - but two quick points: First, it's not a very strong argument to claim something is "unintuitive". Your intuition will be different to mine, especially if we have past experience of different languages. Anyway, if I used my intuition to tell me how to program, I don't think I'd have written a correct program in my life. Second, C uses the int type for logical data. Java - a more modern and arguably better designed language - has a separate boolean type, even though it follows C in many other ways. Why would the designers of the newer language introduce this distinction? Because it conveys a range of advantages, from efficiency to error checking.
From: dpb on 6 May 2010 17:42 Alan B wrote: .... > Matt, Bruno, Roger, I don't think my question is so outrageous... > > I remember an example of a standard Matlab function that computes some > statistical metric on arrays columnwise, except when the input is a 3x3. > In this case, it reverts to row-wise, or maybe does some 2-dimensional > calculation. Unfortunately I do not remember the name of the function, > and I may not be recalling the details correctly, but the point is that > Matlab is not necessarily 100% consistent. Does anyone else know what > I'm talking about? > > I'm not arguing FOR inconsistency, just observing that, if I recall > correctly, Matlab doesn't have a perfect track record. Well, by not thinking the question "isn't outrageous", I'd say you're arguing for inconsistency... :) Undoubtedly being sorta' an ad hoc language that has evolved there are some inconsistencies in ML. _BUT_ to consider introducing such a major behaviorial change between arrays depending only on the values contained within is truly evil... :( --
From: James Tursa on 6 May 2010 18:35 "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <hrvcto$kc7$1(a)fred.mathworks.com>... > > Second, C uses the int type for logical data. Well, C does have the _Bool type. The fact that int is often used in programs for logical type data is a programmer choice, not a language specification. Any type that has zero and non-zero values could be used for this as they would have the same effect in logical contexts. > Java - a more modern and arguably better designed language ... Hmmmm ... inviting a flame war on the MATLAB newsgroup? James Tursa
From: Steven Lord on 6 May 2010 22:53 "Walter Roberson" <roberson(a)hushmail.com> wrote in message news:9nGEn.49$7d5.4(a)newsfe17.iad... > Sergei Koulayev wrote: >> Indeed, why would you store zeros(1,2) >> as a double? It is not efficient. > > Not efficient in space, but efficient in CPU processing, as these days I > understand it is not so uncommon to find chips whose double precision > calculation throughput is faster than its best integer calculation > performance. Another reason (that I know Walter knows but Sergei may not) is preallocation. If you know that you want to end up with a 100-by-100 double precision matrix, but you don't know the values you want to be in the matrix when you first create it, it makes sense to allocate enough memory for 10000 elements once rather than allocating enough memory for 1 element, then 2 elements [copying the 1-element region into the 2-element region], then 3 elements [copying the 2-element region into the 3-element region], etc. Now we _could_ allocate that memory and just leave whatever bits are present in those memory locations, but if some amount of those elements are going to end up as zeros, you might want to fill them up with zeros initially and fill in just the nonzero elements. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Steve Eddins on 7 May 2010 07:35
On 5/6/2010 5:00 PM, us wrote: > "Steven Lord" <slord(a)mathworks.com> wrote in message > <hrva6h$jd7$1(a)fred.mathworks.com>... >> >> "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message >> news:hrv9fl$1ue$1(a)fred.mathworks.com... >> > "Sergei Koulayev" <sergei.koulayev(a)mathworks.com> wrote in message > >> <hrv8mp$9j2$1(a)fred.mathworks.com>... >> >> Expecting users to track data types is not realistic. >> > >> > Of course it is. >> > >> > IMHO the three most important commands absolutely must known by new >> Matlab > users are: >> > >> > DEBUG >> > SIZE >> > CLASS >> >> Perhaps this is optimistic, but I would hope that two others were also >> on that list; I would even put them before the three you mention: >> >> HELP >> DOC >> >> -- >> Steve Lord > > ...and let's not forget these > > METHODS > METHODSVIEW > > us Don't forget MINDREAD. |