| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/scipy/linalg/__pycache__/ |
Upload File : |
�
d�c�
� �, � d Z ddlZddlmZ dgZdd�ZdS ) z+
Solve the orthogonal Procrustes problem.
� N� )�svd�orthogonal_procrustesTc � � |r)t j | � � } t j |� � }n(t j | � � } t j |� � }| j dk rt d| j z � � �| j |j k r t d| j �d|j �d�� � �t
|j � | � � j � � \ }}}|� |� � }|� � � }||fS )a�
Compute the matrix solution of the orthogonal Procrustes problem.
Given matrices A and B of equal shape, find an orthogonal matrix R
that most closely maps A to B using the algorithm given in [1]_.
Parameters
----------
A : (M, N) array_like
Matrix to be mapped.
B : (M, N) array_like
Target matrix.
check_finite : bool, optional
Whether to check that the input matrices contain only finite numbers.
Disabling may give a performance gain, but may result in problems
(crashes, non-termination) if the inputs do contain infinities or NaNs.
Returns
-------
R : (N, N) ndarray
The matrix solution of the orthogonal Procrustes problem.
Minimizes the Frobenius norm of ``(A @ R) - B``, subject to
``R.T @ R = I``.
scale : float
Sum of the singular values of ``A.T @ B``.
Raises
------
ValueError
If the input array shapes don't match or if check_finite is True and
the arrays contain Inf or NaN.
Notes
-----
Note that unlike higher level Procrustes analyses of spatial data, this
function only uses orthogonal transformations like rotations and
reflections, and it does not use scaling or translation.
.. versionadded:: 0.15.0
References
----------
.. [1] Peter H. Schonemann, "A generalized solution of the orthogonal
Procrustes problem", Psychometrica -- Vol. 31, No. 1, March, 1996.
Examples
--------
>>> import numpy as np
>>> from scipy.linalg import orthogonal_procrustes
>>> A = np.array([[ 2, 0, 1], [-2, 0, 0]])
Flip the order of columns and check for the anti-diagonal mapping
>>> R, sca = orthogonal_procrustes(A, np.fliplr(A))
>>> R
array([[-5.34384992e-17, 0.00000000e+00, 1.00000000e+00],
[ 0.00000000e+00, 1.00000000e+00, 0.00000000e+00],
[ 1.00000000e+00, 0.00000000e+00, -7.85941422e-17]])
>>> sca
9.0
� z&expected ndim to be 2, but observed %szthe shapes of A and B differ (z vs �))
�np�asarray_chkfinite�
asanyarray�ndim�
ValueError�shaper �T�dot�sum)�A�B�check_finite�u�w�vt�R�scales �:/usr/lib/python3/dist-packages/scipy/linalg/_procrustes.pyr r s� � �~ � �� ��#�#��� ��#�#����M�!�����M�!�����v��{�{��A�A�F�J�K�K�K��w�!�'����j�
�G�G�G�Q�W�W�W�� � � � �1�3�7�7�1�:�:�<� � �H�A�q�"� ���b� � �A�
�E�E�G�G�E��e�8�O� )T)�__doc__�numpyr �_decomp_svdr �__all__r � r r �<module>r! s] ��� � � � � � � � � � � � #�
#��N� N� N� N� N� Nr