
    `i|                     <   d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ ej        j        j        Zd	 Zd
 Zddej        dfdZdej        dfdZd dZd Zd Z	 	 d!dZ	 	 d"dddZd Z	 	 d#dZ	 	 d!dZ	 	 d!dddZdS )$    N)_core)internal)runtime)_texture)_util)_interp_kernels)_spline_prefilter_corec                     |t          j        d|  d           n|dk     sd|k     rt          d          |dvr"t          d                    |                    d S )NzCurrently the default order of zG is 1. In a future release this may change to 3 to match scipy.ndimage r      zspline order is not supported)
constantgrid-constantnearestmirrorreflectzgrid-mirrorwrap	grid-wrapopencv_opencv_edgez#boundary mode ({}) is not supported)warningswarn
ValueErrorformat)	func_nameordermodes      v/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/ndimage/_interpolation.py_check_parameterr      s    } '	 ' ' ' 	( 	( 	( 	( 
a%ii8999 $ $ $ >EEdKKLLL$ $    c                    | j         j        dk    }|rt          j        }nt          j        }t          |t          j                  rC|r|j         j        dk    rt          d          t          j        |j         |          }|j         }n5|
| j         x}}nt          j         |          }t          j        ||          }t          |t          j                  r=|j         |cxk    r|k    r+n n(|j	        j
        r|| urt          j        | |           |}nU|                     |d          }t          j        |          }t          j        || d          r|                                }|||fS )zCreate workspace array, temp, and the final dtype for the output.

    Differs from SciPy by not always forcing the internal floating point dtype
    to be double precision.
    cz1output must have complex dtype for complex inputsNFcopyMAY_SHARE_BOUNDS)dtypekindcupy	complex64float32
isinstancendarrayr   promote_typesflagsc_contiguousr   elementwise_copyastypeascontiguousarrayshares_memoryr"   )inputoutputcomplex_datamin_float_dtypefloat_dtypeoutput_dtypetemps          r   _get_spline_outputr9       s    ;#s*L '.,&$,'' B 	FL-44C   (GG|>$)K/F\\:f--L(AA64<(( 
;;;;|;;;;;) <"5&111||Ke|44%d++dE+=>> 	99;;Dl**r      r   c           
         |dk     s|dk    rt          d          | }|j        }t          j        ||          }|dk     p|j        dk    p|j        |         dk     }|s,t          j        ||           }t          j        ||           |S t          ||          \  }}	}
t          j        j                            |j                  }t          j        j                            |j        j                  }t          j        |           }|dk    rt          j        nt          j        }|j        |         }|j        |z  }t          j        ||f|j        z   |          }t)          dt+          j        t/          j        |dz                      z  d	          }t3          j        ||||||||
          }|f}||d         z   dz
  |d         z  f}t3          j        |          }|t3          j        |          z  } |||||f           t;          |t          j                  r||urt          j        ||           |S |                    |
d          S )a$  
    Calculate a 1-D spline filter along the given axis.

    The lines of the array along the given axis are filtered by a
    spline filter. The order of the spline must be >= 2 and <= 5.

    Args:
        input (cupy.ndarray): The input array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        axis (int): The axis along which the spline filter is applied. Default
            is the last axis.
        output (cupy.ndarray or dtype, optional): The array in which to place
            the output, or the dtype of the returned array. Default is
            ``numpy.float64``.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).

    Returns:
        cupy.ndarray: The result of prefiltering the input.

    .. seealso:: :func:`scipy.spline_filter1d`
    r   r   spline order not supported      intr$          )r   
index_type	data_type	pole_type
block_size)r   Fr!   ) RuntimeErrorndimr   _normalize_axis_indexshaper   _get_outputr   r.   r9   r&   _scalarget_typenamer$   real_get_inttypeint32int64sizearraymaxmathceilnumpylog2r	   get_raw_spline1d_kernel	get_polesget_gainr)   r*   r/   )r2   r   axisr3   r   xrI   
run_kernelr8   
data_dtyper7   rE   rF   rD   index_dtype	n_samples	n_signalsinforG   kernblockgridpoless                          r   spline_filter1dri   G   s]   6 qyyEAII7888A6D)$55D aiD16Q;D!'$-12DEJ "6511q&)))%76%B%B"D*l
"//
;;I
"//	@@I#E**J *e 3 3$**KI)#I:y),qw6kJJJD Q$)EJy2~$>$>???CCJ!9	 	 	D MEq!A%%(24D #,5999E"+E222D 	DutTl###&$,'' D,>,>tV,,,;;|%;000r   c                    |dk     s|dk    rt          d          | }t          ||          \  }}}|dvr8| j        dk    r-t          |j                  D ]}t	          |||||           |}t          |t          j                  rt          j	        ||           n|}|j
        |k    r|                    |          }|S )a  Multidimensional spline filter.

    Args:
        input (cupy.ndarray): The input array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        output (cupy.ndarray or dtype, optional): The array in which to place
            the output, or the dtype of the returned array. Default is
            ``numpy.float64``.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).

    Returns:
        cupy.ndarray: The result of prefiltering the input.

    .. seealso:: :func:`scipy.spline_filter1d`
    r>   r   r=   )r   r?   r   r3   r   )rH   r9   rI   rangeri   r)   r&   r*   r   r.   r$   r/   )	r2   r   r3   r   r^   r8   r`   r7   r]   s	            r   spline_filterrm      s    ( qyyEAII7888A%76%B%B"D*lFuzA~~!&MM 	 	DAud4dCCCCAA&$,'' tV,,,,||##|,,Mr   Tc                 4   | j         j        dk    rc|r%t          j        | j         t          j                  }n$t          j        | j         t          j                  }|                     |d          } n| j         j        dv rg|dk    r`|r%t          j        | j         t          j                  }n$t          j        | j         t          j                  }|                     |          } nt          d          | j        j	        st          j
        |           } | S )NfFr!   iur?   z,coordinates should have floating point dtype)r$   r%   r&   r+   r(   float64r/   r   r,   r-   r0   )coordinatesr   allow_float32coord_dtypes       r   _check_coordinatesru      s   $$ 	N,[->MMKK,[->MMK!((5(AA			4	'	'199 "0%t|  #0%t|  &,,[99KGHHH) :,[99r   c                     |dv r>d}|dk    rt          d|          }nt          d          }t          j        | |fi |}nd}| }||fS )	N)r   r      r   r   )r   constant_valuesedge)r   r   )dictr&   pad)r2   r   cvalnpadkwargspaddeds         r   _prepad_for_spline_filterr      sq    +++?""z4@@@FFv&&&F%00004<r   c                     |r|dk     rt          j        |           dfS t          | ||          \  }}t          j        | j        t           j                  }t          ||||          }t          j        |          |fS )ak  Perform spline prefiltering when needed.

    Spline orders > 1 need a prefiltering stage to preserve resolution.

    For boundary modes without analytical spline boundary conditions, some
    prepadding of the input with cupy.pad is used to maintain accuracy.
    ``npad`` is an integer corresponding to the amount of padding at each edge
    of the array.
    r>   r   rk   )r&   r0   r   r+   r$   r(   rm   )	image	prefilterr   r|   r   r   r}   r6   filtereds	            r   _filter_inputr      s      2		&u--q11,UD$??LFD$U[$,??KVU;TJJJH!(++T11r   r           c           
         t          d||           |dk    s|dk    r8t          j        | dg| j        z  d|          } t          j        |d          }d}t          j        || |j        dd                   }|j        j	        d	v }t          j
        |||           | j        j	        d	v r|                     t          j                  } t          ||          }t          | ||||          \  }	}
