o
    Eba                     @   s  d Z ddlmZ ddlmZ ddlZejeje	Z
ddddd	d
ddZddddddddddddddddZdd ZdZddddddddddd
Zd d! Zd"d# Zd$Zd%d& Zd'Zd(d) Zd*Zd+d, Zd-Zd.d/ Zd0Zd1d2 Zd3Zd4Zd5d6 Zd7Zd8d9 Zd:Z d;d< Z!d=Z"d>d?d@d>d>d>d>d>d>dA	Z#dBdBdCZ$dDd>iZ%ee&e$e%e%e$e$dEZ'dFdG Z(dHdI Z)dJdK Z*dLdM Z+dNdO Z,dPZ-dQdR Z.dSZ/dTdU Z0dVZ1dWZ2dXZ3dYZ4dZd[ Z5d\d] Z6d^d_ Z7d`da Z8	b	c	d	e	f	g	h	idmdjdkZ9e:dlkre9  dS dS )nz
Code generator script to make the Cython BLAS and LAPACK wrappers
from the files "cython_blas_signatures.txt" and
"cython_lapack_signatures.txt" which contain the signatures for
all the BLAS/LAPACK routines that should be included in the wrappers.
    )defaultdict)
itemgetterNZintegercomplexzdouble precisionrealz
complex*16	characterZlogical)intcdszcharbintr   npy_complex64Zdoublefloatnpy_complex128r   	_cselect1	_cselect2	_dselect2	_dselect3	_sselect2	_sselect3	_zselect1	_zselect2)r   r   r	   r
   r   r   r   cselect1cselect2dselect2dselect3sselect2sselect3zselect1zselect2c                 C   s   t dd | dD  S )Nc                 S   s   g | ]}| d qS z *split.0arg r'   </usr/lib/python3/dist-packages/scipy/linalg/_generate_pyx.py
<listcomp>(       z'arg_names_and_types.<locals>.<listcomp>, )zipr#   )argsr'   r'   r(   arg_names_and_types'      r.   z
cdef extern from "{header_name}":
    void _fortran_{name} "F_FUNC({name}wrp, {upname}WRP)"({ret_type} *out, {fort_args}) nogil
cdef {ret_type} {name}({args}) nogil:
    cdef {ret_type} out
    _fortran_{name}(&out, {argnames})
    return out
)
r   r   r   r   r   r   r   r   r   r    c                 C   s   | dv r	d | S dS )N)
r   r   r   r   r   r   r   r   r   r   z<{0}*> format)r&   r'   r'   r(   	arg_casts;   s   
r3   c              
      s   t |\}} |v r' fdd|D }dd |D }ddd t||D }dd |D }ddd t||D }dd t||D }d|}t  }|d	d
}tj| |  || |||dS )Nc                    s    g | ]}| kr
|n d  qS )_r'   r%   nret_typer'   r(   r)   J        z!pyx_decl_func.<locals>.<listcomp>c                 S       g | ]}|d vr
|n|d qS )lambdainr4   r'   r5   r'   r'   r(   r)   K   s    r+   c                 S      g | ]\}}d  ||gqS r!   joinr%   r6   tr'   r'   r(   r)   M       c                 S      g | ]}t ||qS r'   	npy_typesgetr%   rB   r'   r'   r(   r)   O       c                 S   r>   r!   r?   rA   r'   r'   r(   r)   P   rC   c                 S      g | ]
\}}t || qS r'   r3   rA   r'   r'   r(   r)   R       r<   lambda_)nameupnamer-   	fort_argsr8   
c_ret_typeargnamesheader_name)r.   r@   r,   c_typesreplacepyx_func_templater2   upper)rN   r8   r-   rS   argtypesrR   rP   rQ   r'   r7   r(   pyx_decl_funcC   s,   


rY   zcdef extern from "{header_name}":
    void _fortran_{name} "F_FUNC({name},{upname})"({fort_args}) nogil
cdef void {name}({args}) nogil:
    _fortran_{name}({argnames})
