
    
9jY                        S SK Jr  S SKrS SKJr  S SKJr  S SKJr  \R                  " SSSS	S
S9r\R                  " SSSSSS9r	 S     SS jjr
     S   SS jjrg)    )annotationsN)_core)texture)runtimez%U texObj, raw float32 m, uint64 widthzT transformed_imagea#  
    float3 pixel = make_float3(
        (float)(i / width),
        (float)(i % width),
        1.0f
    );
    float x = dot(pixel, make_float3(m[0],  m[1],  m[2])) + .5f;
    float y = dot(pixel, make_float3(m[3],  m[4],  m[5])) + .5f;
    transformed_image = tex2D<T>(texObj, y, x);
    ,cupyx_texture_affine_transformation_2d_arrayz
    inline __host__ __device__ float dot(float3 a, float3 b)
    {
        return a.x * b.x + a.y * b.y + a.z * b.z;
    }
    )preamblez4U texObj, raw float32 m, uint64 height, uint64 widthzT transformed_volumea  
    float4 voxel = make_float4(
        (float)(i / (width * height)),
        (float)((i % (width * height)) / width),
        (float)((i % (width * height)) % width),
        1.0f
    );
    float x = dot(voxel, make_float4(m[0],  m[1],  m[2],  m[3])) + .5f;
    float y = dot(voxel, make_float4(m[4],  m[5],  m[6],  m[7])) + .5f;
    float z = dot(voxel, make_float4(m[8],  m[9],  m[10], m[11])) + .5f;
    transformed_volume = tex3D<T>(texObj, z, y, x);
    ,cupyx_texture_affine_transformation_3d_arrayz
    inline __host__ __device__ float dot(float4 a, float4 b)
    {
        return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
    }
    c                   [         R                  " U R                  [         R                  5      (       a  [        R
                  nO[         R                  " U R                  [         R                  5      (       a  [        R                  nO][         R                  " U R                  [         R                  5      (       a  [        R                  nO[        SU R                   35      eUS:X  a  [        R                  nO&US:X  a  [        R                  nO[        SU S35      eUS:X  a  [        R                  nO&US:X  a  [        R                  nO[        SU S35      eUS	:X  a  [        R                  nO&US
:X  a  [        R                   nO[        SU S35      e["        R$                  " U R&                  S-  SSSU5      n["        R(                  " U/U R*                  S S S2   Q76 n["        R,                  " [        R.                  US9n["        R0                  " U4U R2                  -  X#U4S9n	["        R4                  " X5      n
UR7                  U 5        U
$ )NzUnsupported data type nearestconstantzUnsupported address mode z (supported: constant, nearest)linearzUnsupported filter mode z (supported: nearest, linear)element_typenormalized_floatzUnsupported read mode z, (supported: element_type, normalized_float)   r   )cuArr)borderColors)cupy
issubdtypedtypeunsignedintegerr   cudaChannelFormatKindUnsignedintegercudaChannelFormatKindSignedfloatingcudaChannelFormatKindFloat
ValueErrorcudaAddressModeClampcudaAddressModeBordercudaFilterModePointcudaFilterModeLinearcudaReadModeElementTypecudaReadModeNormalizedFloatr   ChannelFormatDescriptoritemsize	CUDAarrayshapeResourceDescriptorcudaResourceTypeArrayTextureDescriptorndimTextureObject	copy_from)dataaddress_modefilter_mode	read_modeborder_colorfmt_kindtexture_fmtarrayres_desctex_desctex_objs              H/home/wildlama/miniconda3/lib/python3.13/site-packages/cupyx/_texture.py_create_texture_objectr:   7   s    tzz4#7#78888	T\\	2	266	T]]	3	3551$**>??y 33		#44'~ 6- -. 	. i11		 22&{m 4+ ,- 	- N"33		(	(77	$YK 0: :; 	; 111aH.K k=DJJtt,<=E))%%U4H ((	499$k"%'H ##H7G	OODN    c                
   U R                   nUS:  d  US:  a  [        S5      eU R                  nU[        R                  :w  a  [        SU S35      eUS;  a  [        SU S35      eUR
                  US	-   US	-   4:w  a  [        S
5      e[        U UUSUS9n	US:X  a  [        n
O[        n
Uc  U R
                  nUc  [        R                  " X(S9nO[        U[        [        R                  45      (       a8  U[        R                  :w  a  [        SU S35      e[        R                  " X#S9nOF[        U[        R                  5      (       a  UR
                  U:w  a  [        S5      eO[        S5      eU
" X/US	S QUP76   U$ )a  
Apply an affine transformation.

The method uses texture memory and supports only 2D and 3D float32 arrays
without channel dimension.

Args:
    data (cupy.ndarray): The input array or texture object.
    transformation_matrix (cupy.ndarray): Affine transformation matrix.
        Must be a homogeneous and have shape ``(ndim + 1, ndim + 1)``.
    output_shape (tuple of ints): Shape of output. If not specified,
        the input array shape is used. Default is None.
    output (cupy.ndarray or ~cupy.dtype): The array in which to place the
        output, or the dtype of the returned array. If not specified,
        creates the output array with shape of ``output_shape``. Default is
        None.
    interpolation (str): Specifies interpolation mode: ``'linear'`` or
        ``'nearest'``. Default is ``'linear'``.
    mode (str): Specifies addressing mode for points outside of the array:
        (`'constant'``, ``'nearest'``). Default is ``'constant'``.
    border_value: Specifies value to be used for coordinates outside
        of the array for ``'constant'`` mode. Default is 0.

Returns:
    cupy.ndarray:
        The transformed input.

.. seealso:: :func:`cupyx.scipy.ndimage.affine_transform`
      zdTexture memory affine transformation is defined only for 2D and 3D arrays without channel dimension.zRTexture memory affine transformation is available only for float32 data type (not ))r   r   zUnsupported interpolation z (supported: linear, nearest)   z.Matrix must be have shape (ndim + 1, ndim + 1)r   )r/   r0   r1   r2   N)r   zOutput shapes do not matchz/Output must be None, cupy.ndarray or cupy.dtype)r+   r   r   r   float32r'   r:   !_affine_transform_2d_array_kernel!_affine_transform_3d_array_kernelzeros
isinstancetypendarray)r.   transformation_matrixoutput_shapeoutputinterpolationmodeborder_valuer+   r   texture_objectkernels              r9   affine_transformationrP   r   s   J 99DqdQh:; 	; JJE <<A7!E F 	F 11( 8+ ,- 	- ""tax&::IJJ+D9=8E6D9E	GN qy22zz~L6	FT4::.	/	/T\\!  J &xq* + + L7	FDLL	)	)<<<'9:: ( JKK
>L<3CLVLMr;   )r   )r/   strr0   rQ   r1   rQ   )NNr   r   r   )rK   rQ   rL   rQ   )
__future__r   r   r   	cupy.cudar   r   ElementwiseKernelrB   rC   r:   rP    r;   r9   <module>rV      s    "     %*$;$;+-B	 3%	 !* %*$;$;: 3!%	 !8 )*	8),8(+8 '*8z (,!%/7&0'(U *-	U
 !$Ur;   