help-octave
[Top][All Lists]
Advanced

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

Re: Bi variate to mono variate functions


From: David Bateman
Subject: Re: Bi variate to mono variate functions
Date: Wed, 29 Mar 2006 17:32:53 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.5.20060mdk (X11/20050322)

Anglade Pierre-Matthieu wrote:

>Hi all,
>
>I've some kind of very dumb problem with octave's synthax. probably
>because I don't mastered it at all I'm not able to solve the following
>problem:
>
>I have a function which look like having two variables but have in
>fact a single one and I can't find the way to tell this to octave.
>Here is the function (LateX form):
>f(x) = \int_a^b g(x,y) dy
>
>In order to compute that I first define g(x,y)
>Then I'd like to use the "quad" function to get the integral over the
>range o "y" values.
>but I d'ont find the way to tell quad that my function is now g(x,y)
>but with a fixed "x" value.
>
>Obviously I need to do this on the fly ( i.e. I can't define a
>function for each value of x) because otherwise it would take too long
>to get a complete plot...
>
>Could anybody kindly help me?
>
>
>--
>Pierre-Matthieu Anglade
>
>  
>
There is currently no way to do this, though funnily I just implemented
it with the attached patch I'm working on in another thread about
importing octave-forge changes into octave. So if you want to rebuild
octave the you have the patch :-)

D.

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

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** src/DLD-FUNCTIONS/quad.cc.~1.24.~   2005-04-26 21:24:35.000000000 +0200
--- src/DLD-FUNCTIONS/quad.cc   2006-03-29 14:40:47.698493208 +0200
***************
*** 52,57 ****
--- 52,60 ----
  // Global pointer for user defined function required by quadrature functions.
  static octave_function *quad_fcn;
  
+ // Extra pass-through arguments for the user defined function.
+ static octave_value_list quad_extra_args;
+ 
  // Have we warned about imaginary values returned from user function?
  static bool warned_imaginary = false;
  
***************
*** 66,71 ****
--- 69,77 ----
    octave_value_list args;
    args(0) = x;
  
+   // Append the pass-through arguments at the end.
+   args.append (quad_extra_args);
+ 
    if (quad_fcn)
      {
        octave_value_list tmp = quad_fcn->do_multi_index_op (1, args);
***************
*** 131,137 ****
  
  DEFUN_DLD (quad, args, nargout,
    "-*- texinfo -*-\n\
! @deftypefn {Loadable Function} address@hidden, @var{ier}, @var{nfun}, 
@var{err}] =} quad (@var{f}, @var{a}, @var{b}, @var{tol}, @var{sing})\n\
  Integrate a nonlinear function of one variable using Quadpack.\n\
  The first argument is the name of the  function, the function handle or\n\
  the inline function to call to compute the value of the integrand.  It\n\
--- 137,143 ----
  
  DEFUN_DLD (quad, args, nargout,
    "-*- texinfo -*-\n\
! @deftypefn {Loadable Function} address@hidden, @var{ier}, @var{nfun}, 
@var{err}] =} quad (@var{f}, @var{a}, @var{b}, @var{tol}, @var{sing}, 
@dots{})\n\
  Integrate a nonlinear function of one variable using Quadpack.\n\
  The first argument is the name of the  function, the function handle or\n\
  the inline function to call to compute the value of the integrand.  It\n\
***************
*** 164,170 ****
  solution.\n\
  \n\
  You can use the function @code{quad_options} to set optional\n\
! parameters for @code{quad}.\n\
  @end deftypefn")
  {
    octave_value_list retval;
--- 170,177 ----
  solution.\n\
  \n\
  You can use the function @code{quad_options} to set optional\n\
! parameters for @code{quad}. Additional arguments to @code{quad}\n\
! are passed to the user function.\n\
  @end deftypefn")
  {
    octave_value_list retval;
***************
*** 183,189 ****
  
    int nargin = args.length ();
  
!   if (nargin > 2 && nargin < 6 && nargout < 5)
      {
        if (args(0).is_function_handle () || args(0).is_inline_function ())
        quad_fcn = args(0).function_value ();
--- 190,196 ----
  
    int nargin = args.length ();
  
!   if (nargin > 2 && nargout < 5)
      {
        if (args(0).is_function_handle () || args(0).is_inline_function ())
        quad_fcn = args(0).function_value ();
***************
*** 241,257 ****
  
        switch (nargin)
        {
!       case 5:
!         if (indefinite)
!           QUAD_ABORT1 ("singularities not allowed on infinite intervals");
  
!         have_sing = true;
  
!         sing = ColumnVector (args(4).vector_value ());
  
!         if (error_state)
!           QUAD_ABORT1 ("expecting vector of singularities as fourth 
argument");
  
        case 4:
          tol = ColumnVector (args(3).vector_value ());
  
--- 248,273 ----
  
        switch (nargin)
        {
!       default:
!         // Save the optional pass-through arguments.
!         int nextra = nargin - 5;
!         quad_extra_args.resize (nextra);
!         for (int i = 0;  i < nextra;  i++)
!           quad_extra_args (i) = args (5 + i);
  
!       case 5:
!         if (! args(4).is_empty ())
!           {
!             if (indefinite)
!               QUAD_ABORT1 ("singularities not allowed on infinite intervals");
  
!             have_sing = true;
  
!             sing = ColumnVector (args(4).vector_value ());
  
+             if (error_state)
+               QUAD_ABORT1 ("expecting vector of singularities as fourth 
argument");
+           }
        case 4:
          tol = ColumnVector (args(3).vector_value ());
  
***************
*** 294,303 ****
                }
            }
          break;
- 
-       default:
-         panic_impossible ();
-         break;
        }
  
        retval(3) = abserr;
--- 310,315 ----

reply via email to

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