octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with fsolve


From: David Bateman
Subject: Re: Trouble with fsolve
Date: Wed, 19 Oct 2005 16:57:02 +0200
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

Taking this thread to maintainers, as its getting a bit more technical than a normal message to the help list...

John W. Eaton wrote:

On 19-Oct-2005, David Bateman wrote:

| If you want a completely matlab compatiable | fsolve that calculates the function and the jacobian in a single | function, without the mess of caching the results, then you have to | rewrite the underlying fortran code to accept this...

What is wrong with caching the results, provided that you know that
the function and jacobian subroutines will always be called in pairs,
in the same order (I'm not certain that the minpack routines do this,
but I think they might and it seems it would be worth checking)?

jwe


The caching is quite invasive. I attach here the patch I made last year for it so you can see the type of changes I found necessary to get it to work. Note its against an octave version from September 2004 and still includes patches for odessa that has since been dropped from octave, so I don't imagine it will apply cleanly, but the changes shouldn't be enormous. It also doesn't include the changes for multiple argument functions, but those are trivial relative to this part of the patch.

Also read the message at

http://www.octave.org/mailing-lists/octave-maintainers/2004/627

for a description of some of the other issues with caching particular to DASRT and DASSL and issues of consistency of the interface for DASRT. If you can suggest a simpler manner to do the caching then why not...

D.

--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary

2004-08-24 David Bateman <address@hidden>

        * NLEqn-opt.in, DASPK-opts.in, DASRT-opts.in, DASSL-opts.in
        LSODE-opts.in, ODESSA-opts.in: Add "jacobian" option

        * ODESSA-opts.in: Add "inhomogeneity" option

        * DAEFunc.h (*DAERHSFuncCached, *DAEJacFuncCached): Function pointer
        for cached versions of function so that ires and cj args can always
        be passed.
        (DAEFunc::DAEFunc): Correctly initialize cached versions of the
        functions in the constructors
        (function_cached, jacobian_function_cached): Return cached version 
        of user function and jacobian.
        (set_function_cached, set_jacobian_function_cached): Function
        to set the cached versions of the user function and jacobian.
        (fun_cached, jac_cached): The stored cached version of the user
        function and jacobian

        * ODESFunc.h (*ODES_fsub_cached, *ODES_bsub_cached, *ODES_jsub_cached):
        Function pointers for cached versions of functions so that the
        column for the inhomogeneity function can always be passed
        (ODESFunc::ODESFunc): Correctly initialize cached versions of the
        functions in the constructors
        (fsub_function_cached, bsub_function_cached, jsub_function_cached): 
        Return cached version of user function inhomogeneity and jacobian.
        (set_fsub_function_cached, set_bsub_function_cached,
        set_jsub_function_cached): Function to set the cached versions of 
        the user function, inhomogeneity and jacobian.
        (fsub_cached, bsub_cached jsub_cached): The stored cached version of 
        the user function, inhomogeneity  and jacobian

        * DASPK.cc (ddaspk_f): Pass cj argument, select version of user
        function to use
        (ddaspk_j): Select version of user function to use
        (user_fun_cached, user_jac_cached): Cached version of functions
        (do_integrate): Set up either the normal or cached version of 
        functions to use

        * DASRT.cc: Include "lo-ieee.h"
        (user_fsub_cached, user_jsub_cached): New cached versions of user
        function and jacobian 
        (dasrt_f, dasrt_j): Select version of function to use
        (DASRT::integrate (double)): Set up either the normal or cached
        version of the functions to use

        * ODESSA.cc (user_fsub_cached, user_bsub_cached, user_jsub_cached):
        Nes cached versions of the user function, inhomogeneity and jacobian.
        (odessa_f, odessa_j, odessa_b): Select version of function to use
        (ODESSA::integrate (double)): Set up either the normal or cached
        version of the functions to use

        * DASSL.cc: Include "lo-ieee.h"
        (user_fsub_cached, user_jsub_cached): New cached versions of user
        function and jacobian 
        (dassl_f, dassl_j): Select version of function to use
        (DASSL::integrate (double)): Set up either the normal or cached
        version of the functions to use

2004-08-24 David Bateman <address@hidden>

        * DLD-FUNCTIONS/fsolve.cc (fsolve_user_function_cached, 
        fsolve_user_jacobian_cached): New versions of functions to allow
        user function to return jacobian as second return argument
        (Ffsolve): Update docs, allow function handles and inline inputs,
        destory temporary functions on exit.

        * DLD-FUNCTIONS/daspk.cc, DLD-FUNCTION/lsode.cc,
        DLD-FUNCTION/dasrt.cc, DLD-FUNCTION/dassl.cc,
        DLD-FUNCTION/odessa.cc: ditto.

Attachment: patch.handle2-2.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]