lapack.py 15 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. """
  2. Low-level LAPACK functions (:mod:`scipy.linalg.lapack`)
  3. =======================================================
  4. This module contains low-level functions from the LAPACK library.
  5. .. versionadded:: 0.12.0
  6. .. note::
  7. The common ``overwrite_<>`` option in many routines, allows the
  8. input arrays to be overwritten to avoid extra memory allocation.
  9. However this requires the array to satisfy two conditions
  10. which are memory order and the data type to match exactly the
  11. order and the type expected by the routine.
  12. As an example, if you pass a double precision float array to any
  13. ``S....`` routine which expects single precision arguments, f2py
  14. will create an intermediate array to match the argument types and
  15. overwriting will be performed on that intermediate array.
  16. Similarly, if a C-contiguous array is passed, f2py will pass a
  17. FORTRAN-contiguous array internally. Please make sure that these
  18. details are satisfied. More information can be found in the f2py
  19. documentation.
  20. .. warning::
  21. These functions do little to no error checking.
  22. It is possible to cause crashes by mis-using them,
  23. so prefer using the higher-level routines in `scipy.linalg`.
  24. Finding functions
  25. -----------------
  26. .. autosummary::
  27. :toctree: generated/
  28. get_lapack_funcs
  29. All functions
  30. -------------
  31. .. autosummary::
  32. :toctree: generated/
  33. sgbsv
  34. dgbsv
  35. cgbsv
  36. zgbsv
  37. sgbtrf
  38. dgbtrf
  39. cgbtrf
  40. zgbtrf
  41. sgbtrs
  42. dgbtrs
  43. cgbtrs
  44. zgbtrs
  45. sgebal
  46. dgebal
  47. cgebal
  48. zgebal
  49. sgecon
  50. dgecon
  51. cgecon
  52. zgecon
  53. sgeequ
  54. dgeequ
  55. cgeequ
  56. zgeequ
  57. sgeequb
  58. dgeequb
  59. cgeequb
  60. zgeequb
  61. sgees
  62. dgees
  63. cgees
  64. zgees
  65. sgeev
  66. dgeev
  67. cgeev
  68. zgeev
  69. sgeev_lwork
  70. dgeev_lwork
  71. cgeev_lwork
  72. zgeev_lwork
  73. sgehrd
  74. dgehrd
  75. cgehrd
  76. zgehrd
  77. sgehrd_lwork
  78. dgehrd_lwork
  79. cgehrd_lwork
  80. zgehrd_lwork
  81. sgejsv
  82. dgejsv
  83. sgels
  84. dgels
  85. cgels
  86. zgels
  87. sgels_lwork
  88. dgels_lwork
  89. cgels_lwork
  90. zgels_lwork
  91. sgelsd
  92. dgelsd
  93. cgelsd
  94. zgelsd
  95. sgelsd_lwork
  96. dgelsd_lwork
  97. cgelsd_lwork
  98. zgelsd_lwork
  99. sgelss
  100. dgelss
  101. cgelss
  102. zgelss
  103. sgelss_lwork
  104. dgelss_lwork
  105. cgelss_lwork
  106. zgelss_lwork
  107. sgelsy
  108. dgelsy
  109. cgelsy
  110. zgelsy
  111. sgelsy_lwork
  112. dgelsy_lwork
  113. cgelsy_lwork
  114. zgelsy_lwork
  115. sgeqp3
  116. dgeqp3
  117. cgeqp3
  118. zgeqp3
  119. sgeqrf
  120. dgeqrf
  121. cgeqrf
  122. zgeqrf
  123. sgeqrf_lwork
  124. dgeqrf_lwork
  125. cgeqrf_lwork
  126. zgeqrf_lwork
  127. sgeqrfp
  128. dgeqrfp
  129. cgeqrfp
  130. zgeqrfp
  131. sgeqrfp_lwork
  132. dgeqrfp_lwork
  133. cgeqrfp_lwork
  134. zgeqrfp_lwork
  135. sgerqf
  136. dgerqf
  137. cgerqf
  138. zgerqf
  139. sgesdd
  140. dgesdd
  141. cgesdd
  142. zgesdd
  143. sgesdd_lwork
  144. dgesdd_lwork
  145. cgesdd_lwork
  146. zgesdd_lwork
  147. sgesv
  148. dgesv
  149. cgesv
  150. zgesv
  151. sgesvd
  152. dgesvd
  153. cgesvd
  154. zgesvd
  155. sgesvd_lwork
  156. dgesvd_lwork
  157. cgesvd_lwork
  158. zgesvd_lwork
  159. sgesvx
  160. dgesvx
  161. cgesvx
  162. zgesvx
  163. sgetrf
  164. dgetrf
  165. cgetrf
  166. zgetrf
  167. sgetc2
  168. dgetc2
  169. cgetc2
  170. zgetc2
  171. sgetri
  172. dgetri
  173. cgetri
  174. zgetri
  175. sgetri_lwork
  176. dgetri_lwork
  177. cgetri_lwork
  178. zgetri_lwork
  179. sgetrs
  180. dgetrs
  181. cgetrs
  182. zgetrs
  183. sgesc2
  184. dgesc2
  185. cgesc2
  186. zgesc2
  187. sgges
  188. dgges
  189. cgges
  190. zgges
  191. sggev
  192. dggev
  193. cggev
  194. zggev
  195. sgglse
  196. dgglse
  197. cgglse
  198. zgglse
  199. sgglse_lwork
  200. dgglse_lwork
  201. cgglse_lwork
  202. zgglse_lwork
  203. sgtsv
  204. dgtsv
  205. cgtsv
  206. zgtsv
  207. sgtsvx
  208. dgtsvx
  209. cgtsvx
  210. zgtsvx
  211. chbevd
  212. zhbevd
  213. chbevx
  214. zhbevx
  215. checon
  216. zhecon
  217. cheequb
  218. zheequb
  219. cheev
  220. zheev
  221. cheev_lwork
  222. zheev_lwork
  223. cheevd
  224. zheevd
  225. cheevd_lwork
  226. zheevd_lwork
  227. cheevr
  228. zheevr
  229. cheevr_lwork
  230. zheevr_lwork
  231. cheevx
  232. zheevx
  233. cheevx_lwork
  234. zheevx_lwork
  235. chegst
  236. zhegst
  237. chegv
  238. zhegv
  239. chegv_lwork
  240. zhegv_lwork
  241. chegvd
  242. zhegvd
  243. chegvx
  244. zhegvx
  245. chegvx_lwork
  246. zhegvx_lwork
  247. chesv
  248. zhesv
  249. chesv_lwork
  250. zhesv_lwork
  251. chesvx
  252. zhesvx
  253. chesvx_lwork
  254. zhesvx_lwork
  255. chetrd
  256. zhetrd
  257. chetrd_lwork
  258. zhetrd_lwork
  259. chetrf
  260. zhetrf
  261. chetrf_lwork
  262. zhetrf_lwork
  263. chfrk
  264. zhfrk
  265. slamch
  266. dlamch
  267. slange
  268. dlange
  269. clange
  270. zlange
  271. slarf
  272. dlarf
  273. clarf
  274. zlarf
  275. slarfg
  276. dlarfg
  277. clarfg
  278. zlarfg
  279. slartg
  280. dlartg
  281. clartg
  282. zlartg
  283. slasd4
  284. dlasd4
  285. slaswp
  286. dlaswp
  287. claswp
  288. zlaswp
  289. slauum
  290. dlauum
  291. clauum
  292. zlauum
  293. sorcsd
  294. dorcsd
  295. sorcsd_lwork
  296. dorcsd_lwork
  297. sorghr
  298. dorghr
  299. sorghr_lwork
  300. dorghr_lwork
  301. sorgqr
  302. dorgqr
  303. sorgrq
  304. dorgrq
  305. sormqr
  306. dormqr
  307. sormrz
  308. dormrz
  309. sormrz_lwork
  310. dormrz_lwork
  311. spbsv
  312. dpbsv
  313. cpbsv
  314. zpbsv
  315. spbtrf
  316. dpbtrf
  317. cpbtrf
  318. zpbtrf
  319. spbtrs
  320. dpbtrs
  321. cpbtrs
  322. zpbtrs
  323. spftrf
  324. dpftrf
  325. cpftrf
  326. zpftrf
  327. spftri
  328. dpftri
  329. cpftri
  330. zpftri
  331. spftrs
  332. dpftrs
  333. cpftrs
  334. zpftrs
  335. spocon
  336. dpocon
  337. cpocon
  338. zpocon
  339. spstrf
  340. dpstrf
  341. cpstrf
  342. zpstrf
  343. spstf2
  344. dpstf2
  345. cpstf2
  346. zpstf2
  347. sposv
  348. dposv
  349. cposv
  350. zposv
  351. sposvx
  352. dposvx
  353. cposvx
  354. zposvx
  355. spotrf
  356. dpotrf
  357. cpotrf
  358. zpotrf
  359. spotri
  360. dpotri
  361. cpotri
  362. zpotri
  363. spotrs
  364. dpotrs
  365. cpotrs
  366. zpotrs
  367. sppcon
  368. dppcon
  369. cppcon
  370. zppcon
  371. sppsv
  372. dppsv
  373. cppsv
  374. zppsv
  375. spptrf
  376. dpptrf
  377. cpptrf
  378. zpptrf
  379. spptri
  380. dpptri
  381. cpptri
  382. zpptri
  383. spptrs
  384. dpptrs
  385. cpptrs
  386. zpptrs
  387. sptsv
  388. dptsv
  389. cptsv
  390. zptsv
  391. sptsvx
  392. dptsvx
  393. cptsvx
  394. zptsvx
  395. spttrf
  396. dpttrf
  397. cpttrf
  398. zpttrf
  399. spttrs
  400. dpttrs
  401. cpttrs
  402. zpttrs
  403. spteqr
  404. dpteqr
  405. cpteqr
  406. zpteqr
  407. crot
  408. zrot
  409. ssbev
  410. dsbev
  411. ssbevd
  412. dsbevd
  413. ssbevx
  414. dsbevx
  415. ssfrk
  416. dsfrk
  417. sstebz
  418. dstebz
  419. sstein
  420. dstein
  421. sstemr
  422. dstemr
  423. sstemr_lwork
  424. dstemr_lwork
  425. ssterf
  426. dsterf
  427. sstev
  428. dstev
  429. ssycon
  430. dsycon
  431. csycon
  432. zsycon
  433. ssyconv
  434. dsyconv
  435. csyconv
  436. zsyconv
  437. ssyequb
  438. dsyequb
  439. csyequb
  440. zsyequb
  441. ssyev
  442. dsyev
  443. ssyev_lwork
  444. dsyev_lwork
  445. ssyevd
  446. dsyevd
  447. ssyevd_lwork
  448. dsyevd_lwork
  449. ssyevr
  450. dsyevr
  451. ssyevr_lwork
  452. dsyevr_lwork
  453. ssyevx
  454. dsyevx
  455. ssyevx_lwork
  456. dsyevx_lwork
  457. ssygst
  458. dsygst
  459. ssygv
  460. dsygv
  461. ssygv_lwork
  462. dsygv_lwork
  463. ssygvd
  464. dsygvd
  465. ssygvx
  466. dsygvx
  467. ssygvx_lwork
  468. dsygvx_lwork
  469. ssysv
  470. dsysv
  471. csysv
  472. zsysv
  473. ssysv_lwork
  474. dsysv_lwork
  475. csysv_lwork
  476. zsysv_lwork
  477. ssysvx
  478. dsysvx
  479. csysvx
  480. zsysvx
  481. ssysvx_lwork
  482. dsysvx_lwork
  483. csysvx_lwork
  484. zsysvx_lwork
  485. ssytf2
  486. dsytf2
  487. csytf2
  488. zsytf2
  489. ssytrd
  490. dsytrd
  491. ssytrd_lwork
  492. dsytrd_lwork
  493. ssytrf
  494. dsytrf
  495. csytrf
  496. zsytrf
  497. ssytrf_lwork
  498. dsytrf_lwork
  499. csytrf_lwork
  500. zsytrf_lwork
  501. stbtrs
  502. dtbtrs
  503. ctbtrs
  504. ztbtrs
  505. stfsm
  506. dtfsm
  507. ctfsm
  508. ztfsm
  509. stfttp
  510. dtfttp
  511. ctfttp
  512. ztfttp
  513. stfttr
  514. dtfttr
  515. ctfttr
  516. ztfttr
  517. stgexc
  518. dtgexc
  519. ctgexc
  520. ztgexc
  521. stgsen
  522. dtgsen
  523. ctgsen
  524. ztgsen
  525. stgsen_lwork
  526. dtgsen_lwork
  527. ctgsen_lwork
  528. ztgsen_lwork
  529. stpttf
  530. dtpttf
  531. ctpttf
  532. ztpttf
  533. stpttr
  534. dtpttr
  535. ctpttr
  536. ztpttr
  537. strexc
  538. dtrexc
  539. ctrexc
  540. ztrexc
  541. strsen
  542. dtrsen
  543. ctrsen
  544. ztrsen
  545. strsen_lwork
  546. dtrsen_lwork
  547. ctrsen_lwork
  548. ztrsen_lwork
  549. strsyl
  550. dtrsyl
  551. ctrsyl
  552. ztrsyl
  553. strtri
  554. dtrtri
  555. ctrtri
  556. ztrtri
  557. strtrs
  558. dtrtrs
  559. ctrtrs
  560. ztrtrs
  561. strttf
  562. dtrttf
  563. ctrttf
  564. ztrttf
  565. strttp
  566. dtrttp
  567. ctrttp
  568. ztrttp
  569. stzrzf
  570. dtzrzf
  571. ctzrzf
  572. ztzrzf
  573. stzrzf_lwork
  574. dtzrzf_lwork
  575. ctzrzf_lwork
  576. ztzrzf_lwork
  577. cunghr
  578. zunghr
  579. cunghr_lwork
  580. zunghr_lwork
  581. cungqr
  582. zungqr
  583. cungrq
  584. zungrq
  585. cunmqr
  586. zunmqr
  587. sgeqrt
  588. dgeqrt
  589. cgeqrt
  590. zgeqrt
  591. sgemqrt
  592. dgemqrt
  593. cgemqrt
  594. zgemqrt
  595. sgttrf
  596. dgttrf
  597. cgttrf
  598. zgttrf
  599. sgttrs
  600. dgttrs
  601. cgttrs
  602. zgttrs
  603. stpqrt
  604. dtpqrt
  605. ctpqrt
  606. ztpqrt
  607. stpmqrt
  608. dtpmqrt
  609. ctpmqrt
  610. ztpmqrt
  611. cuncsd
  612. zuncsd
  613. cuncsd_lwork
  614. zuncsd_lwork
  615. cunmrz
  616. zunmrz
  617. cunmrz_lwork
  618. zunmrz_lwork
  619. ilaver
  620. """
  621. #
  622. # Author: Pearu Peterson, March 2002
  623. #
  624. import numpy as _np
  625. from .blas import _get_funcs, _memoize_get_funcs
  626. from scipy.linalg import _flapack
  627. from re import compile as regex_compile
  628. try:
  629. from scipy.linalg import _clapack
  630. except ImportError:
  631. _clapack = None
  632. try:
  633. from scipy.linalg import _flapack_64
  634. HAS_ILP64 = True
  635. except ImportError:
  636. HAS_ILP64 = False
  637. _flapack_64 = None
  638. # Expose all functions (only flapack --- clapack is an implementation detail)
  639. empty_module = None
  640. from scipy.linalg._flapack import *
  641. del empty_module
  642. __all__ = ['get_lapack_funcs']
  643. # some convenience alias for complex functions
  644. _lapack_alias = {
  645. 'corghr': 'cunghr', 'zorghr': 'zunghr',
  646. 'corghr_lwork': 'cunghr_lwork', 'zorghr_lwork': 'zunghr_lwork',
  647. 'corgqr': 'cungqr', 'zorgqr': 'zungqr',
  648. 'cormqr': 'cunmqr', 'zormqr': 'zunmqr',
  649. 'corgrq': 'cungrq', 'zorgrq': 'zungrq',
  650. }
  651. # Place guards against docstring rendering issues with special characters
  652. p1 = regex_compile(r'with bounds (?P<b>.*?)( and (?P<s>.*?) storage){0,1}\n')
  653. p2 = regex_compile(r'Default: (?P<d>.*?)\n')
  654. def backtickrepl(m):
  655. if m.group('s'):
  656. return ('with bounds ``{}`` with ``{}`` storage\n'
  657. ''.format(m.group('b'), m.group('s')))
  658. else:
  659. return 'with bounds ``{}``\n'.format(m.group('b'))
  660. for routine in [ssyevr, dsyevr, cheevr, zheevr,
  661. ssyevx, dsyevx, cheevx, zheevx,
  662. ssygvd, dsygvd, chegvd, zhegvd]:
  663. if routine.__doc__:
  664. routine.__doc__ = p1.sub(backtickrepl, routine.__doc__)
  665. routine.__doc__ = p2.sub('Default ``\\1``\n', routine.__doc__)
  666. else:
  667. continue
  668. del regex_compile, p1, p2, backtickrepl
  669. @_memoize_get_funcs
  670. def get_lapack_funcs(names, arrays=(), dtype=None, ilp64=False):
  671. """Return available LAPACK function objects from names.
  672. Arrays are used to determine the optimal prefix of LAPACK routines.
  673. Parameters
  674. ----------
  675. names : str or sequence of str
  676. Name(s) of LAPACK functions without type prefix.
  677. arrays : sequence of ndarrays, optional
  678. Arrays can be given to determine optimal prefix of LAPACK
  679. routines. If not given, double-precision routines will be
  680. used, otherwise the most generic type in arrays will be used.
  681. dtype : str or dtype, optional
  682. Data-type specifier. Not used if `arrays` is non-empty.
  683. ilp64 : {True, False, 'preferred'}, optional
  684. Whether to return ILP64 routine variant.
  685. Choosing 'preferred' returns ILP64 routine if available, and
  686. otherwise the 32-bit routine. Default: False
  687. Returns
  688. -------
  689. funcs : list
  690. List containing the found function(s).
  691. Notes
  692. -----
  693. This routine automatically chooses between Fortran/C
  694. interfaces. Fortran code is used whenever possible for arrays with
  695. column major order. In all other cases, C code is preferred.
  696. In LAPACK, the naming convention is that all functions start with a
  697. type prefix, which depends on the type of the principal
  698. matrix. These can be one of {'s', 'd', 'c', 'z'} for the NumPy
  699. types {float32, float64, complex64, complex128} respectively, and
  700. are stored in attribute ``typecode`` of the returned functions.
  701. Examples
  702. --------
  703. Suppose we would like to use '?lange' routine which computes the selected
  704. norm of an array. We pass our array in order to get the correct 'lange'
  705. flavor.
  706. >>> import numpy as np
  707. >>> import scipy.linalg as LA
  708. >>> rng = np.random.default_rng()
  709. >>> a = rng.random((3,2))
  710. >>> x_lange = LA.get_lapack_funcs('lange', (a,))
  711. >>> x_lange.typecode
  712. 'd'
  713. >>> x_lange = LA.get_lapack_funcs('lange',(a*1j,))
  714. >>> x_lange.typecode
  715. 'z'
  716. Several LAPACK routines work best when its internal WORK array has
  717. the optimal size (big enough for fast computation and small enough to
  718. avoid waste of memory). This size is determined also by a dedicated query
  719. to the function which is often wrapped as a standalone function and
  720. commonly denoted as ``###_lwork``. Below is an example for ``?sysv``
  721. >>> a = rng.random((1000, 1000))
  722. >>> b = rng.random((1000, 1)) * 1j
  723. >>> # We pick up zsysv and zsysv_lwork due to b array
  724. ... xsysv, xlwork = LA.get_lapack_funcs(('sysv', 'sysv_lwork'), (a, b))
  725. >>> opt_lwork, _ = xlwork(a.shape[0]) # returns a complex for 'z' prefix
  726. >>> udut, ipiv, x, info = xsysv(a, b, lwork=int(opt_lwork.real))
  727. """
  728. if isinstance(ilp64, str):
  729. if ilp64 == 'preferred':
  730. ilp64 = HAS_ILP64
  731. else:
  732. raise ValueError("Invalid value for 'ilp64'")
  733. if not ilp64:
  734. return _get_funcs(names, arrays, dtype,
  735. "LAPACK", _flapack, _clapack,
  736. "flapack", "clapack", _lapack_alias,
  737. ilp64=False)
  738. else:
  739. if not HAS_ILP64:
  740. raise RuntimeError("LAPACK ILP64 routine requested, but Scipy "
  741. "compiled only with 32-bit BLAS")
  742. return _get_funcs(names, arrays, dtype,
  743. "LAPACK", _flapack_64, None,
  744. "flapack_64", None, _lapack_alias,
  745. ilp64=True)
  746. _int32_max = _np.iinfo(_np.int32).max
  747. _int64_max = _np.iinfo(_np.int64).max
  748. def _compute_lwork(routine, *args, **kwargs):
  749. """
  750. Round floating-point lwork returned by lapack to integer.
  751. Several LAPACK routines compute optimal values for LWORK, which
  752. they return in a floating-point variable. However, for large
  753. values of LWORK, single-precision floating point is not sufficient
  754. to hold the exact value --- some LAPACK versions (<= 3.5.0 at
  755. least) truncate the returned integer to single precision and in
  756. some cases this can be smaller than the required value.
  757. Examples
  758. --------
  759. >>> from scipy.linalg import lapack
  760. >>> n = 5000
  761. >>> s_r, s_lw = lapack.get_lapack_funcs(('sysvx', 'sysvx_lwork'))
  762. >>> lwork = lapack._compute_lwork(s_lw, n)
  763. >>> lwork
  764. 32000
  765. """
  766. dtype = getattr(routine, 'dtype', None)
  767. int_dtype = getattr(routine, 'int_dtype', None)
  768. ret = routine(*args, **kwargs)
  769. if ret[-1] != 0:
  770. raise ValueError("Internal work array size computation failed: "
  771. "%d" % (ret[-1],))
  772. if len(ret) == 2:
  773. return _check_work_float(ret[0].real, dtype, int_dtype)
  774. else:
  775. return tuple(_check_work_float(x.real, dtype, int_dtype)
  776. for x in ret[:-1])
  777. def _check_work_float(value, dtype, int_dtype):
  778. """
  779. Convert LAPACK-returned work array size float to integer,
  780. carefully for single-precision types.
  781. """
  782. if dtype == _np.float32 or dtype == _np.complex64:
  783. # Single-precision routine -- take next fp value to work
  784. # around possible truncation in LAPACK code
  785. value = _np.nextafter(value, _np.inf, dtype=_np.float32)
  786. value = int(value)
  787. if int_dtype.itemsize == 4:
  788. if value < 0 or value > _int32_max:
  789. raise ValueError("Too large work array required -- computation "
  790. "cannot be performed with standard 32-bit"
  791. " LAPACK.")
  792. elif int_dtype.itemsize == 8:
  793. if value < 0 or value > _int64_max:
  794. raise ValueError("Too large work array required -- computation"
  795. " cannot be performed with standard 64-bit"
  796. " LAPACK.")
  797. return value