L i. dZddgZddlZddlZddlmZ ddlmZ ddlm Z dZ dZ dd l [ d Dcic]}|d c}Z e jd Dcic]}|dc}e jddddddejdfdejdfdejdfdejdfdZdddddd d!d!d"d"d# Zd(d$Z d)d%Zd&Zed*d'Zy#e$rdZYwxYw#e$rd Z dZ YwxYwcc}wcc}w)+ar Low-level BLAS functions (:mod:`scipy.linalg.blas`) =================================================== This module contains low-level functions from the BLAS library. .. versionadded:: 0.12.0 .. note:: The common ``overwrite_<>`` option in many routines, allows the input arrays to be overwritten to avoid extra memory allocation. However this requires the array to satisfy two conditions which are memory order and the data type to match exactly the order and the type expected by the routine. As an example, if you pass a double precision float array to any ``S....`` routine which expects single precision arguments, f2py will create an intermediate array to match the argument types and overwriting will be performed on that intermediate array. Similarly, if a C-contiguous array is passed, f2py will pass a FORTRAN-contiguous array internally. Please make sure that these details are satisfied. More information can be found in the f2py documentation. .. warning:: These functions do little to no error checking. It is possible to cause crashes by mis-using them, so prefer using the higher-level routines in `scipy.linalg`. Finding functions ----------------- .. autosummary:: :toctree: generated/ get_blas_funcs find_best_blas_type BLAS Level 1 functions ---------------------- .. autosummary:: :toctree: generated/ sasum saxpy scasum scnrm2 scopy sdot snrm2 srot srotg srotm srotmg sscal sswap dasum daxpy dcopy ddot dnrm2 drot drotg drotm drotmg dscal dswap dzasum dznrm2 icamax idamax isamax izamax caxpy ccopy cdotc cdotu crotg cscal csrot csscal cswap zaxpy zcopy zdotc zdotu zdrot zdscal zrotg zscal zswap BLAS Level 2 functions ---------------------- .. autosummary:: :toctree: generated/ sgbmv sgemv sger ssbmv sspmv sspr sspr2 ssymv ssyr ssyr2 stbmv stbsv stpmv stpsv strmv strsv dgbmv dgemv dger dsbmv dspmv dspr dspr2 dsymv dsyr dsyr2 dtbmv dtbsv dtpmv dtpsv dtrmv dtrsv cgbmv cgemv cgerc cgeru chbmv chemv cher cher2 chpmv chpr chpr2 cspmv cspr csyr ctbmv ctbsv ctpmv ctpsv ctrmv ctrsv zgbmv zgemv zgerc zgeru zhbmv zhemv zher zher2 zhpmv zhpr zhpr2 zspmv zspr zsyr ztbmv ztbsv ztpmv ztpsv ztrmv ztrsv BLAS Level 3 functions ---------------------- .. autosummary:: :toctree: generated/ sgemm ssymm ssyr2k ssyrk strmm strsm dgemm dsymm dsyr2k dsyrk dtrmm dtrsm cgemm chemm cher2k cherk csymm csyr2k csyrk ctrmm ctrsm zgemm zhemm zher2k zherk zsymm zsyr2k zsyrk ztrmm ztrsm get_blas_funcsfind_best_blas_typeN)_fblas)_cblas) _fblas_64TF)*z?bBhHefiIlLqQd)FDgGsfloat32dfloat64c complex64z complex128)r r r r scnrm2dznrm2cdotczdotccgerczgercsdotddot) cnrm2znrm2cdotzdotcgerzgersdotcsdotuddotcddotucdtj|}tj|jd}d}|rt |dk(r@tj|djjd}|dj d}nr|Dcgc],}tj|jjd.}}t|}|j|}|dk(rd|vrd}||j drd }tj|d tjd f\}}|||fScc}w) aFind best-matching BLAS/LAPACK type. Arrays are used to determine the optimal prefix of BLAS routines. Parameters ---------- arrays : sequence of ndarrays, optional Arrays can be given to determine optimal prefix of BLAS routines. If not given, double-precision routines will be used, otherwise the most generic type in arrays will be used. dtype : str or dtype, optional Data-type specifier. Not used if `arrays` is non-empty. Returns ------- prefix : str BLAS/LAPACK prefix character. dtype : dtype Inferred Numpy data type. prefer_fortran : bool Whether to prefer Fortran order routines over C order. Examples -------- >>> import numpy as np >>> import scipy.linalg.blas as bla >>> rng = np.random.default_rng() >>> a = rng.random((10,15)) >>> b = np.asfortranarray(a) # Change the memory layout order >>> bla.find_best_blas_type((a,)) ('d', dtype('float64'), False) >>> bla.find_best_blas_type((a*1j,)) ('z', dtype('complex128'), False) >>> bla.find_best_blas_type((b,)) ('d', dtype('float64'), True) Fr rFORTRANr r r Trr) npdtype _type_scoregetcharlenflagsmaxindex _type_conv)arraysr0 max_scoreprefer_fortranxscores ind_max_scoreprefixs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/linalg/blas.pyrrs L HHUOE A.IN v;! #q (<("GTM IIi3 wqz9d3aj <71:y$7D!!*K <*Jyk1DEG G*5v'$- XXbgg.DNXXbhh/DN  T%(Qx cZi_tjdfd }|S)z5 Memoized fast path for _get_funcs instances c|||f}|D]1}||jj|jjfz }3 j |}||S||||}|||<|S#t $rd}d}Y'wxYw)N)r0r3r5fortranr2 TypeError) rLr9r0rSkeyarrayvaluerZmemos r@getterz"_memoize_get_funcs..getterseU# ;E EKK$$ekk&9&9: :C ; HHSME  LUFE51 ?DI  CE sA'' A76A7NF)rd functoolswraps)rZrerds` @r@_memoize_get_funcsrjs3 DDI__T. Mr\c t|tr|dk(rt}n td|s!t |||dt t ddtd Sts tdt |||dtd d d td  S) aReturn available BLAS function objects from names. Arrays are used to determine the optimal prefix of BLAS routines. Parameters ---------- names : str or sequence of str Name(s) of BLAS functions without type prefix. arrays : sequence of ndarrays, optional Arrays can be given to determine optimal prefix of BLAS routines. If not given, double-precision routines will be used, otherwise the most generic type in arrays will be used. dtype : str or dtype, optional Data-type specifier. Not used if `arrays` is non-empty. ilp64 : {True, False, 'preferred'}, optional Whether to return ILP64 routine variant. Choosing 'preferred' returns ILP64 routine if available, and otherwise the 32-bit routine. Default: False Returns ------- funcs : list List containing the found function(s). Notes ----- This routine automatically chooses between Fortran/C interfaces. Fortran code is used whenever possible for arrays with column major order. In all other cases, C code is preferred. In BLAS, the naming convention is that all functions start with a type prefix, which depends on the type of the principal matrix. These can be one of {'s', 'd', 'c', 'z'} for the NumPy types {float32, float64, complex64, complex128} respectively. The code and the dtype are stored in attributes `typecode` and `dtype` of the returned functions. Examples -------- >>> import numpy as np >>> import scipy.linalg as LA >>> rng = np.random.default_rng() >>> a = rng.random((3,2)) >>> x_gemv = LA.get_blas_funcs('gemv', (a,)) >>> x_gemv.typecode 'd' >>> x_gemv = LA.get_blas_funcs('gemv',(a*1j,)) >>> x_gemv.typecode 'z' preferredzInvalid value for 'ilp64'BLASfblascblasF)rSzFBLAS ILP64 routine requested, but Scipy compiled only with 32-bit BLASNfblas_64T) rBrC HAS_ILP64rEr[rr _blas_alias RuntimeErrorr)rLr9r0rSs r@rrsr% K E89 9 % &&'7%U4 4 @A A% )T:t%T3 3r\)rgN)Frf)__doc____all__numpyr/rh scipy.linalgrr ImportErrorrrq empty_modulescipy.linalg._fblasr1updater0r8rrrr[rjr)r<s0r@r|smTt 2 3#&I  !''q!t' ),QAqD,- 34xrxx *+xrxx *+xrxx ,-xrxx -.0 !8 1 @)L0fDH3H3I F II (,s-C&C3 D D&C0/C03 C?>C?