t          t!          | j                  |j        d
                   dk    }t#          j        | j        ||j        |||||
          } ||	||           |S )a6  Map the input array to new coordinates by interpolation.

    The array of coordinates is used to find, for each point in the output, the
    corresponding coordinates in the input. The value of the input at those
    coordinates is determined by spline interpolation of the requested order.

    The shape of the output is derived from that of the coordinate array by
    dropping the first axis. The values of the array along the first axis are
    the coordinates in the input array at which the output value is found.

    Args:
        input (cupy.ndarray): The input array.
        coordinates (array_like): The coordinates at which ``input`` is
            evaluated.
        output (cupy.ndarray or ~cupy.dtype): The array in which to place the
            output, or the dtype of the returned array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).
        cval (scalar): Value used for points outside the boundaries of
            the input if ``mode='constant'`` or ``mode='opencv'``. Default is
            0.0
        prefilter (bool): Determines if the input array is prefiltered with
            ``spline_filter`` before interpolation. The default is True, which
            will create a temporary ``float64`` array of filtered values if
            ``order > 1``. If setting this to False, the output will be
            slightly blurred if ``order > 1``, unless the input is prefiltered,
            i.e. it is the result of calling ``spline_filter`` on the original
            input.

    Returns:
        cupy.ndarray:
            The result of transforming the input. The shape of the output is
            derived from that of ``coordinates`` by dropping the first axis.

    .. seealso:: :func:`scipy.ndimage.map_coordinates`
    map_coordinatesr   r   )r?   r?   r   )rx   r?   Nrp   r           )yshaper   r|   r   integer_outputnprepad)r   r&   r{   rI   addr   rL   rK   r$   r%   _check_cvalr/   r(   ru   r   rU   _prodr   _get_map_kernel)r2   rr   r3   r   r   r|   r   retr   r   r   	large_intre   s                r   r   r      sl   V &t444x4>115: 5z)-/ / /h{A..

FE;+<QRR+@
A
ACY^t+N	dD.111{4T\**$[%88K%eYdEJJHgE%+&&(9!(<==GI*
Ik&7dNGE E ED 	D;$$$Jr   F)texture_memoryc	          
      r	   |	r@t           j        rt          d          |dk    rdnd}
t          j        | ||||
||          S t          d||           t          j        || j        dt                    }|j        dvs|j
        d         d	k     rt          d
          |j        dk    r|j
        d         |j
        d	         d	z
  k    r|dddf         }|ddddf         }n3|j
        d         | j        d	z   k    r|dddf         }|ddddf         }|j
        | j        | j        fk    rt          d          |dk    rt          j        | j        d	z   | j        d	z   f          }||ddddf<   ||dddf<   d	|d<   t          j                            |          }t          j        |dd         d	d          |dd<   t          j        |ddddf         d	d	          |ddddf<   |ddddf         }|dddf         }|| j
        }|dk    s|dk    r|j        d	k    rt          j        |          }t          j        |t          j                  }t          j        ||                    | j        df                    }|t          j        t          j        |          d          z  }t          j        || |          }t1          | ||j        ||||                              |          |dd<   |S |                    t          j        d          }| j        }t          j        || |          }| j        j        dv r|                     t          j                  } t;          | ||||          \  }}|j        j        dv }t          j        |||           t?          tA          | j
                  tA          |                    dk    }|j        d	k    rQt          j        |t          j                  }| |z  }tC          j"        ||||||||          } |||||           ntC          j#        ||||||||          }t          j        ||d	z   ft          j                  }||ddddf<   t          j        |t          j                  |dddf<    ||||           |S )a  Apply an affine transformation.

    Given an output image pixel index vector ``o``, the pixel value is
    determined from the input image at position
    ``cupy.dot(matrix, o) + offset``.

    Args:
        input (cupy.ndarray): The input array.
        matrix (cupy.ndarray): The inverse coordinate transformation matrix,
            mapping output coordinates to input coordinates. If ``ndim`` is the
            number of dimensions of ``input``, the given matrix must have one
            of the following shapes:

                - ``(ndim, ndim)``: the linear transformation matrix for each
                  output coordinate.
                - ``(ndim,)``: assume that the 2D transformation matrix is
                  diagonal, with the diagonal specified by the given value.
                - ``(ndim + 1, ndim + 1)``: assume that the transformation is
                  specified using homogeneous coordinates. In this case, any
                  value passed to ``offset`` is ignored.
                - ``(ndim, ndim + 1)``: as above, but the bottom row of a
                  homogeneous transformation matrix is always
                  ``[0, 0, ..., 1]``, and may be omitted.

        offset (float or sequence): The offset into the array where the
            transform is applied. If a float, ``offset`` is the same for each
            axis. If a sequence, ``offset`` should contain one value for each
            axis.
        output_shape (tuple of ints): Shape tuple.
        output (cupy.ndarray or ~cupy.dtype): The array in which to place the
            output, or the dtype of the returned array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).
        cval (scalar): Value used for points outside the boundaries of
            the input if ``mode='constant'`` or ``mode='opencv'``. Default is
            0.0
        prefilter (bool): Determines if the input array is prefiltered with
            ``spline_filter`` before interpolation. The default is True, which
            will create a temporary ``float64`` array of filtered values if
            ``order > 1``. If setting this to False, the output will be
            slightly blurred if ``order > 1``, unless the input is prefiltered,
            i.e. it is the result of calling ``spline_filter`` on the original
            input.
        texture_memory (bool): If True, uses GPU texture memory. Supports only:

            - 2D and 3D float32 arrays as input
            - ``(ndim + 1, ndim + 1)`` homogeneous float32 transformation
                matrix
            - ``mode='constant'`` and ``mode='nearest'``
            - ``order=0`` (nearest neighbor) and ``order=1`` (linear
                interpolation)
            - NVIDIA CUDA GPUs

    Returns:
        cupy.ndarray or None:
            The transformed input. If ``output`` is given as a parameter,
            ``None`` is returned.

    .. seealso:: :func:`scipy.ndimage.affine_transform`
    z3HIP currently does not support texture accelerationr   linearr   )datatransformation_matrixoutput_shaper3   interpolationr   border_valueaffine_transformoffset)r?   r>   r?   z no proper affine matrix providedr>   Nr;   zimproper affine shaper   )r;   r;   r]   r   rA   rK   Fr!   rp   r   r|   r   r   r   )$r   is_hiprH   r   affine_transformationr   r   _fix_sequence_argrI   floatrK   r&   zeroslinalginvrolldiagindicesrq   dotreshapeexpand_dimsasarrayrL   r   r$   r/   r%   r(   r   r   rU   r   r   _get_zoom_shift_kernel_get_affine_kernel)r2   matrixr   r   r3   r   r   r|   r   r   	tm_interpmrr   r   rI   r   r   r   r   re   s                       r   r   r   ?  s(   H  A> 	GEG G G %		HHy	-5DJ;G5;<E37;?A A A 	A '555$VUZ5IIF{&  FLOa$7$7=>>>{a<?fl1o111AAArE]FAAAssF^FF\!_
Q..CRCG_FCRC"H%F<EJ
3336777xJ
Q
Q788#2#ss(#2#r'
&	KOOA	!BQB%+++"1"IaBQBi333"1"bqb&	3B383B37{x4>11;!Yv&&Fl<t|DDDhv{':':EJ;K'L'LMMt'V(<(<bAAA\BBB SYt!%y2 229',2G2G 	AAA
]]4<e]44F:DvuLAAAF{4T\**%eYdEJJHg\&$.N	dD.111E%+&&l(;(;<<wFI{afDL9996!5)\4d%)7< < < 	Xvvv....1)\4d%)7< < < JdQh't|<<<!!!SbS&	<dl;;;!!!R%Xq&!!!Mr   c                     | d         |d         k     r| d         |d<   | d         |d         k    r| d         |d<   | d         |d         k     r| d         |d<   | d         |d         k    r| d         |d<   ||fS )Nr   r?    )coormincmaxcs      r   _minmaxr     s    Awaq'QAwaq'QAwaq'QAwaq'Q:r   r?   r   c	                     t          d||           |dk    rd}| }	t          |          }|d         dk     r|dxx         |	j        z  cc<   |d         dk     r|dxx         |	j        z  cc<   |d         |d         k    r|d         |d         g}|d         dk     s|	j        |d         k    rt          d          |	j        }
t	          j        |          }t          j        |          }t          j        |          }t	          j	        ||g| |gg          }t	          j
        |	j                  }||         }|rK|\  }}|dd||gd|d|ggz  }t	          j        |d          dz                       t          j                  }n||         }||dz
  d	z  z  }|dz
  d	z  }|}|||<   t!          |          }t	          j        |
          }|||d         |d         f<   |||d         |d         f<   | ||d         |d         f<   |||d         |d         f<   t	          j        |
