Prev: pattern recognition/image analysis
Next: How to fit my data to y=a*exp(-bx) by restricting 0<a<1?
From: dpb on 1 Apr 2010 15:49 Jan Simon wrote: .... > Both mentioned methods ([~, ~, .. varn] and [varn, varn, ..varn]) > "waste" some memory, although it is occupied temporarily only. > Another idea is using an additional input: > varn = myfunction(param1, param2, ..., paramn, nOut) > And reply just the nOut.th output. .... And yet another might be to reorder the output variables if this is a common need of the function so that the one that is often desired as a single output is the first instead of somewhere on down the list... If the one desired result changes from time to time, that doesn't help so much, of course, but if that's the case then one begins to wonder if the factorization of the function isn't in error, perhaps. --
From: Merciadri Luca on 1 Apr 2010 17:00 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 dpb <none(a)non.net> writes: > Merciadri Luca wrote: > ... > >> ... M-Lint Code Check Report gives me `The value >> assigned to var1 is never used,' where var1 is actually used. I mean that >> function myfunction2 sends [var1 var2], but I call it with >> >> [var2 var2] = myfunction2(some stuff), >> where var2 is used later in my code (not in the function, evidently), >> but not var1. ... > > Would have to see actual code to confirm but I'd presume it's caught > on to the fact that var1 isn't actually assigned on the output but is > declared as an output in the function definition... I do not understand what you mean: the function is defined to return [var1 var2], but I do not want, once it has been called, to know var1. I simply want to know var1. And? Let's take another example on a function that I cannot modify directly. I use somewhere in my code == [minim, min_subst_index] = min(subst) == where subst is a matrix whose elements are the results of substractions between numbers. Okay, everything is fine, but I simply do not use minim in my code. If I use == [min_subst_index, min_subst_index] = min(subst) == M-Lint tells me that `The value assigned here to variable 'min_subst_index' is never used.' That is complete nonsense, as min_subst_index _is_ used later. However, if I use == [minim, min_subst_index] = min(subst) == it tells me that `The value assigned here to variable 'minim' is never used.' What can I do to get rid of minim? I have other examples of such problems, but with personal functions. I absolutely need a (clean, if possible) solution to this. Please tell me if what I said is not clear. Thanks. - -- Merciadri Luca See http://www.student.montefiore.ulg.ac.be/~merciadri/ - -- You don't have to be different to be good. You have to be good to be different. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/> iEYEARECAAYFAku1CXkACgkQM0LLzLt8MhwN6gCeNwcZO+XpQMu0GWRXoxNEwQBU LcgAnRF5V67KmsGlOOIWRq03k/hsYHOA =s93k -----END PGP SIGNATURE-----
From: Merciadri Luca on 1 Apr 2010 17:02 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> writes: > Dear Merciadri Luca! > Both mentioned methods ([~, ~, .. varn] and [varn, varn, ..varn]) "waste" some memory, although it is occupied temporarily only. > Another idea is using an additional input: > varn = myfunction(param1, param2, ..., paramn, nOut) > And reply just the nOut.th output. > If the other parameters are large, it is worth to compare the computing times. If the function is not critical for time, choose the method you like most. Thanks for your answer. I will use it if I do not have any other choice, as my function is time-critical and that computations are quite tricky. - -- Merciadri Luca See http://www.student.montefiore.ulg.ac.be/~merciadri/ - -- You'll always miss 100% of the shots you don't take. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/> iEYEARECAAYFAku1CfAACgkQM0LLzLt8MhybxgCeJNdPX1VSsBly8nbKw2r2reE8 cRoAnjNuBLTxAFkIvrLxl0Sk2IctELRf =IxtX -----END PGP SIGNATURE-----
From: dpb on 1 Apr 2010 17:25 Merciadri Luca wrote: .... > > == > [min_subst_index, min_subst_index] = min(subst) > == > > M-Lint tells me that `The value assigned here to variable > 'min_subst_index' is never used.' That is complete nonsense, as > min_subst_index _is_ used later. However, if I use > > == > [minim, min_subst_index] = min(subst) > == > > it tells me that `The value assigned here to variable > 'minim' is never used.' What can I do to get rid of minim? > > I have other examples of such problems, but with personal functions. I > absolutely need a (clean, if possible) solution to this. .... The parser of m-lint is smart enough to be able to tell the two apart syntactically in the first case, apparently, and minim _isn't_ used elsewhere in the second. Both seem perfectly correct. Only way I can see to "fix" it would be if M-Lint has a warnings level that would exclude it. Otherwise, it's simply being informative of a condition that could possibly be an error/oversight/mistake; you just happen in this instance to know better. --
From: dpb on 1 Apr 2010 17:26 Merciadri Luca wrote: .... > Thanks for your answer. I will use it if I do not have any other > choice, as my function is time-critical and that computations are > quite tricky. .... This would seem to call for the refactorization approach alluded to earlier, perhaps... --
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: pattern recognition/image analysis Next: How to fit my data to y=a*exp(-bx) by restricting 0<a<1? |