Information Technology Reference
In-Depth Information
the nonlinear equation solver base class and its generic (say) solve method are
seen. This way of programming hides details in numerical algorithms and reduces
complexity. This is of course very important for the reliability of large numerical
codes.
6.5.3
Design of a Numerical Integration Hierarchy
Class Integrate is the base class of our numerical integration methods hierarchy.
Specific integration rules are implemented as subclasses. Common to all methods
are the integration limits and the function to be integrated. Other parameters can
differ among the subclasses. The idea of an init method with differing argument
lists is not good. We should look for a strategy that handles input data and the ini-
tialization of integration objects in the same way for all subclasses of Integration .
To achieve a unified treatment of input data for all subclasses, it may be con-
venient to collect all the parameters in a so-called parameter class , here called
Integration prm :
class Integration_prm
data:
a, b, f
npoints
method
tolerance
...
methods:
constructor()
create()
default()
read()
write()
This outline of the class shows some possible parameters and (at least) five methods:
- constructor for creating and initializing an object
- create for creating an integration rule object (as a subclass instance in the
Integration hierarchy), based on the data in this Integration prm instance
- default for assigning appropriate default values to data members
- read for reading values from some kind of user interface
- write for dumping the contents of the parameters (for a check)
Observe that our pseudo code does not coincide with a particular programming
language. 20
The base class Integration for all integration methods typically has a construc-
tor that takes the bag of parameters (i.e., an Integration prm object) and stores it
internally in the class. The base class also offers access to the integrate method
20 For example, the constructor method will have different names in different languages
( Integration prm in Java and C
CC
, init in Python).
Search WWH ::




Custom Search