Exponentiation used in division? & Some extrordinary slowness is some problems.



add(a,b) := a+b$              <<< a correct function definition, works with
numeric and symbolic a and b
addfs(a,b) := (modedeclare([a,b],fixnum), a+b)$  <<< compiles into good
code for fixnum (integers that fit in one word)
addfb(a,b) := block([], modedeclare([a,b],fixnum), a+b) $ <<< same thing,
using a block instead of a sequence

Unlike most languages, the modedeclare *does not* do any type checking
either in interpreted or in compiled code (it probably should...).
Moreover, sometimes it will perform the correct operation even if the
arguments are of the wrong type.

                   -s



On Tue, Dec 31, 2013 at 6:45 PM, Dennis Darland - student <
student at dennisdarland.com> wrote:

>  I find the documentation on modedeclare and compile a little confusing.
> Could someone point me to a short working example?
> I've never done that before.
>
> I have no idea how to produce a short example of my problem and I suspect
> it may be too large to even attach.
> I cannot expect anyone to tackle this - but I will provide some links just
> in case.
>
> (These are just in the 2nd recent set of tests -  have been working on
> this in one form or another for a long time.)
>
> The maxima source file:
>
> http://sode.sourceforge.net/omniresults/2nd_maxima_tests/diffeq.expt_lin_sin_new.max.txt
>
> The results:
>
> http://sode.sourceforge.net/omniresults/2nd_maxima_tests/results.expt_lin_sin_new.max.txt
>
> The c source for the same problem:
>
> http://sode.sourceforge.net/omniresults/2nd_c_tests/diffeq.expt_lin_sin_new.c.txt
>
> The c program results:
>
> http://sode.sourceforge.net/omniresults/2nd_c_tests/results.expt_lin_sin_new.c.txt
>
> Both programs are generated by the same set of programs.
>
> Again there is more info at the web site - it will be difficult to
> understand the code without the info.
> http://sode.sourceforge.net/
> I really don't expect anyone to tackle this but help on compiling would be
> appreciated.
>
>
>
> Dennis Darlandstudent at dennisdarland.com
>
> On 12/31/2013 5:18 PM, Stavros Macrakis wrote:
>
>  modedeclare is useful when the Maxima+Lisp compilers can take advantage
> of a more efficient representation or more efficient operations than those
> used by the interpreter.
>
>  That is the case for some kinds of numbers (though not bfloats) and some
> kinds of arrays.
>
>  There is no way to declare an argument as a string, or a symbol, or as a
> list, etc., because the Maxima+Lisp compilers don't know how to take
> advantage of that information.  You can still compile functions whose
> arguments and internal variables are not modedeclare'd -- it's just that
> the speed-up will be smaller.
>
>  Again, we should be able to help you improve the performance of your
> code if you can give us a *short, self-contained, reproducible *example.
>
>                 -s
>
>
> On Tue, Dec 31, 2013 at 5:51 PM, Dennis Darland - student <
> student at dennisdarland.com> wrote:
>
>> I have functions to which I pass strings. I see no type for them. Does
>> that mean I can not use modedeclare?
>> I saw that you can pass only some functions (instead of all) to compile,
>> does that mean I could compile all except those
>> containing strings and still run the program?  If not there is no use in
>> trying it.
>>
>> There are over 100 programs in my test suite. Only two take anything like
>> this long. They are quite long complex  programs but so are many of the
>> others.
>>
>> I am not very concerned about this as I can use the other languages, and
>> I have learned a lot in the process.
>>
>> Dennis Darland
>> student at dennisdarland.com
>>
>>
>> On 12/31/2013 12:04 PM, Dennis Darland - student wrote:
>>
>>> I've decided to try modedeclare. If I remember correctly, I could not
>>> use bfloat in declare_variable either. I will
>>> try to isolate the changes however. I only have one program to generate
>>> c, c++, Ruby, Maxima or Maple.
>>>
>>> Dennis Darland
>>> student at dennisdarland.com
>>>
>>> On 12/31/2013 11:08 AM, Robert Dodier wrote:
>>>
>>>> On 2013-12-31, Dennis Darland - student <student at dennisdarland.com>
>>>> wrote:
>>>>
>>>>  I do not expect maxima to be comparable to c at number crunching,
>>>>> but there are two examples in my tests that it appears would take over
>>>>> one day to complete using maxima, but take only 4 and 5 seconds
>>>>> respectively in c.
>>>>>
>>>> A major factor is that Maxima is probably doing something much more
>>>> general than necessary. Speeding up the code would require recognizing
>>>> that a special case is possible and then exploiting it. Maxima has some
>>>> machinery for that, but it is clumsy to use and not terribly effective.
>>>> I certainly agree that getting Maxima to run faster is a good idea, but
>>>> at present we (developers) are mostly concerned with trying to get it
>>>> to run correctly first. If you would like to work on speed, though, you
>>>> are more than welcome to do so.
>>>>
>>>> best
>>>>
>>>> Robert Dodier
>>>>