List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] declaration of procedure-type
| [MUG] declaration of procedure-type |
|
Author: Stefano Sofia
Posted: Mon, 06 May 2002 17:08:09 +0100
|
>> From: Stefano Sofia "stefano.sofia"
Hello everybody!
Here there is a question about declaration of procedure-type.
I hope my terminology is correct and you can understand my problem.
Two of the arguments (f1 and f2) of a procedure called "bif" are
procedure-type:
> bif:=proc(f1::procedure,f2::procedure,nr::procedure,initial::numeric);
> global s;
> local h_old,f_old,h_new,f_new,count,tdlist,dlist;
...
> end:
f1 and f2 are defined outside the bif procedure, for example f1 could be
defined as
> f1:=(x)->0.3*x-(0.5)*arctan(3.2*x)+0.1;
and f2 as
> f2:=(y)->y + 0.3*arctan(3.2*y);
Inside the "bif" procedure, and in particular within a "for" loop of n
steps I evaluate f1(x_t), with t=1..n, x_t different at each step. Let us call
f1(x_t) alpha_t; then, always for each iteration of the loop I need to create
a new procedure-type f3 defined as f2-alpha_t.
How can I define f3 within the bif procedure (not as external argument)? I'm
not able to declare f3 in a correct way.
thank you in advance for the eventual help
Stefano
|
| [MUG] Re: declaration of procedure-type |
|
Author: Robert Israel
Posted: Thu, 9 May 2002 01:13:10 -0700 (
|
>> From: Robert Israel "israel"
Perhaps I don't understand your problem, but it seems to me that you
may be missing something fundamental. You don't need to declare the type
of a variable that you want to be a procedure. Any name can be assigned
a value of any type, whether procedure or something else. Normally the
only effect of declaring the type of a formal parameter of a procedure is
to produce an error if the procedure is called with an actual parameter
that is not of this type.
As for "f3 defined as f2-alpha_t": if f2 and alpha_t are functions you've
already defined, you can simply say f3:= f2 - alpha_t, and then you can
treat f3 as if it were a function: f3(v) will be f2(v) - alpha_t(v).
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
On Mon, 6 May 2002, Stefano Sofia wrote:
> Hello everybody!
> Here there is a question about declaration of procedure-type.
> I hope my terminology is correct and you can understand my problem.
>
> Two of the arguments (f1 and f2) of a procedure called "bif" are
> procedure-type:
>
> > bif:=proc(f1::procedure,f2::procedure,nr::procedure,initial::numeric);
> > global s;
> > local h_old,f_old,h_new,f_new,count,tdlist,dlist;
> ...
> > end:
>
>
> f1 and f2 are defined outside the bif procedure, for example f1 could be
> defined as
> > f1:=(x)->0.3*x-(0.5)*arctan(3.2*x)+0.1;
> and f2 as
> > f2:=(y)->y + 0.3*arctan(3.2*y);
>
> Inside the "bif" procedure, and in particular within a "for" loop of n
> steps I evaluate f1(x_t), with t=1..n, x_t different at each step. Let us call
> f1(x_t) alpha_t; then, always for each iteration of the loop I need to create
> a new procedure-type f3 defined as f2-alpha_t.
> How can I define f3 within the bif procedure (not as external argument)? I'm
> not able to declare f3 in a correct way.
|
Previous by date: [MUG] PostScript Bug in Maple 6.02a Win 2k Pro, Jeff Wright
Next by date: [MUG] Reading the Date from a txt File, Juan Navarro
Previous thread: [MUG] a bug or a feature?, Rouben Rostamian
Next thread: [MUG] Reading the Date from a txt File, Juan Navarro
|