Abstract
Polynomials, such as a 0 + a 1 x + a 2x2 + ... + a n x n, have a dual nature. On one hand, you can regard them as functions P(x). On the other hand, you can subject them to algebraic operations such as addition and subtraction, as though they were vectors with components, a 0 , a 1,a 2, ..., a n . Designing a data structure for them is complicated by this duality of roles that it must support. Section 6.1 defines classes Polynom for double and complex polynomials. Since they’re derived from the corresponding MSP Vector classes, they inherit some structure—in particular, their data components and some logical functions. But new restrictions must be imposed: Subscripts must start at 0 and there may be no trailing zero coefficients. Thus, some Vector operations must be modified when applied to Polynom objects. Some new operations are added—for instance, polynomial multiplication and differentiation—which don’t make sense for vectors in general. Finally, to reflect the functional nature of a polynomial, the C++ () operator is overloaded, so that P(x) makes sense when P is a Polynom object and x a scalar. These algebraic parts of the Polynom class definition are described in detail in Section 6.2. That section concludes with a detailed example, which verifies calculus results for Legendre polynomials.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 1999 Springer Science+Business Media New York
About this chapter
Cite this chapter
Smith, J.T. (1999). Polynomial Classes. In: C++ Toolkit for Engineers and Scientists. Springer, New York, NY. https://doi.org/10.1007/978-1-4612-1474-8_6
Download citation
DOI: https://doi.org/10.1007/978-1-4612-1474-8_6
Publisher Name: Springer, New York, NY
Print ISBN: 978-0-387-98797-2
Online ISBN: 978-1-4612-1474-8
eBook Packages: Springer Book Archive