c                 C   s   t |\}}dd |D }dd |D }ddd t||D }dd t||D }d|}|ddd	d
}tj| |  ||||dS )Nc                 S   rD   r'   rE   rH   r'   r'   r(   r)   e   rI   z pyx_decl_sub.<locals>.<listcomp>c                 S   r:   r;   r'   r5   r'   r'   r(   r)   f   r9   r+   c                 S   r>   r!   r?   rA   r'   r'   r(   r)   g   rC   c                 S   rJ   r'   rK   rA   r'   r'   r(   r)   i   rL   z*lambda,z	*lambda_,*in,*in_,)rN   rO   r-   rP   rR   rS   )r.   r@   r,   rU   pyx_sub_templater2   rW   )rN   r-   rS   rX   rR   rP   r'   r'   r(   pyx_decl_subc   s   

r]   a  # cython: boundscheck = False
# cython: wraparound = False
# cython: cdivision = True

"""
BLAS Functions for Cython
=========================

Usable from Cython via::

    cimport scipy.linalg.cython_blas

These wrappers do not check for alignment of arrays.
Alignment should be checked before these wrappers are used.

Raw function pointers (Fortran-style pointer arguments):

- {}


"""

# Within SciPy, these wrappers can be used via relative or absolute cimport.
# Examples:
# from ..linalg cimport cython_blas
# from scipy.linalg cimport cython_blas
# cimport scipy.linalg.cython_blas as cython_blas
# cimport ..linalg.cython_blas as cython_blas

# Within SciPy, if BLAS functions are needed in C/C++/Fortran,
# these wrappers should not be used.
# The original libraries should be linked directly.

cdef extern from "fortran_defs.h":
    pass

from numpy cimport npy_complex64, npy_complex128

