1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id: deriv.m4,v 1.5 1998-04-06 10:50:46 schmidt Exp $ */ |
---|
3 | |
---|
4 | ftestSetNameOfGame( deriv, `" |
---|
5 | Usage: deriv [<options>] [<envSpec>] <f> [<x>] |
---|
6 | calculates df/dx or derivation of canonical form <f> with |
---|
7 | respect to main variable if variable <x> is not specified. |
---|
8 | "'`' ) |
---|
9 | |
---|
10 | //{{{ docu |
---|
11 | // |
---|
12 | // ftestAlgorithm.m4 - ftestAlgorithm test program. |
---|
13 | // |
---|
14 | // To create ftestAlgorithm.cc, run m4 using the ftest_util.m4 library in |
---|
15 | // the following way: |
---|
16 | // |
---|
17 | // m4 ftest_util.m4 ftestAlgorithm.m4 > ftestAlgorithm.cc |
---|
18 | // |
---|
19 | //}}} |
---|
20 | |
---|
21 | ftestPreprocInit(); |
---|
22 | |
---|
23 | ftestGlobalInit(); |
---|
24 | |
---|
25 | // |
---|
26 | // - main program. |
---|
27 | // |
---|
28 | int |
---|
29 | main ( int argc, char ** argv ) |
---|
30 | { |
---|
31 | // initialization |
---|
32 | ftestMainInit(); |
---|
33 | |
---|
34 | // declare input and output variables |
---|
35 | ftestOutVar( CanonicalForm, result ); |
---|
36 | ftestInVar( CanonicalForm, f ); |
---|
37 | ftestInVar( Variable, x ); |
---|
38 | |
---|
39 | // process argument list and set environment |
---|
40 | ftestGetOpts(); |
---|
41 | ftestGetEnv(); |
---|
42 | ftestGetInVar( f ); |
---|
43 | ftestGetInVar( x, Variable() ); |
---|
44 | |
---|
45 | // do the test! |
---|
46 | if ( ftestArgGiven( x ) ) { |
---|
47 | ftestRun( result = f.deriv( x ); ); |
---|
48 | } else { |
---|
49 | ftestRun( result = f.deriv(); ); |
---|
50 | } |
---|
51 | |
---|
52 | // print results |
---|
53 | if ( ftestArgGiven( x ) ) { |
---|
54 | ftestOutput( "df/dx", result ); |
---|
55 | } else { |
---|
56 | ftestOutput( "df", result ); |
---|
57 | } |
---|
58 | |
---|
59 | // clean up |
---|
60 | ftestMainExit(); |
---|
61 | } |
---|