
    -iN                     P    S r SSKrSSKJrJrJrJr  SSKJ	r	J
r
  S rS rS rS	 rg)
a  
This is a module evaluating the objective/constraint function with Nan/Inf handling.

Translated from Zaikun Zhang's modern-Fortran reference implementation in PRIMA.

Dedicated to late Professor M. J. D. Powell FRS (1936--2015).

Python translation by Nickolai Belakovski.
    N   )FUNCMAX	CONSTRMAXREALMAX	DEBUGGING)matprodprimasumc                 z    SU [         R                  " U 5      '   [         R                  " U [        * [        5      n U $ )ze
This function moderates a decision variable. It replaces NaN by 0 and Inf/-Inf by
REALMAX/-REALMAX.
r   )npisnanclipr   )xs    U/var/www/html/venv/lib/python3.13/site-packages/scipy/_lib/pyprima/common/evaluate.py	moderatexr      s.    
 AbhhqkN
G8W%AH    c                     [         R                  " U 5      (       a  [        OU n [         R                  " U [        * [        5      n U $ )z
This function moderates the function value of a MINIMIZATION problem. It replaces
NaN and any value above FUNCMAX by FUNCMAX.
)r   r   r   r   r   )fs    r   	moderatefr      s2    
 88A;;AA
G8W%A Hr   c                 |    [         R                  " U S[        S9  [         R                  " U [        * [        5      n U $ )z
This function moderates the constraint value, the constraint demanding this value
to be NONNEGATIVE. It replaces any value below -CONSTRMAX by -CONSTRMAX, and any
NaN or value above CONSTRMAX by CONSTRMAX.
F)copynan)r   
nan_to_numr   r   )cs    r   	moderatecr   '   s-     MM!%Y/
I:y)AHr   c                    Ub  [        U5      OSn[        (       a&  [        [        R                  " U5      5      (       a   e[        R
                  " XR-   5      nUb  [        XR                  5      U-
  USU& [        [        R                  " U5      5      (       a%  [        U5      n[        R                  " U5      U-  nO0U " [        U5      5      u  ovUS& [        U5      n[        XeS 5      XeS& [        (       au  [        R                  " U5      (       d  [        R                  " U5      (       a   e[        [        R                  " U5      [        R                  " U5      -  5      (       a   eXv4$ )z
This function evaluates CALCFC at X, returning the objective function value and the
constraint value. Nan/Inf are handled by a moderated extreme barrier.
Nr   )lenr   anyr   r   zerosr   Tr	   onesr   r   r   isposinf)calcfcr   m_nlconamatbvecm_lconconstrr   s           r   evaluater(   2   s%    *SYF y rxx{#### XXf&'F!!VV,t3w
288A; QK!A%#IaL1&'?
 aL#F7O4w y HHQKK2;;q>>22rxx'"++f*==>>>>9r   )__doc__numpyr   constsr   r   r   r   linalgr   r	   r   r   r   r(    r   r   <module>r.      s,     : : %
	1r   