t          j        
          }||z
  ||<   t          j
        |          }t          j
        |          }t)          | ||||||||	  	        S )a]  Rotate an array.

    The array is rotated in the plane defined by the two axes given by the
    ``axes`` parameter using spline interpolation of the requested order.

    Args:
        input (cupy.ndarray): The input array.
        angle (float): The rotation angle in degrees.
        axes (tuple of 2 ints): The two axes that define the plane of rotation.
            Default is the first two axes.
        reshape (bool): If ``reshape`` is True, the output shape is adapted so
            that the input array is contained completely in the output. Default
            is True.
        output (cupy.ndarray or ~cupy.dtype): The array in which to place the
            output, or the dtype of the returned array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).
        cval (scalar): Value used for points outside the boundaries of
            the input if ``mode='constant'`` or ``mode='opencv'``. Default is
            0.0
        prefilter (bool): Determines if the input array is prefiltered with
            ``spline_filter`` before interpolation. The default is True, which
            will create a temporary ``float64`` array of filtered values if
            ``order > 1``. If setting this to False, the output will be
            slightly blurred if ``order > 1``, unless the input is prefiltered,
            i.e. it is the result of calling ``spline_filter`` on the original
            input.

    Returns:
        cupy.ndarray or None:
            The rotated input.

    .. seealso:: :func:`scipy.ndimage.rotate`
    rotater   r   r   r?   z invalid rotation plane specifiedr   g      ?r>   rA   )r   listrI   r   rX   deg2radrV   sincosrT   r   rK   ptpr/   r&   rR   tupleidentityr   rq   r   )r2   angleaxesr   r3   r   r   r|   r   	input_arrrI   radr   r   
