You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

359 lines
12 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. <HTML>
  2. <HEAD>
  3. <!-- Created by texi2html 1.56k from cln.texi on 19 May 2000 -->
  4. <TITLE>CLN, a Class Library for Numbers - 9. Univariate polynomials</TITLE>
  5. </HEAD>
  6. <BODY>
  7. Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_8.html">previous</A>, <A HREF="cln_10.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
  8. <P><HR><P>
  9. <H1><A NAME="SEC55" HREF="cln_toc.html#TOC55">9. Univariate polynomials</A></H1>
  10. <P>
  11. <A NAME="IDX280"></A>
  12. <A NAME="IDX281"></A>
  13. <H2><A NAME="SEC56" HREF="cln_toc.html#TOC56">9.1 Univariate polynomial rings</A></H2>
  14. <P>
  15. CLN implements univariate polynomials (polynomials in one variable) over an
  16. arbitrary ring. The indeterminate variable may be either unnamed (and will be
  17. printed according to <CODE>cl_default_print_flags.univpoly_varname</CODE>, which
  18. defaults to <SAMP>`x'</SAMP>) or carry a given name. The base ring and the
  19. indeterminate are explicitly part of every polynomial. CLN doesn't allow you to
  20. (accidentally) mix elements of different polynomial rings, e.g.
  21. <CODE>(a^2+1) * (b^3-1)</CODE> will result in a runtime error. (Ideally this should
  22. return a multivariate polynomial, but they are not yet implemented in CLN.)
  23. <P>
  24. The classes of univariate polynomial rings are
  25. <PRE>
  26. Ring
  27. cl_ring
  28. &#60;cl_ring.h&#62;
  29. |
  30. |
  31. Univariate polynomial ring
  32. cl_univpoly_ring
  33. &#60;cl_univpoly.h&#62;
  34. |
  35. +----------------+-------------------+
  36. | | |
  37. Complex polynomial ring | Modular integer polynomial ring
  38. cl_univpoly_complex_ring | cl_univpoly_modint_ring
  39. &#60;cl_univpoly_complex.h&#62; | &#60;cl_univpoly_modint.h&#62;
  40. |
  41. +----------------+
  42. | |
  43. Real polynomial ring |
  44. cl_univpoly_real_ring |
  45. &#60;cl_univpoly_real.h&#62; |
  46. |
  47. +----------------+
  48. | |
  49. Rational polynomial ring |
  50. cl_univpoly_rational_ring |
  51. &#60;cl_univpoly_rational.h&#62; |
  52. |
  53. +----------------+
  54. |
  55. Integer polynomial ring
  56. cl_univpoly_integer_ring
  57. &#60;cl_univpoly_integer.h&#62;
  58. </PRE>
  59. <P>
  60. and the corresponding classes of univariate polynomials are
  61. <PRE>
  62. Univariate polynomial
  63. cl_UP
  64. &#60;cl_univpoly.h&#62;
  65. |
  66. +----------------+-------------------+
  67. | | |
  68. Complex polynomial | Modular integer polynomial
  69. cl_UP_N | cl_UP_MI
  70. &#60;cl_univpoly_complex.h&#62; | &#60;cl_univpoly_modint.h&#62;
  71. |
  72. +----------------+
  73. | |
  74. Real polynomial |
  75. cl_UP_R |
  76. &#60;cl_univpoly_real.h&#62; |
  77. |
  78. +----------------+
  79. | |
  80. Rational polynomial |
  81. cl_UP_RA |
  82. &#60;cl_univpoly_rational.h&#62; |
  83. |
  84. +----------------+
  85. |
  86. Integer polynomial
  87. cl_UP_I
  88. &#60;cl_univpoly_integer.h&#62;
  89. </PRE>
  90. <P>
  91. Univariate polynomial rings are constructed using the functions
  92. <DL COMPACT>
  93. <DT><CODE>cl_univpoly_ring cl_find_univpoly_ring (const cl_ring&#38; R)</CODE>
  94. <DD>
  95. <DT><CODE>cl_univpoly_ring cl_find_univpoly_ring (const cl_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  96. <DD>
  97. This function returns the polynomial ring <SAMP>`R[X]'</SAMP>, unnamed or named.
  98. <CODE>R</CODE> may be an arbitrary ring. This function takes care of finding out
  99. about special cases of <CODE>R</CODE>, such as the rings of complex numbers,
  100. real numbers, rational numbers, integers, or modular integer rings.
  101. There is a cache table of rings, indexed by <CODE>R</CODE> and <CODE>varname</CODE>.
  102. This ensures that two calls of this function with the same arguments will
  103. return the same polynomial ring.
  104. <DT><CODE>cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring&#38; R)</CODE>
  105. <DD>
  106. <A NAME="IDX282"></A>
  107. <DT><CODE>cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  108. <DD>
  109. <DT><CODE>cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring&#38; R)</CODE>
  110. <DD>
  111. <DT><CODE>cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  112. <DD>
  113. <DT><CODE>cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring&#38; R)</CODE>
  114. <DD>
  115. <DT><CODE>cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  116. <DD>
  117. <DT><CODE>cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring&#38; R)</CODE>
  118. <DD>
  119. <DT><CODE>cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  120. <DD>
  121. <DT><CODE>cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring&#38; R)</CODE>
  122. <DD>
  123. <DT><CODE>cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring&#38; R, const cl_symbol&#38; varname)</CODE>
  124. <DD>
  125. These functions are equivalent to the general <CODE>cl_find_univpoly_ring</CODE>,
  126. only the return type is more specific, according to the base ring's type.
  127. </DL>
  128. <H2><A NAME="SEC57" HREF="cln_toc.html#TOC57">9.2 Functions on univariate polynomials</A></H2>
  129. <P>
  130. Given a univariate polynomial ring <CODE>R</CODE>, the following members can be used.
  131. <DL COMPACT>
  132. <DT><CODE>cl_ring R-&#62;basering()</CODE>
  133. <DD>
  134. <A NAME="IDX283"></A>
  135. This returns the base ring, as passed to <SAMP>`cl_find_univpoly_ring'</SAMP>.
  136. <DT><CODE>cl_UP R-&#62;zero()</CODE>
  137. <DD>
  138. <A NAME="IDX284"></A>
  139. This returns <CODE>0 in R</CODE>, a polynomial of degree -1.
  140. <DT><CODE>cl_UP R-&#62;one()</CODE>
  141. <DD>
  142. <A NAME="IDX285"></A>
  143. This returns <CODE>1 in R</CODE>, a polynomial of degree &#60;= 0.
  144. <DT><CODE>cl_UP R-&#62;canonhom (const cl_I&#38; x)</CODE>
  145. <DD>
  146. <A NAME="IDX286"></A>
  147. This returns <CODE>x in R</CODE>, a polynomial of degree &#60;= 0.
  148. <DT><CODE>cl_UP R-&#62;monomial (const cl_ring_element&#38; x, uintL e)</CODE>
  149. <DD>
  150. <A NAME="IDX287"></A>
  151. This returns a sparse polynomial: <CODE>x * X^e</CODE>, where <CODE>X</CODE> is the
  152. indeterminate.
  153. <DT><CODE>cl_UP R-&#62;create (sintL degree)</CODE>
  154. <DD>
  155. <A NAME="IDX288"></A>
  156. Creates a new polynomial with a given degree. The zero polynomial has degree
  157. <CODE>-1</CODE>. After creating the polynomial, you should put in the coefficients,
  158. using the <CODE>set_coeff</CODE> member function, and then call the <CODE>finalize</CODE>
  159. member function.
  160. </DL>
  161. <P>
  162. The following are the only destructive operations on univariate polynomials.
  163. <DL COMPACT>
  164. <DT><CODE>void set_coeff (cl_UP&#38; x, uintL index, const cl_ring_element&#38; y)</CODE>
  165. <DD>
  166. <A NAME="IDX289"></A>
  167. This changes the coefficient of <CODE>X^index</CODE> in <CODE>x</CODE> to be <CODE>y</CODE>.
  168. After changing a polynomial and before applying any "normal" operation on it,
  169. you should call its <CODE>finalize</CODE> member function.
  170. <DT><CODE>void finalize (cl_UP&#38; x)</CODE>
  171. <DD>
  172. <A NAME="IDX290"></A>
  173. This function marks the endpoint of destructive modifications of a polynomial.
  174. It normalizes the internal representation so that subsequent computations have
  175. less overhead. Doing normal computations on unnormalized polynomials may
  176. produce wrong results or crash the program.
  177. </DL>
  178. <P>
  179. The following operations are defined on univariate polynomials.
  180. <DL COMPACT>
  181. <DT><CODE>cl_univpoly_ring x.ring ()</CODE>
  182. <DD>
  183. <A NAME="IDX291"></A>
  184. Returns the ring to which the univariate polynomial <CODE>x</CODE> belongs.
  185. <DT><CODE>cl_UP operator+ (const cl_UP&#38;, const cl_UP&#38;)</CODE>
  186. <DD>
  187. <A NAME="IDX292"></A>
  188. Returns the sum of two univariate polynomials.
  189. <DT><CODE>cl_UP operator- (const cl_UP&#38;, const cl_UP&#38;)</CODE>
  190. <DD>
  191. <A NAME="IDX293"></A>
  192. Returns the difference of two univariate polynomials.
  193. <DT><CODE>cl_UP operator- (const cl_UP&#38;)</CODE>
  194. <DD>
  195. Returns the negative of a univariate polynomial.
  196. <DT><CODE>cl_UP operator* (const cl_UP&#38;, const cl_UP&#38;)</CODE>
  197. <DD>
  198. <A NAME="IDX294"></A>
  199. Returns the product of two univariate polynomials. One of the arguments may
  200. also be a plain integer or an element of the base ring.
  201. <DT><CODE>cl_UP square (const cl_UP&#38;)</CODE>
  202. <DD>
  203. <A NAME="IDX295"></A>
  204. Returns the square of a univariate polynomial.
  205. <DT><CODE>cl_UP expt_pos (const cl_UP&#38; x, const cl_I&#38; y)</CODE>
  206. <DD>
  207. <A NAME="IDX296"></A>
  208. <CODE>y</CODE> must be &#62; 0. Returns <CODE>x^y</CODE>.
  209. <DT><CODE>bool operator== (const cl_UP&#38;, const cl_UP&#38;)</CODE>
  210. <DD>
  211. <A NAME="IDX297"></A>
  212. <DT><CODE>bool operator!= (const cl_UP&#38;, const cl_UP&#38;)</CODE>
  213. <DD>
  214. <A NAME="IDX298"></A>
  215. Compares two univariate polynomials, belonging to the same univariate
  216. polynomial ring, for equality.
  217. <DT><CODE>cl_boolean zerop (const cl_UP&#38; x)</CODE>
  218. <DD>
  219. <A NAME="IDX299"></A>
  220. Returns true if <CODE>x</CODE> is <CODE>0 in R</CODE>.
  221. <DT><CODE>sintL degree (const cl_UP&#38; x)</CODE>
  222. <DD>
  223. <A NAME="IDX300"></A>
  224. Returns the degree of the polynomial. The zero polynomial has degree <CODE>-1</CODE>.
  225. <DT><CODE>cl_ring_element coeff (const cl_UP&#38; x, uintL index)</CODE>
  226. <DD>
  227. <A NAME="IDX301"></A>
  228. Returns the coefficient of <CODE>X^index</CODE> in the polynomial <CODE>x</CODE>.
  229. <DT><CODE>cl_ring_element x (const cl_ring_element&#38; y)</CODE>
  230. <DD>
  231. <A NAME="IDX302"></A>
  232. Evaluation: If <CODE>x</CODE> is a polynomial and <CODE>y</CODE> belongs to the base ring,
  233. then <SAMP>`x(y)'</SAMP> returns the value of the substitution of <CODE>y</CODE> into
  234. <CODE>x</CODE>.
  235. <DT><CODE>cl_UP deriv (const cl_UP&#38; x)</CODE>
  236. <DD>
  237. <A NAME="IDX303"></A>
  238. Returns the derivative of the polynomial <CODE>x</CODE> with respect to the
  239. indeterminate <CODE>X</CODE>.
  240. </DL>
  241. <P>
  242. The following output functions are defined (see also the chapter on
  243. input/output).
  244. <DL COMPACT>
  245. <DT><CODE>void fprint (cl_ostream stream, const cl_UP&#38; x)</CODE>
  246. <DD>
  247. <A NAME="IDX304"></A>
  248. <DT><CODE>cl_ostream operator&#60;&#60; (cl_ostream stream, const cl_UP&#38; x)</CODE>
  249. <DD>
  250. <A NAME="IDX305"></A>
  251. Prints the univariate polynomial <CODE>x</CODE> on the <CODE>stream</CODE>. The output may
  252. depend on the global printer settings in the variable
  253. <CODE>cl_default_print_flags</CODE>.
  254. </DL>
  255. <H2><A NAME="SEC58" HREF="cln_toc.html#TOC58">9.3 Special polynomials</A></H2>
  256. <P>
  257. The following functions return special polynomials.
  258. <DL COMPACT>
  259. <DT><CODE>cl_UP_I cl_tschebychev (sintL n)</CODE>
  260. <DD>
  261. <A NAME="IDX306"></A>
  262. <A NAME="IDX307"></A>
  263. Returns the n-th Tchebychev polynomial (n &#62;= 0).
  264. <DT><CODE>cl_UP_I cl_hermite (sintL n)</CODE>
  265. <DD>
  266. <A NAME="IDX308"></A>
  267. <A NAME="IDX309"></A>
  268. Returns the n-th Hermite polynomial (n &#62;= 0).
  269. <DT><CODE>cl_UP_RA cl_legendre (sintL n)</CODE>
  270. <DD>
  271. <A NAME="IDX310"></A>
  272. <A NAME="IDX311"></A>
  273. Returns the n-th Legendre polynomial (n &#62;= 0).
  274. <DT><CODE>cl_UP_I cl_laguerre (sintL n)</CODE>
  275. <DD>
  276. <A NAME="IDX312"></A>
  277. <A NAME="IDX313"></A>
  278. Returns the n-th Laguerre polynomial (n &#62;= 0).
  279. </DL>
  280. <P>
  281. Information how to derive the differential equation satisfied by each
  282. of these polynomials from their definition can be found in the
  283. <CODE>doc/polynomial/</CODE> directory.
  284. <P><HR><P>
  285. Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_8.html">previous</A>, <A HREF="cln_10.html">next</A>, <A HREF="cln_13.html">last</A> section, <A HREF="cln_toc.html">table of contents</A>.
  286. </BODY>
  287. </HTML>