[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell
Subject:    improved Cryptarithm test
From:       mechvel () math ! botik ! ru (S ! D ! Mechveliani)
Date:       1999-09-28 15:56:53
Message-ID: m11Vzao-004561C () math ! botik ! ru
[Download RAW message or body]

Fergus Henderson <fjh@cs.mu.OZ.AU>  writes

> On 28-Sep-1999, S.D.Mechveliani <mechvel@math.botik.ru> wrote:
>> D. Tweed <tweed@compsci.bristol.ac.uk>  writes
>> T> One small comment is that in your functions condition1 & condition2 I
>> T> think most C++ programmers would say that you want to write
>> T> 
>> T> int condition1 (const vector<long>& x)
>> T>  
>> T> since otherwise the compiler generally has to obey the normal function
>> T> call semantics and create a copy of the vector when it passes it the
>> T> function, rather than work directly with the existing list. 
>> 
>> Thank you.
>> Here is again the improved test.
...
>> And now the performance ratio shows  * 16 *.
>> 
>> I understand this so, that this particular task allows to set
>> `const'. Because first,  condition1, condition2  apply to the 
>> vector  x;  as they do not modify  x,  next_permutation(x)
>> yields the correct value when applied after them.
>> 
>> Probably, other tasks and `condition1' variants would not allow to 
>> set `const' like here.
>> Do i understand right?
>> And for these cases the ratio is smaller, say,  6, as showed the 
>> earlier test - ?


> No.  `const' here probably has no effect on the efficiency.
> The difference in efficiency is due to the copying, which is
> because your original C++ program unwisely used pass-by-value,
> rather than pass-by-const-reference.  Most likely pass-by-reference
> and pass-by-const-reference will have exactly the same performance.


Sorry, this C so so difficult ...
What i wrote on `const', probably it refers to `&'.
Because in the initial program  x  of type  vector  was passed to
`condition1'  (if i recall right).
And now appears `&' (right?). That is passed is the pointer to the 
vector.
Now, if i reformulate my last assertion      `>> .. '
replacing `const' with `&' will it be true?


------------------
Sergey Mechveliani
mechvel@botik.ru








[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic