ó
î&]\c           @   s9  d  Z  d d l m Z d d l m Z d d l Z e j j e j j e	 ƒ ƒ Z
 i d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6Z i d d 6d d 6d d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6Z d' „  Z d( Z i
 d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6Z d) „  Z d* „  Z d+ Z d, „  Z d- Z d. „  Z d/ Z d0 „  Z d1 Z d2 „  Z d3 Z d4 „  Z d5 Z d6 Z d7 „  Z d8 Z d9 „  Z d: Z  d; „  Z! d< Z" i	 d= d> 6d? d@ 6dA dB 6d= dC 6d= d
 6d= dD 6d= dE 6d= dF 6d= dG 6Z# i dH dI 6dH dJ 6Z$ i d= dB 6Z% e e& dK e$ dL e% dM e% dN e$ dO e$ ƒZ' dP „  Z( dQ „  Z) dR „  Z* dS „  Z+ dT „  Z, dU Z- dV „  Z. dW Z/ dX „  Z0 dY Z1 dZ Z2 d[ Z3 d\ Z4 d] „  Z5 d^ „  Z6 d_ „  Z7 d` „  Z8 da db dc dd de df dg dh di „ Z9 e: dj k r5e9 ƒ  n  d S(k   sù   
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.
iÿÿÿÿ(   t   defaultdict(   t
   itemgetterNt   integert   intt   complext   cs   double precisiont   dt   realt   ss
   complex*16t   zt	   charactert   chart   logicalt   bintt   npy_complex64t   doublet   floatt   npy_complex128t	   _cselect1t   cselect1t	   _cselect2t   cselect2t	   _dselect2t   dselect2t	   _dselect3t   dselect3t	   _sselect2t   sselect2t	   _sselect3t   sselect3t	   _zselect1t   zselect1t	   _zselect2t   zselect2c         C   s/   t  g  |  j d ƒ D] } | j d ƒ ^ q Œ  S(   Ns   , s    *(   t   zipt   split(   t   argst   arg(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   arg_names_and_types'   s    sô   
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
c         C   s   |  d k r d j  |  ƒ Sd S(   NR   R   R   R   R   R   R   R   R   R    s   <{0}*>t    (
   R   R   R   R   R   R   R   R   R   R    (   t   format(   R%   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt	   arg_casts;   s
     	c   
      C   sÁ  t  | ƒ \ } } | | k r¿ g  | D]" } | | k r= | n | d ^ q% } g  | D]" } | d k rl | n | d ^ qT } d j g  t | | ƒ D]! \ } } d j | | g ƒ ^ q’ ƒ } n  g  | D] } t j | | ƒ ^ qÆ } d j g  t | | ƒ D]! \ } } d j | | g ƒ ^ qú ƒ } g  t | | ƒ D] \ } } t | ƒ | ^ q4} d j | ƒ } t | }	 | j d d ƒ } t j	 d |  d |  j
 ƒ  d	 | d
 | d | d |	 d | d | ƒ S(   Nt   _t   lambdat   ins   , s    *t   lambda_t   namet   upnameR$   t	   fort_argst   ret_typet
   c_ret_typet   argnamest   header_name(   R+   R,   (   R&   t   joinR"   t	   npy_typest   getR)   t   c_typest   replacet   pyx_func_templateR(   t   upper(
   R.   R1   R$   R4   t   argtypesR3   t   nt   tR0   R2   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   pyx_decl_funcC   s$    /,	:%	72
!s¨   cdef extern from "{header_name}":
    void _fortran_{name} "F_FUNC({name},{upname})"({fort_args}) nogil
cdef void {name}({args}) nogil:
    _fortran_{name}({argnames})
c         C   s9  t  | ƒ \ } } g  | D] } t j | | ƒ ^ q } g  | D]" } | d k rV | n | d ^ q> } d j g  t | | ƒ D]! \ } } d j | | g ƒ ^ q| ƒ } g  t | | ƒ D] \ } } t | ƒ | ^ q¶ } d j | ƒ } | j d d ƒ j d d	 ƒ } t j d
 |  d |  j	 ƒ  d | d | d | d | ƒ S(   NR+   R,   R*   s   , s    *s   *lambda,s	   *lambda_,s   *in,s   *in_,R.   R/   R$   R0   R3   R4   (   R+   R,   (
   R&   R6   R7   R5   R"   R)   R9   t   pyx_sub_templateR(   R;   (   R.   R$   R4   R<   R3   R>   R=   R0   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   pyx_decl_subc   s    %/	72s®  # 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.

from __future__ import absolute_import

cdef extern from "fortran_defs.h":
    pass

from numpy cimport npy_complex64, npy_complex128

c         C   s3   g  |  D] } | d ^ q } t  j d j | ƒ ƒ S(   Ni    s   
- (   t   blas_pyx_preambleR(   R5   (   t   all_sigst   sigt   names(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   make_blas_pyx_preambleœ   s    sJ  """
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.

from __future__ import absolute_import

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   s3   g  |  D] } | d ^ q } t  j d j | ƒ ƒ S(   Ni    s   
- (   t   lapack_pyx_preambleR(   R5   (   RC   RD   RE   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   make_lapack_pyx_preambleÙ   s    sæ  

# 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            sX   d j  ‡  f d †  |  Dƒ ƒ } d d j  ‡  f d †  | Dƒ ƒ } t | ƒ | | t S(   Ns   
c         3   s"   |  ] } t  | ˆ  f Œ  Vq d  S(   N(   R?   (   t   .0R   (   R4   (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>©  s    c         3   s/   |  ]% } t  | d  d  d … ˆ  f Œ  Vq d  S(   Ni   (   RA   (   RI   R   (   R4   (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>ª  s   (   R5   RF   t   blas_py_wrappers(   t	   func_sigst   sub_sigsRC   R4   t   funcst   subs(    (   R4   s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_blas_pyx¨  s    sž  

# 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            s^   d j  ‡  f d †  |  Dƒ ƒ } d d j  ‡  f d †  | Dƒ ƒ } t | ƒ } | | | t S(   Ns   
c         3   s"   |  ] } t  | ˆ  f Œ  Vq d  S(   N(   R?   (   RI   R   (   R4   (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>Æ  s    c         3   s/   |  ]% } t  | d  d  d … ˆ  f Œ  Vq d  S(   Ni   (   RA   (   RI   R   (   R4   (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>Ç  s   (   R5   RH   t   lapack_py_wrappers(   RK   RL   RC   R4   RM   RN   t   preamble(    (   R4   s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_lapack_pyxÅ  s
    sC   ctypedef {ret_type} {name}_t({args}) nogil
cdef {name}_t *{name}_f
s%   cdef {ret_type} {name}({args}) nogil
c         C   s:   | j  d d ƒ j  d d ƒ } t j d |  d | d | ƒ S(   NR+   R-   s   *in,s   *in_,R.   R1   R$   (   R9   t   pxd_templateR(   (   R.   R1   R$   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   pxd_declÔ  s    sö  # 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 j  d „  |  Dƒ ƒ } t | S(   Ns   
c         s   s   |  ] } t  | Œ  Vq d  S(   N(   RT   (   RI   RD   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>í  s    (   R5   t   blas_pxd_preamble(   RC   t   body(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_blas_pxdì  s    sM  # 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 j d „  |  Dƒ ƒ S(   Ns   
c         s   s   |  ] } t  | Œ  Vq d  S(   N(   RT   (   RI   RD   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>  s    (   t   lapack_pxd_preambleR5   (   RC   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_lapack_pxd  s    sò         subroutine {name}wrp(
     +    ret,
     +    {argnames}
     +    )
        external {wrapper}
        {ret_type} {wrapper}
        {ret_type} ret
        {argdecls}
        ret = {wrapper}(
     +    {argnames}
     +    )
      end
s   (*)t   works   (ldab,*)t   abs   (lda,*)t   at   dlt   dut   apt   et   lldR'   t   xt   yt   ladivt   lanhft   lansft   lapy2t   lapy3c         C   se   d |  k r |  St  | d } d |  k s6 d |  k rK | j |  d ƒ } n | j |  d ƒ } |  | S(   Nt   inci   Rb   Rc   s   (n)R'   (   t   special_casesR7   (   R.   t   funcnamet   specialt   suffix(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   process_fortran_name.  s    c         C   s0   d d d d d d g } |  | k r, d |  S|  S(   Nt   cdotct   cdotut   zdotct   zdotut   cladivt   zladivt   w(    (   R.   t   included(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   called_name9  s    c   	      C   s   t  |  ƒ } t | ƒ \ } } d j | ƒ } g  | D] } t | |  ƒ ^ q4 } d j d „  t | | ƒ Dƒ ƒ } t j d |  d | d | d | d t | ƒ S(	   Ns   ,
     +    s	   
        c         s   s+   |  ]! \ } } d  j  t | | ƒ Vq d S(   s   {0} {1}N(   R(   t   fortran_types(   RI   R=   R>   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>F  s   R.   t   wrapperR3   t   argdeclsR1   (   Rw   R&   R5   Rn   R"   t   fortran_templateR(   Rx   (	   R.   R1   R$   Ry   t   typesRE   R3   R=   Rz   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   fort_subroutine_wrapper@  s    "c         C   s   d j  d „  |  Dƒ ƒ S(   Ns   
c         s   s   |  ] } t  | Œ  Vq d  S(   N(   R}   (   RI   RD   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>N  s    (   R5   (   RK   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_fortranM  s    c         C   sO   t  |  ƒ \ } } g  | D] } t | ^ q } d j d „  t | | ƒ Dƒ ƒ S(   Ns   , c         s   s'   |  ] \ } } d  j  | | ƒ Vq d S(   s   {0} *{1}N(   R(   (   RI   R>   R=   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>T  s    (   R&   R8   R5   R"   (   R$   R|   RE   R%   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   make_c_argsQ  s    sA   void F_FUNC({name}wrp, {upname}WRP)({return_type} *ret, {args});
c      	   C   s>   t  | ƒ } t | } t j d |  d |  j ƒ  d | d | ƒ S(   NR.   R/   t   return_typeR$   (   R   R8   t   c_func_templateR(   R;   (   R.   R€   R$   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   c_func_decl[  s    
s&   void F_FUNC({name},{upname})({args});
c         C   s.   t  | ƒ } t j d |  d |  j ƒ  d | ƒ S(   NR.   R/   R$   (   R   t   c_sub_templateR(   R;   (   R.   R€   R$   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt
   c_sub_decle  s    s•   #ifndef SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H
#define SCIPY_LINALG_{lib}_FORTRAN_WRAPPERS_H
#include "fortran_defs.h"
#include "numpy/arrayobject.h"
s‰  
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*);
s)   
#ifdef __cplusplus
extern "C" {
#endif

s$   
#ifdef __cplusplus
}
#endif
#endif
c         C   s‰   d j  d „  |  Dƒ ƒ } d d j  d „  | Dƒ ƒ } | d k r[ t j d | ƒ t } n t j d | ƒ } d j  | t | | t g ƒ S(   NR'   c         s   s   |  ] } t  | Œ  Vq d  S(   N(   R‚   (   RI   RD   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>‹  s    s   
c         s   s   |  ] } t  | Œ  Vq d  S(   N(   R„   (   RI   RD   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>Œ  s    t   LAPACKt   lib(   R5   t
   c_preambleR(   t   lapack_declst	   cpp_guardt   c_end(   RK   RL   RC   t   lib_nameRM   RN   RQ   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   generate_c_headerŠ  s    c         C   s;   |  d  j  d ƒ \ } } | j  d ƒ \ } } | | | f S(   Niÿÿÿÿt   (t    (   R#   (   RD   t   name_and_typeR$   R1   R.   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   split_signature”  s    c         C   sÚ   g  t  t j |  ƒ D]" } | r | j d ƒ r | ^ q }  g  |  D]+ } | j d ƒ d d k rB t | ƒ ^ qB } g  |  D]+ } | j d ƒ d d k rz t | ƒ ^ qz } t t | | d t d ƒ ƒƒ } | | | f S(   Nt   #RŽ   i    t   voidt   key(	   t   mapt   strt   stript
   startswithR#   R   t   listt   sortedR   (   t   linest   lineRK   RL   RC   (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   filter_linesš  s    "++"c            s-   d d l  m ‰  t ‡  ‡ f d †  | Dƒ ƒ S(   Niÿÿÿÿ(   t   newerc         3   s=   |  ]3 } ˆ D]& } t  j j | ƒ o1 ˆ  | | ƒ Vq q d  S(   N(   t   ost   patht   exists(   RI   t   dstt   src(   R   t	   src_files(    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pys	   <genexpr>§  s   (   t   distutils.dep_utilR   t   all(   R£   t	   dst_files(    (   R   R£   s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt	   all_newer¥  s    s   cython_blas_signatures.txts   cython_lapack_signatures.txtt   cython_blast   cython_lapacks   _blas_subroutine_wrappers.fs   _lapack_subroutine_wrappers.fs   _blas_subroutines.hs   _lapack_subroutines.hc         C   sŒ  t  j j t ƒ |  | f } | d | d | | | d | d | | f }	 t  j t ƒ t | |	 ƒ rn d GHd  Sd d g }
 d j g  |
 D] } d | j ƒ  d ^ q‡ ƒ d	 } d j g  |
 D] } d
 | ^ q» ƒ d	 } d j g  |
 D] } d | ^ qå ƒ d	 } t	 |  d ƒ  } | j
 ƒ  } Wd  QXt | ƒ } t | | f Œ  } t	 | d d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d ƒ } t	 | d d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d ƒ } t	 | d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d Œ  } t	 | d ƒ ! } | j | ƒ | j | ƒ Wd  QXt	 | d ƒ  } | j
 ƒ  } Wd  QXt | ƒ } t | | f Œ  } t	 | d d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d ƒ } t	 | d d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d ƒ } t	 | d ƒ ! } | j | ƒ | j | ƒ Wd  QXt | d Œ  } t	 | d ƒ ! } | j | ƒ | j | ƒ Wd  QXd  S(   Ns   .pyxs   .pxds3   scipy/linalg/_generate_pyx.py: all files up-to-dates-   This file was generated by _generate_pyx.py.
s    Do not edit this file directly.
R'   s   /* s    */
s   
s   # s   c     t   rRu   i   i    t   BLASR…   (   R«   (   R…   (   Rž   RŸ   t   abspatht   __file__t   chdirt   BASE_DIRR§   R5   t   rstript   opent	   readlinesRœ   RO   t   writeRW   R~   RŒ   RR   RY   (   t   blas_signature_filet   lapack_signature_filet	   blas_namet   lapack_namet   blas_fortran_namet   lapack_fortran_namet   blas_header_namet   lapack_header_nameR£   R¦   t   commentsR›   t   ccommentt
   pyxcommentt   fcommentt   ft	   blas_sigst   blas_pyxt   blas_pxdt   blas_fortrant   blas_c_headert   lapack_sigst
   lapack_pyxt
   lapack_pxdt   lapack_fortrant   lapack_c_header(    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   make_all«  sv    					+**t   __main__(;   t   __doc__t   collectionsR    t   operatorR   Rž   RŸ   R¬   t   dirnameR­   R¯   Rx   R8   R&   R:   R6   R)   R?   R@   RA   RB   RF   RG   RH   RJ   RO   RP   RR   RS   RT   RU   RW   RX   RY   R{   t   dimst   xy_specialized_dimst   a_specialized_dimst   dictRj   Rn   Rw   R}   R~   R   R   R‚   Rƒ   R„   R‡   Rˆ   R‰   RŠ   RŒ   R   Rœ   R§   RË   t   __name__(    (    (    s9   lib/python2.7/site-packages/scipy/linalg/_generate_pyx.pyt   <module>   s´   



				6	:	Ì		
		 	&											
			B