| 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/sparse/linalg/tests/__pycache__/ |
Upload File : |
�
d�c
$ � � � d Z ddlZddlmZmZmZ ddlZddlZ ddl
Z ddlmZm
Z
G d� de j j j � � Z G d� d� � Z G d � d
� � ZdS )z8Test functions for the sparse.linalg._onenormest module
� N)�assert_allclose�assert_equal�assert_)�_onenormest_core�_algorithm_2_2c �@ � e Zd ZdZd� Zd� Zd� Zd� Zed� � � Z dS )�MatrixProductOperatorz0
This is purely for onenormest testing.
c � � |j dk s|j dk rt d� � �|j d |j d k rt d� � �|| _ || _ d| _ |j d |j d f| _ d S )N� z'expected ndarrays representing matrices� r zincompatible shapes)�ndim�
ValueError�shape�A�B)�selfr r s �K/usr/lib/python3/dist-packages/scipy/sparse/linalg/tests/test_onenormest.py�__init__zMatrixProductOperator.__init__ s} � ��6�Q�;�;�!�&�A�+�+��F�G�G�G��7�1�:�����#�#��2�3�3�3��������� ��g�a�j�!�'�!�*�-��
�
�
� c �f � t j | j t j | j |� � � � S �N��np�dotr r �r �xs r �_matveczMatrixProductOperator._matvec �$ � ��v�d�f�b�f�T�V�Q�/�/�0�0�0r c �f � t j t j || j � � | j � � S r r r s r �_rmatveczMatrixProductOperator._rmatvec s$ � ��v�b�f�Q���'�'���0�0�0r c �f � t j | j t j | j |� � � � S r r )r �Xs r �_matmatzMatrixProductOperator._matmat! r r c �J � t | j j | j j � � S r )r r �Tr )r s r r% zMatrixProductOperator.T$ s � �$�T�V�X�t�v�x�8�8�8r N)
�__name__�
__module__�__qualname__�__doc__r r r r# �propertyr% � r r r r su � � � � � �� �.� .� .�1� 1� 1�1� 1� 1�1� 1� 1� �9� 9� �X�9� 9� 9r r c �� � e Zd Zej j d� � � Zej j d� � � Zd� Zej j d� � � Z d� Z
d� Zej j d� � � Z
d� Zd S )
�TestOnenormestc � � t j � d� � d}d}d}d}g }g }g }g }t |� � D ]�} t j � t j � ||� � � � }
t |
|
j ||� � \ }}}
}}|�
|� � |�
t j � |
d� � � � |�
|� � |�
|� � ��t j |t �� � }t j |t �� � }t j ||z
� � |z }||z }t dt j |� � cxk od k nc � � t# t j |� � d� � t d
t j |� � cxk odk nc � � t j |dk � � }|t |� � z }t d
|cxk odk nc � � t dt j |� � cxk odk nc � � d S )N�� r �d � � r ��dtype�G�z��?g �?皙�����?g�������?�+����=��������?gffffff�?� @� @)r �random�seed�range�scipy�linalg�inv�randnr r% �append�norm�array�float�absr �meanr �max�
count_nonzero�r �t�n�itmax�nsamples�observed�expected�
nmult_list�nresample_list�ir �est�v�w�nmults�
nresamples�relative_errors�underestimation_ratio�nexact�proportion_exacts r �test_onenormest_table_3_t_2z*TestOnenormest.test_onenormest_table_3_t_2+ s] � � � ���t����
�������������
����x��� .� .�A��� � ������A�!6�!6�7�7�A�,<�Q���Q��,N�,N�)�C��A�v�z��O�O�C� � � ��O�O�E�L�-�-�a��3�3�4�4�4����f�%�%�%��!�!�*�-�-�-�-��8�H�E�2�2�2���8�H�E�2�2�2���&��H�!4�5�5��@�� !)�8� 3����r�w�4�5�5�;�;�;�;��;�;�;�;�<�<�<� �R�V�N�+�+�Q�/�/�/���r�w�~�.�.�4�4�4�4��4�4�4�4�5�5�5� �!�/�E�"9�:�:��!�E�(�O�O�3����&�-�-�-�-��-�-�-�-�.�.�.� ��b�g�j�)�)�/�/�/�/�C�/�/�/�/�0�0�0�0�0r c �& � t j � d� � d}d}d}d}g }g }g }g }t |� � D ]�} t j � dd||f�� � }
t |
|
j ||� � \ }}}
}}|� |� � |� t j �
|
d � � � � |� |� � |� |� � ��t j |t �
� � }t j |t �
� � }t j
||z
� � |z }||z }t dt j |� � cxk odk nc � � t! t j |� � d
� � t j |dk � � }|t |� � z }t d|cxk odk nc � � t dt j |� � cxk odk nc � � d S )Nr/ � r0 r1 r2 ���r )�sizer r3 r8 r5 r r7 g333333�?g �?r9 r: )r r; r<