rot_matrix	img_shapein_plane_shapeiyix
out_boundsout_plane_shape
out_center	in_centerr   r   r   s                             r   r   r     s   R Xud+++xI::DAw{{Q9>!Aw{{Q9>!AwaQa!Aw{{inQ//;<<<>D
-

C
(3--C
(3--C sCj #tSk+ , ,J io..It_N 	*BAq"b>$%r1b>#3 3
 !9Za888 &tz 2 2 	 $D/! 3q89J!#q(IL(L&&L^D!!F"F47DG"F47DG #tF47DG"F47DG[T\222Fz)F4L\&!!F\&!!FE66< $	3 3 3r   c                 p   t          d||           t          j        || j        dt                    }|dk    r\d}t          | t          j        | j        | j                  t          j	        t          j
        |                    d|||||	  	        }n!t          j        ||           }| j        j        dv r|                     t          j                  } t          | ||||          \  }}|j        j        dv }	t          j        |||	           t#          | j                  dk    }
t'          j        | j        |
| j        ||||	|          }t          j
        |t          j        d	          }|j        d
k    rt-          d          |j        |j        k    rt-          d           ||||           |S )a  Shift an array.

    The array is shifted using spline interpolation of the requested order.
    Points outside the boundaries of the input are filled according to the
    given mode.

    Args:
        input (cupy.ndarray): The input array.
        shift (float or sequence): The shift along the axes. If a float,
            ``shift`` is the same for each axis. If a sequence, ``shift``
            should contain one value for each axis.
        output (cupy.ndarray or ~cupy.dtype): The array in which to place the
            output, or the dtype of the returned array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).
        cval (scalar): Value used for points outside the boundaries of
            the input if ``mode='constant'`` or ``mode='opencv'``. Default is
            0.0
        prefilter (bool): Determines if the input array is prefiltered with
            ``spline_filter`` before interpolation. The default is True, which
            will create a temporary ``float64`` array of filtered values if
            ``order > 1``. If setting this to False, the output will be
            slightly blurred if ``order > 1``, unless the input is prefiltered,
            i.e. it is the result of calling ``spline_filter`` on the original
            input.

    Returns:
        cupy.ndarray or None:
            The shifted input.

    .. seealso:: :func:`scipy.ndimage.shift`
    shiftr   r   Nrp   r   r   C)r$   r   r?   zshift must be 1dz len(shift) must equal input.ndim)r   r   r   rI   r   r   r&   onesr$   negativer   rL   r%   r/   r(   r   r   r   rK   r   _get_shift_kernelrq   r   rS   )r2   r   r3   r   r   r|   r   r   r   r   r   re   s               r   r   r   G  s   N WeT***#E5:wFFEx!Iej%+..M$,u--..

 

 "6511;t##LL..E)%D$NN'*d2$n555%+&&0	0J	5;4u)7< < < U$,cBBB:??/000:&&?@@@Xuf%%%Mr   )	grid_modec                
   t          d||           t          j        || j        dt                    }g }t          | j        |          D ]7\  }	}
