_orthogonal.pyi 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. from typing import (
  2. Any,
  3. Literal,
  4. Optional,
  5. overload,
  6. )
  7. from collections.abc import Callable
  8. import numpy as np
  9. _IntegerType = int | np.integer
  10. _FloatingType = float | np.floating
  11. _PointsAndWeights = tuple[np.ndarray, np.ndarray]
  12. _PointsAndWeightsAndMu = tuple[np.ndarray, np.ndarray, float]
  13. _ArrayLike0D = bool | int | float | complex | str | bytes | np.generic
  14. __all__ = [
  15. 'legendre',
  16. 'chebyt',
  17. 'chebyu',
  18. 'chebyc',
  19. 'chebys',
  20. 'jacobi',
  21. 'laguerre',
  22. 'genlaguerre',
  23. 'hermite',
  24. 'hermitenorm',
  25. 'gegenbauer',
  26. 'sh_legendre',
  27. 'sh_chebyt',
  28. 'sh_chebyu',
  29. 'sh_jacobi',
  30. 'roots_legendre',
  31. 'roots_chebyt',
  32. 'roots_chebyu',
  33. 'roots_chebyc',
  34. 'roots_chebys',
  35. 'roots_jacobi',
  36. 'roots_laguerre',
  37. 'roots_genlaguerre',
  38. 'roots_hermite',
  39. 'roots_hermitenorm',
  40. 'roots_gegenbauer',
  41. 'roots_sh_legendre',
  42. 'roots_sh_chebyt',
  43. 'roots_sh_chebyu',
  44. 'roots_sh_jacobi',
  45. ]
  46. @overload
  47. def roots_jacobi(
  48. n: _IntegerType,
  49. alpha: _FloatingType,
  50. beta: _FloatingType,
  51. ) -> _PointsAndWeights: ...
  52. @overload
  53. def roots_jacobi(
  54. n: _IntegerType,
  55. alpha: _FloatingType,
  56. beta: _FloatingType,
  57. mu: Literal[False],
  58. ) -> _PointsAndWeights: ...
  59. @overload
  60. def roots_jacobi(
  61. n: _IntegerType,
  62. alpha: _FloatingType,
  63. beta: _FloatingType,
  64. mu: Literal[True],
  65. ) -> _PointsAndWeightsAndMu: ...
  66. @overload
  67. def roots_sh_jacobi(
  68. n: _IntegerType,
  69. p1: _FloatingType,
  70. q1: _FloatingType,
  71. ) -> _PointsAndWeights: ...
  72. @overload
  73. def roots_sh_jacobi(
  74. n: _IntegerType,
  75. p1: _FloatingType,
  76. q1: _FloatingType,
  77. mu: Literal[False],
  78. ) -> _PointsAndWeights: ...
  79. @overload
  80. def roots_sh_jacobi(
  81. n: _IntegerType,
  82. p1: _FloatingType,
  83. q1: _FloatingType,
  84. mu: Literal[True],
  85. ) -> _PointsAndWeightsAndMu: ...
  86. @overload
  87. def roots_genlaguerre(
  88. n: _IntegerType,
  89. alpha: _FloatingType,
  90. ) -> _PointsAndWeights: ...
  91. @overload
  92. def roots_genlaguerre(
  93. n: _IntegerType,
  94. alpha: _FloatingType,
  95. mu: Literal[False],
  96. ) -> _PointsAndWeights: ...
  97. @overload
  98. def roots_genlaguerre(
  99. n: _IntegerType,
  100. alpha: _FloatingType,
  101. mu: Literal[True],
  102. ) -> _PointsAndWeightsAndMu: ...
  103. @overload
  104. def roots_laguerre(n: _IntegerType) -> _PointsAndWeights: ...
  105. @overload
  106. def roots_laguerre(
  107. n: _IntegerType,
  108. mu: Literal[False],
  109. ) -> _PointsAndWeights: ...
  110. @overload
  111. def roots_laguerre(
  112. n: _IntegerType,
  113. mu: Literal[True],
  114. ) -> _PointsAndWeightsAndMu: ...
  115. @overload
  116. def roots_hermite(n: _IntegerType) -> _PointsAndWeights: ...
  117. @overload
  118. def roots_hermite(
  119. n: _IntegerType,
  120. mu: Literal[False],
  121. ) -> _PointsAndWeights: ...
  122. @overload
  123. def roots_hermite(
  124. n: _IntegerType,
  125. mu: Literal[True],
  126. ) -> _PointsAndWeightsAndMu: ...
  127. @overload
  128. def roots_hermitenorm(n: _IntegerType) -> _PointsAndWeights: ...
  129. @overload
  130. def roots_hermitenorm(
  131. n: _IntegerType,
  132. mu: Literal[False],
  133. ) -> _PointsAndWeights: ...
  134. @overload
  135. def roots_hermitenorm(
  136. n: _IntegerType,
  137. mu: Literal[True],
  138. ) -> _PointsAndWeightsAndMu: ...
  139. @overload
  140. def roots_gegenbauer(
  141. n: _IntegerType,
  142. alpha: _FloatingType,
  143. ) -> _PointsAndWeights: ...
  144. @overload
  145. def roots_gegenbauer(
  146. n: _IntegerType,
  147. alpha: _FloatingType,
  148. mu: Literal[False],
  149. ) -> _PointsAndWeights: ...
  150. @overload
  151. def roots_gegenbauer(
  152. n: _IntegerType,
  153. alpha: _FloatingType,
  154. mu: Literal[True],
  155. ) -> _PointsAndWeightsAndMu: ...
  156. @overload
  157. def roots_chebyt(n: _IntegerType) -> _PointsAndWeights: ...
  158. @overload
  159. def roots_chebyt(
  160. n: _IntegerType,
  161. mu: Literal[False],
  162. ) -> _PointsAndWeights: ...
  163. @overload
  164. def roots_chebyt(
  165. n: _IntegerType,
  166. mu: Literal[True],
  167. ) -> _PointsAndWeightsAndMu: ...
  168. @overload
  169. def roots_chebyu(n: _IntegerType) -> _PointsAndWeights: ...
  170. @overload
  171. def roots_chebyu(
  172. n: _IntegerType,
  173. mu: Literal[False],
  174. ) -> _PointsAndWeights: ...
  175. @overload
  176. def roots_chebyu(
  177. n: _IntegerType,
  178. mu: Literal[True],
  179. ) -> _PointsAndWeightsAndMu: ...
  180. @overload
  181. def roots_chebyc(n: _IntegerType) -> _PointsAndWeights: ...
  182. @overload
  183. def roots_chebyc(
  184. n: _IntegerType,
  185. mu: Literal[False],
  186. ) -> _PointsAndWeights: ...
  187. @overload
  188. def roots_chebyc(
  189. n: _IntegerType,
  190. mu: Literal[True],
  191. ) -> _PointsAndWeightsAndMu: ...
  192. @overload
  193. def roots_chebys(n: _IntegerType) -> _PointsAndWeights: ...
  194. @overload
  195. def roots_chebys(
  196. n: _IntegerType,
  197. mu: Literal[False],
  198. ) -> _PointsAndWeights: ...
  199. @overload
  200. def roots_chebys(
  201. n: _IntegerType,
  202. mu: Literal[True],
  203. ) -> _PointsAndWeightsAndMu: ...
  204. @overload
  205. def roots_sh_chebyt(n: _IntegerType) -> _PointsAndWeights: ...
  206. @overload
  207. def roots_sh_chebyt(
  208. n: _IntegerType,
  209. mu: Literal[False],
  210. ) -> _PointsAndWeights: ...
  211. @overload
  212. def roots_sh_chebyt(
  213. n: _IntegerType,
  214. mu: Literal[True],
  215. ) -> _PointsAndWeightsAndMu: ...
  216. @overload
  217. def roots_sh_chebyu(n: _IntegerType) -> _PointsAndWeights: ...
  218. @overload
  219. def roots_sh_chebyu(
  220. n: _IntegerType,
  221. mu: Literal[False],
  222. ) -> _PointsAndWeights: ...
  223. @overload
  224. def roots_sh_chebyu(
  225. n: _IntegerType,
  226. mu: Literal[True],
  227. ) -> _PointsAndWeightsAndMu: ...
  228. @overload
  229. def roots_legendre(n: _IntegerType) -> _PointsAndWeights: ...
  230. @overload
  231. def roots_legendre(
  232. n: _IntegerType,
  233. mu: Literal[False],
  234. ) -> _PointsAndWeights: ...
  235. @overload
  236. def roots_legendre(
  237. n: _IntegerType,
  238. mu: Literal[True],
  239. ) -> _PointsAndWeightsAndMu: ...
  240. @overload
  241. def roots_sh_legendre(n: _IntegerType) -> _PointsAndWeights: ...
  242. @overload
  243. def roots_sh_legendre(
  244. n: _IntegerType,
  245. mu: Literal[False],
  246. ) -> _PointsAndWeights: ...
  247. @overload
  248. def roots_sh_legendre(
  249. n: _IntegerType,
  250. mu: Literal[True],
  251. ) -> _PointsAndWeightsAndMu: ...
  252. class orthopoly1d(np.poly1d):
  253. def __init__(
  254. self,
  255. roots: np.typing.ArrayLike,
  256. weights: np.typing.ArrayLike | None,
  257. hn: float = ...,
  258. kn: float = ...,
  259. wfunc = Optional[Callable[[float], float]], # noqa: UP045
  260. limits = tuple[float, float] | None,
  261. monic: bool = ...,
  262. eval_func: np.ufunc = ...,
  263. ) -> None: ...
  264. @property
  265. def limits(self) -> tuple[float, float]: ...
  266. def weight_func(self, x: float) -> float: ...
  267. @overload
  268. def __call__(self, x: _ArrayLike0D) -> Any: ...
  269. @overload
  270. def __call__(self, x: np.poly1d) -> np.poly1d: ... # type: ignore[overload-overlap]
  271. @overload
  272. def __call__(self, x: np.typing.ArrayLike) -> np.ndarray: ...
  273. def legendre(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  274. def chebyt(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  275. def chebyu(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  276. def chebyc(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  277. def chebys(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  278. def jacobi(
  279. n: _IntegerType,
  280. alpha: _FloatingType,
  281. beta: _FloatingType,
  282. monic: bool = ...,
  283. ) -> orthopoly1d: ...
  284. def laguerre(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  285. def genlaguerre(
  286. n: _IntegerType,
  287. alpha: _FloatingType,
  288. monic: bool = ...,
  289. ) -> orthopoly1d: ...
  290. def hermite(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  291. def hermitenorm(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  292. def gegenbauer(
  293. n: _IntegerType,
  294. alpha: _FloatingType,
  295. monic: bool = ...,
  296. ) -> orthopoly1d: ...
  297. def sh_legendre(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  298. def sh_chebyt(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  299. def sh_chebyu(n: _IntegerType, monic: bool = ...) -> orthopoly1d: ...
  300. def sh_jacobi(
  301. n: _IntegerType,
  302. p: _FloatingType,
  303. q: _FloatingType,
  304. monic: bool = ...,
  305. ) -> orthopoly1d: ...
  306. # These functions are not public, but still need stubs because they
  307. # get checked in the tests.
  308. def _roots_hermite_asy(n: _IntegerType) -> _PointsAndWeights: ...