c                 C      dd | D }t d|S )Nc                 S      g | ]}|d  qS r   r'   r%   sigr'   r'   r(   r)          z*make_blas_pyx_preamble.<locals>.<listcomp>
- )blas_pyx_preambler2   r@   all_sigsnamesr'   r'   r(   make_blas_pyx_preamble      ri   a"  """
LAPACK functions for Cython
===========================

Usable from Cython via::

    cimport scipy.linalg.cython_lapack

This module provides Cython-level wrappers for all primary routines included
in LAPACK 3.4.0 except for ``zcgesv`` since its interface is not consistent
from LAPACK 3.4.0 to 3.6.0. It also provides some of the
fixed-api auxiliary routines.

These wrappers do not check for alignment of arrays.
Alignment should be checked before these wrappers are used.

Raw function pointers (Fortran-style pointer arguments):

- {}


"""

# Within SciPy, these wrappers can be used via relative or absolute cimport.
# Examples:
# from ..linalg cimport cython_lapack
# from scipy.linalg cimport cython_lapack
# cimport scipy.linalg.cython_lapack as cython_lapack
# cimport ..linalg.cython_lapack as cython_lapack

# Within SciPy, if LAPACK functions are needed in C/C++/Fortran,
# these wrappers should not be used.
# The original libraries should be linked directly.

cdef extern from "fortran_defs.h":
    pass

from numpy cimport npy_complex64, npy_complex128

cdef extern from "_lapack_subroutines.h":
    # Function pointer type declarations for
    # gees and gges families of functions.
    ctypedef bint _cselect1(npy_complex64*)
    ctypedef bint _cselect2(npy_complex64*, npy_complex64*)
    ctypedef bint _dselect2(d*, d*)
    ctypedef bint _dselect3(d*, d*, d*)
    ctypedef bint _sselect2(s*, s*)
    ctypedef bint _sselect3(s*, s*, s*)
    ctypedef bint _zselect1(npy_complex128*)
    ctypedef bint _zselect2(npy_complex128*, npy_complex128*)

c                 C   r^   )Nc                 S   r_   r`   r'   ra   r'   r'   r(   r)      rc   z,make_lapack_pyx_preamble.<locals>.<listcomp>rd   )lapack_pyx_preambler2   r@   rf   r'   r'   r(   make_lapack_pyx_preamble   rj   rl   a  

# Python-accessible wrappers for testing:

cdef inline bint _is_contiguous(double[:,:] a, int axis) nogil:
    return (a.strides[axis] == sizeof(a[0,0]) or a.shape[axis] == 1)

cpdef float complex _test_cdotc(float complex[:] cx, float complex[:] cy) nogil:
    cdef:
        int n = cx.shape[0]
        int incx = cx.strides[0] // sizeof(cx[0])
        int incy = cy.strides[0] // sizeof(cy[0])
    return cdotc(&n, &cx[0], &incx, &cy[0], &incy)

cpdef float complex _test_cdotu(float complex[:] cx, float complex[:] cy) nogil:
    cdef:
        int n = cx.shape[0]
        int incx = cx.strides[0] // sizeof(cx[0])
        int incy = cy.strides[0] // sizeof(cy[0])
    return cdotu(&n, &cx[0], &incx, &cy[0], &incy)

cpdef double _test_dasum(double[:] dx) nogil:
    cdef:
        int n = dx.shape[0]
        int incx = dx.strides[0] // sizeof(dx[0])
    return dasum(&n, &dx[0], &incx)

cpdef double _test_ddot(double[:] dx, double[:] dy) nogil:
    cdef:
        int n = dx.shape[0]
        int incx = dx.strides[0] // sizeof(dx[0])
        int incy = dy.strides[0] // sizeof(dy[0])
    return ddot(&n, &dx[0], &incx, &dy[0], &incy)

cpdef int _test_dgemm(double alpha, double[:,:] a, double[:,:] b, double beta,
                double[:,:] c) nogil except -1:
    cdef:
        char *transa
        char *transb
        int m, n, k, lda, ldb, ldc
        double *a0=&a[0,0]
        double *b0=&b[0,0]
        double *c0=&c[0,0]
    # In the case that c is C contiguous, swap a and b and
    # swap whether or not each of them is transposed.
    # This can be done because a.dot(b) = b.T.dot(a.T).T.
    if _is_contiguous(c, 1):
        if _is_contiguous(a, 1):
            transb = 'n'
            ldb = (&a[1,0]) - a0 if a.shape[0] > 1 else 1
        elif _is_contiguous(a, 0):
            transb = 't'
            ldb = (&a[0,1]) - a0 if a.shape[1] > 1 else 1
        else:
            with gil:
                raise ValueError("Input 'a' is neither C nor Fortran contiguous.")
        if _is_contiguous(b, 1):
            transa = 'n'
            lda = (&b[1,0]) - b0 if b.shape[0] > 1 else 1
        elif _is_contiguous(b, 0):
            transa = 't'
            lda = (&b[0,1]) - b0 if b.shape[1] > 1 else 1
        else:
            with gil:
                raise ValueError("Input 'b' is neither C nor Fortran contiguous.")
        k = b.shape[0]
        if k != a.shape[1]:
            with gil:
                raise ValueError("Shape mismatch in input arrays.")
        m = b.shape[1]
        n = a.shape[0]
        if n != c.shape[0] or m != c.shape[1]:
            with gil:
                raise ValueError("Output array does not have the correct shape.")
        ldc = (&c[1,0]) - c0 if c.shape[0] > 1 else 1
        dgemm(transa, transb, &m, &n, &k, &alpha, b0, &lda, a0,
                   &ldb, &beta, c0, &ldc)
    elif _is_contiguous(c, 0):
        if _is_contiguous(a, 1):
            transa = 't'
            lda = (&a[1,0]) - a0 if a.shape[0] > 1 else 1
        elif _is_contiguous(a, 0):
            transa = 'n'
            lda = (&a[0,1]) - a0 if a.shape[1] > 1 else 1
        else:
            with gil:
                raise ValueError("Input 'a' is neither C nor Fortran contiguous.")
        if _is_contiguous(b, 1):
            transb = 't'
            ldb = (&b[1,0]) - b0 if b.shape[0] > 1 else 1
        elif _is_contiguous(b, 0):
            transb = 'n'
            ldb = (&b[0,1]) - b0 if b.shape[1] > 1 else 1
        else:
            with gil:
                raise ValueError("Input 'b' is neither C nor Fortran contiguous.")
        m = a.shape[0]
        k = a.shape[1]
        if k != b.shape[0]:
            with gil:
                raise ValueError("Shape mismatch in input arrays.")
        n = b.shape[1]
        if m != c.shape[0] or n != c.shape[1]:
            with gil:
                raise ValueError("Output array does not have the correct shape.")
        ldc = (&c[0,1]) - c0 if c.shape[1] > 1 else 1
        dgemm(transa, transb, &m, &n, &k, &alpha, a0, &lda, b0,
                   &ldb, &beta, c0, &ldc)
    else:
        with gil:
            raise ValueError("Input 'c' is neither C nor Fortran contiguous.")
    return 0

cpdef double _test_dnrm2(double[:] x) nogil:
    cdef:
        int n = x.shape[0]
        int incx = x.strides[0] // sizeof(x[0])
    return dnrm2(&n, &x[0], &incx)

cpdef double _test_dzasum(double complex[:] zx) nogil:
    cdef:
        int n = zx.shape[0]
        int incx = zx.strides[0] // sizeof(zx[0])
    return dzasum(&n, &zx[0], &incx)

cpdef double _test_dznrm2(double complex[:] x) nogil:
    cdef:
        int n = x.shape[0]
        int incx = x.strides[0] // sizeof(x[0])
    return dznrm2(&n, &x[0], &incx)

cpdef int _test_icamax(float complex[:] cx) nogil:
    cdef:
        int n = cx.shape[0]
        int incx = cx.strides[0] // sizeof(cx[0])
    return icamax(&n, &cx[0], &incx)

cpdef int _test_idamax(double[:] dx) nogil:
    cdef:
        int n = dx.shape[0]
        int incx = dx.strides[0] // sizeof(dx[0])
    return idamax(&n, &dx[0], &incx)

cpdef int _test_isamax(float[:] sx) nogil:
    cdef:
        int n = sx.shape[0]
        int incx = sx.strides[0] // sizeof(sx[0])
    return isamax(&n, &sx[0], &incx)

cpdef int _test_izamax(double complex[:] zx) nogil:
    cdef:
        int n = zx.shape[0]
        int incx = zx.strides[0] // sizeof(zx[0])
    return izamax(&n, &zx[0], &incx)

cpdef float _test_sasum(float[:] sx) nogil:
    cdef:
        int n = sx.shape[0]
        int incx = sx.shape[0] // sizeof(sx[0])
    return sasum(&n, &sx[0], &incx)

cpdef float _test_scasum(float complex[:] cx) nogil:
    cdef:
        int n = cx.shape[0]
        int incx = cx.strides[0] // sizeof(cx[0])
    return scasum(&n, &cx[0], &incx)

cpdef float _test_scnrm2(float complex[:] x) nogil:
    cdef:
        int n = x.shape[0]
        int incx = x.strides[0] // sizeof(x[0])
    return scnrm2(&n, &x[0], &incx)

cpdef float _test_sdot(float[:] sx, float[:] sy) nogil:
    cdef:
        int n = sx.shape[0]
        int incx = sx.strides[0] // sizeof(sx[0])
        int incy = sy.strides[0] // sizeof(sy[0])
    return sdot(&n, &sx[0], &incx, &sy[0], &incy)

cpdef float _test_snrm2(float[:] x) nogil:
    cdef:
        int n = x.shape[0]
        int incx = x.shape[0] // sizeof(x[0])
    return snrm2(&n, &x[0], &incx)

cpdef double complex _test_zdotc(double complex[:] zx, double complex[:] zy) nogil:
    cdef:
        int n = zx.shape[0]
        int incx = zx.strides[0] // sizeof(zx[0])
        int incy = zy.strides[0] // sizeof(zy[0])
    return zdotc(&n, &zx[0], &incx, &zy[0], &incy)

cpdef double complex _test_zdotu(double complex[:] zx, double complex[:] zy) nogil:
    cdef:
        int n = zx.shape[0]
        int incx = zx.strides[0] // sizeof(zx[0])
        int incy = zy.strides[0] // sizeof(zy[0])
    return zdotu(&n, &zx[0], &incx, &zy[0], &incy)
c                    sH   d  fdd| D }dd  fdd|D  }t|| | t S )N
c                 3       | ]
}t | f  V  qd S NrY   r%   r
   rS   r'   r(   	<genexpr>      z$generate_blas_pyx.<locals>.<genexpr>c                 3   (    | ]}t |d d d  f  V  qd S N   r]   rq   rr   r'   r(   rs          )r@   ri   blas_py_wrappers)	func_sigssub_sigsrg   rS   funcssubsr'   rr   r(   generate_blas_pyx  s
   
r   a  

# Python accessible wrappers for testing:

def _test_dlamch(cmach):
    # This conversion is necessary to handle Python 3 strings.
    cmach_bytes = bytes(cmach)
    # Now that it is a bytes representation, a non-temporary variable
    # must be passed as a part of the function call.
    cdef char* cmach_char = cmach_bytes
    return dlamch(cmach_char)

def _test_slamch(cmach):
    # This conversion is necessary to handle Python 3 strings.
    cmach_bytes = bytes(cmach)
    # Now that it is a bytes representation, a non-temporary variable
    # must be passed as a part of the function call.
    cdef char* cmach_char = cmach_bytes
    return slamch(cmach_char)
c                    sL   d  fdd| D }dd  fdd|D  }t|}|| | t S )Nrm   c                 3   rn   ro   rp   rq   rr   r'   r(   rs     rt   z&generate_lapack_pyx.<locals>.<genexpr>c                 3   ru   rv   rx   rq   rr   r'   r(   rs     ry   )r@   rl   lapack_py_wrappers)r{   r|   rg   rS   r}   r~   preambler'   rr   r(   generate_lapack_pyx  s   
r   zCctypedef {ret_type} {name}_t({args}) nogil
cdef {name}_t *{name}_f
z%cdef {ret_type} {name}({args}) nogil
c                 C   s$   | dd dd}tj| ||dS )Nr<   rM   rZ   r[   rN   r8   r-   )rU   pxd_templater2   r   r'   r'   r(   pxd_decl  s   r   a  # Within scipy, these wrappers can be used via relative or absolute cimport.
# Examples:
# from ..linalg cimport cython_blas
# from scipy.linalg cimport cython_blas
# cimport scipy.linalg.cython_blas as cython_blas
# cimport ..linalg.cython_blas as cython_blas

# Within SciPy, if BLAS functions are needed in C/C++/Fortran,
# these wrappers should not be used.
# The original libraries should be linked directly.

ctypedef float s
ctypedef double d
ctypedef float complex c
ctypedef double complex z

c                 C   s   d dd | D }t| S )Nrm   c                 s       | ]}t | V  qd S ro   r   ra   r'   r'   r(   rs         z$generate_blas_pxd.<locals>.<genexpr>)r@   blas_pxd_preamble)rg   bodyr'   r'   r(   generate_blas_pxd  s   r   aM  # Within SciPy, these wrappers can be used via relative or absolute cimport.
# Examples:
# from ..linalg cimport cython_lapack
# from scipy.linalg cimport cython_lapack
# cimport scipy.linalg.cython_lapack as cython_lapack
# cimport ..linalg.cython_lapack as cython_lapack

# Within SciPy, if LAPACK functions are needed in C/C++/Fortran,
# these wrappers should not be used.
# The original libraries should be linked directly.

ctypedef float s
ctypedef double d
ctypedef float complex c
ctypedef double complex z

# Function pointer type declarations for
# gees and gges families of functions.
ctypedef bint cselect1(c*)
ctypedef bint cselect2(c*, c*)
ctypedef bint dselect2(d*, d*)
ctypedef bint dselect3(d*, d*, d*)
ctypedef bint sselect2(s*, s*)
ctypedef bint sselect3(s*, s*, s*)
ctypedef bint zselect1(z*)
ctypedef bint zselect2(z*, z*)

c                 C   s   t ddd | D  S )Nrm   c                 s   r   ro   r   ra   r'   r'   r(   rs     r   z&generate_lapack_pxd.<locals>.<genexpr>)lapack_pxd_preambler@   )rg   r'   r'   r(   generate_lapack_pxd  r/   r   z      subroutine {name}wrp(
     +    ret,
     +    {argnames}
     +    )
        external {wrapper}
        {ret_type} {wrapper}
        {ret_type} ret
        {argdecls}
        ret = {wrapper}(
     +    {argnames}
     +    )
      end
z(*)z(ldab,*)z(lda,*))	ZworkabaZdlr	   ZduZapeZlldr0   )xyr   )ZladivZlanhfZlansfZlapy2Zlapy3c                 C   sT   d| v r| S t |dd   }d| v sd| v r || d}| | S || d}| | S )NZinc   r   r   z(n)r0   )special_casesrG   )rN   funcnameZspecialsuffixr'   r'   r(   process_fortran_name*  s   r   c                 C   s   g d}| |v rd|  S | S )N)ZcdotcZcdotuZzdotcZzdotuZcladivZzladivwr'   )rN   Zincludedr'   r'   r(   called_name5  s   r   c                    sb   t  }t|\}}d|} fdd|D }ddd t||D }tj |||t| dS )Nz,
     +    c                    s   g | ]}t | qS r'   )r   r5   rN   r'   r(   r)   A  r*   z+fort_subroutine_wrapper.<locals>.<listcomp>z	
        c                 s   s$    | ]\}}d  t| |V  qdS )z{0} {1}N)r2   fortran_typesrA   r'   r'   r(   rs   B  s    z*fort_subroutine_wrapper.<locals>.<genexpr>)rN   wrapperrR   argdeclsr8   )r   r.   r@   r,   fortran_templater2   r   )rN   r8   r-   r   typesrh   rR   r   r'   r   r(   fort_subroutine_wrapper<  s   

r   c                 C   s   d dd | D S )Nrm   c                 s   r   ro   )r   ra   r'   r'   r(   rs   J  r   z#generate_fortran.<locals>.<genexpr>r?   )r{   r'   r'   r(   generate_fortranI  s   r   c                 C   s4   t | \}}dd |D }ddd t||D S )Nc                 S   s   g | ]}t | qS r'   )rT   r$   r'   r'   r(   r)   O  rc   zmake_c_args.<locals>.<listcomp>r+   c                 s   s     | ]\}}d  ||V  qdS )z{0} *{1}Nr1   )r%   rB   r6   r'   r'   r(   rs   P  s    zmake_c_args.<locals>.<genexpr>)r.   r@   r,   )r-   r   rh   r'   r'   r(   make_c_argsM  s   r   zAvoid F_FUNC({name}wrp, {upname}WRP)({return_type} *ret, {args});
c                 C   s&   t |}t| }tj| |  ||dS )N)rN   rO   return_typer-   )r   rT   c_func_templater2   rW   rN   r   r-   r'   r'   r(   c_func_declW  s
   r   z&void F_FUNC({name},{upname})({args});
c                 C   s   t |}tj| |  |dS )N)rN   rO   r-   )r   c_sub_templater2   rW   r   r'   r'   r(   
c_sub_decla  s   r   z#ifndef SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H
#define SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H
#include "fortran_defs.h"
#include "numpy/arrayobject.h"
a  
typedef int (*_cselect1)(npy_complex64*);
typedef int (*_cselect2)(npy_complex64*, npy_complex64*);
typedef int (*_dselect2)(double*, double*);
typedef int (*_dselect3)(double*, double*, double*);
typedef int (*_sselect2)(float*, float*);
typedef int (*_sselect3)(float*, float*, float*);
typedef int (*_zselect1)(npy_complex128*);
typedef int (*_zselect2)(npy_complex128*, npy_complex128*);
z)
#ifdef __cplusplus
extern "C" {
#endif

z$
#ifdef __cplusplus
}
#endif
#endif
c                 C   sf   d dd | D }dd dd |D  }|dkr#tj|dt }ntj|d}d |t||tgS )Nr0   c                 s   r   ro   )r   ra   r'   r'   r(   rs     r   z$generate_c_header.<locals>.<genexpr>rm   c                 s   r   ro   )r   ra   r'   r'   r(   rs     r   LAPACK)lib)r@   
c_preambler2   lapack_decls	cpp_guardc_end)r{   r|   rg   Zlib_namer}   r~   r   r'   r'   r(   generate_c_header  s   r   c                 C   s.   | d d  d\}}| d\}}|||fS )N( r"   )rb   Zname_and_typer-   r8   rN   r'   r'   r(   split_signature  s   
r   c                 C   sT   dd t tj| D } dd | D }dd | D }tt|| tdd}|||fS )Nc                 S   s   g | ]}|r| d s|qS )#)
startswithr%   liner'   r'   r(   r)     s
    
z filter_lines.<locals>.<listcomp>c                 S   s&   g | ]}| d d dkrt|qS r   r   Zvoidr#   r   r   r'   r'   r(   r)         c                 S   s&   g | ]}| d d dkrt|qS r   r   r   r'   r'   r(   r)     r   r   )key)mapstrstriplistsortedr   )linesr{   r|   rg   r'   r'   r(   filter_lines  s
   
r   c                    s$   ddl m  t fdd|D S )Nr   )newerc                 3   s0    | ]}D ]}t j|o ||V  qqd S ro   )ospathexists)r%   dstsrcr   	src_filesr'   r(   rs     s     zall_newer.<locals>.<genexpr>)Zdistutils.dep_utilr   all)r   	dst_filesr'   r   r(   	all_newer  s   r   cython_blas_signatures.txtcython_lapack_signatures.txtcython_blascython_lapack_blas_subroutine_wrappers.f_lapack_subroutine_wrappers.f_blas_subroutines.h_lapack_subroutines.hc                 C   s  t jt| |f}|d |d |||d |d ||f}	t t t||	r+td d S ddg}
ddd |
D d	 }dd
d |
D d	 }ddd |
D d	 }t	| d}|
 }W d    n1 sgw   Y  t|}t||f  }t	|d d}|| || W d    n1 sw   Y  t|d }t	|d d}|| || W d    n1 sw   Y  t|d }t	|d}|| || W d    n1 sw   Y  t|d  }t	|d}|| || W d    n	1 sw   Y  t	|d}|
 }W d    n	1 sw   Y  t|}t||f  }t	|d d}|| || W d    n	1 sLw   Y  t|d }t	|d d}|| || W d    n	1 stw   Y  t|d }t	|d}|| || W d    n	1 sw   Y  t|d  }t	|d}|| || W d    d S 1 sw   Y  d S )Nz.pyxz.pxdz3scipy/linalg/_generate_pyx.py: all files up-to-datez-This file was generated by _generate_pyx.py.
z Do not edit this file directly.
r0   c                 S   s   g | ]
}d |   d qS )z/* z */
)rstripr   r'   r'   r(   r)     s    zmake_all.<locals>.<listcomp>rm   c                 S      g | ]}d | qS )z# r'   r   r'   r'   r(   r)     rc   c                 S   r   )zc     r'   r   r'   r'   r(   r)     rc   rr   rw   r   )ZBLAS)r   )r   r   abspath__file__chdirBASE_DIRr   printr@   open	readlinesr   r   writer   r   r   r   r   )Zblas_signature_fileZlapack_signature_fileZ	blas_nameZlapack_nameZblas_fortran_nameZlapack_fortran_nameZblas_header_nameZlapack_header_namer   r   ZcommentsZccommentZ
pyxcommentZfcommentfZ	blas_sigsZblas_pyxZblas_pxdZblas_fortranZblas_c_headerZlapack_sigsZ
lapack_pyxZ
lapack_pxdZlapack_fortranZlapack_c_headerr'   r'   r(   make_all  s   
	
	











$r   __main__)r   r   r   r   r   r   r   r   );__doc__collectionsr   operatorr   r   r   r   dirnamer   r   r   rT   r.   rV   rF   r3   rY   r\   r]   re   ri   rk   rl   rz   r   r   r   r   r   r   r   r   r   r   ZdimsZxy_specialized_dimsZa_specialized_dimsdictr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __name__r'   r'   r'   r(   <module>   s    	)6 K



I