|                    t          t          |	|
z                                 8t          |          }|dk    rg }g }t          | j        |          D ]|\  }}|dk    rG|                    t	          |          |z             |                    |d         dz
  dz             R|                    d           |                    d           }d}t          | t          j        |          |||||||	  	        }n|r0d}|d	k    rd
}n|dk    rd}|t          j        d| d| d           g }t          | j        |          D ]`\  }}|r|dk    r|                    ||z             &|dk    r|                    |dz
  |dz
  z             K|                    d           at          j        || |          }| j        j        dv r|                     t          j                  } t+          | ||||          \  }}|j        j        dv }t          j        |||           t/          t1          | j                  t1          |                    dk    }t3          j        | j        |||||||          }t          j        |t          j                  } ||||           |S )a	  Zoom an array.

    The array is zoomed using spline interpolation of the requested order.

    Args:
        input (cupy.ndarray): The input array.
        zoom (float or sequence): The zoom factor along the axes. If a float,
            ``zoom`` is the same for each axis. If a sequence, ``zoom`` should
            contain one value for each axis.
        output (cupy.ndarray or ~cupy.dtype): The array in which to place the
            output, or the dtype of the returned array.
        order (int): The order of the spline interpolation, default is 3. Must
            be in the range 0-5.
        mode (str): Points outside the boundaries of the input are filled
            according to the given mode (``'constant'``, ``'nearest'``,
            ``'mirror'``, ``'reflect'``, ``'wrap'``, ``'grid-mirror'``,
            ``'grid-wrap'``, ``'grid-constant'`` or ``'opencv'``).
        cval (scalar): Value used for points outside the boundaries of
            the input if ``mode='constant'`` or ``mode='opencv'``. Default is
            0.0
        prefilter (bool): Determines if the input array is prefiltered with
            ``spline_filter`` before interpolation. The default is True, which
            will create a temporary ``float64`` array of filtered values if
            ``order > 1``. If setting this to False, the output will be
            slightly blurred if ``order > 1``, unless the input is prefiltered,
            i.e. it is the result of calling ``spline_filter`` on the original
            input.
        grid_mode (bool, optional): If False, the distance from the pixel
            centers is zoomed. Otherwise, the distance including the full pixel
            extent is used. For example, a 1d signal of length 5 is considered
            to have length 4 when ``grid_mode`` is False, but length 5 when
            ``grid_mode`` is True. See the following visual illustration:

            .. code-block:: text

                    | pixel 1 | pixel 2 | pixel 3 | pixel 4 | pixel 5 |
                         |<-------------------------------------->|
                                            vs.
                    |<----------------------------------------------->|

            The starting point of the arrow in the diagram above corresponds to
            coordinate location 0 in each mode.

    Returns:
        cupy.ndarray or None:
            The zoomed input.

    .. seealso:: :func:`scipy.ndimage.zoom`
    zoomr   r   r;   r?   g       @r   Nr   r   r   r   z It is recommended to use mode = z instead of z when grid_mode is True.r   rp   r   )r   r   r   r   rA   )r   r   r   rI   r   ziprK   appendr@   roundr   r   r&   r   r   r   rL   r$   r%   r/   r(   r   r   rU   r   r   _get_zoom_kernelrq   )r2   r   r3   r   r   r|   r   r   r   szr   in_sizeout_sizesuggest_moder   r   r   r   re   s                       r   r   r     s[   h VUD)))"4VUCCDLEK&& / /1Ca!e--....&&Lx!$U[,!?!? 	! 	!GX!||E'NNX5666tBx!|s23333Aa    !L

 

  	:  Lz!!.*'9| 9 99 9 9: : : !$U[,!?!? 	 	GX X\\Gh.////AWq[X\:;;;;A"65EEE;t##LL..E)%D$NN'*d2$n555ek**E,,?,?@@7J	/J	<U)Y   |D555XtV$$$Mr   )T)Nr:   r   r   T)r   NNr:   r   r   T)r   TNr:   r   r   T)rV   r   r&   rX   r   
cupy._corer   	cupy.cudar   cupyxr   cupyx.scipy.ndimager   r   r	   prodr   r   r9   rq   ri   rm   ru   r   r   r   r   r   r   r   r   r   r   r   <module>r      s4                               % % % % % % / / / / / / 6 6 6 6 6 6
 M M M$+ $+ $+N "#DL!Q1 Q1 Q1 Q1h  !H # # # #L   4  2 2 2$ <=9=@ @ @ @F KOCGS$)S S S S Sl	 	 	 HI04c3 c3 c3 c3L EHJ J J JZ CFx&+x x x x x x xr   