@@ -506,6 +506,37 @@ Returns a `logical` scalar that is `.true.` if the input matrix is skew-symmetri
506506{!example/linalg/example_is_skew_symmetric.f90!}
507507```
508508
509+ ## ` hermitian ` - Compute the Hermitian version of a rank-2 matrix
510+
511+ ### Status
512+
513+ Experimental
514+
515+ ### Description
516+
517+ Compute the Hermitian version of a rank-2 matrix.
518+ For ` complex ` matrices, the function returns the conjugate transpose (` conjg(transpose(a)) ` ).
519+ For ` real ` or ` integer ` matrices, the function returns the transpose (` transpose(a) ` ).
520+
521+ ### Syntax
522+
523+ ` h = ` [[ stdlib_linalg(module): hermitian (interface)]] ` (a) `
524+
525+ ### Arguments
526+
527+ ` a ` : Shall be a rank-2 array of type ` integer ` , ` real ` , or ` complex ` . The input matrix ` a ` is not modified.
528+
529+ ### Return value
530+
531+ Returns a rank-2 array of the same shape and type as ` a ` . If ` a ` is of type ` complex ` , the Hermitian matrix is computed as ` conjg(transpose(a)) ` .
532+ For ` real ` or ` integer ` types, it is equivalent to the intrinsic ` transpose(a) ` .
533+
534+ ### Example
535+
536+ ``` fortran
537+ {!example/linalg/example_hermitian.f90!}
538+ ```
539+
509540## ` is_hermitian ` - Checks if a matrix is Hermitian
510541
511542### Status
@@ -1456,6 +1487,142 @@ If `err` is not present, exceptions trigger an `error stop`.
14561487{!example/linalg/example_inverse_function.f90!}
14571488```
14581489
1490+ ## ` pinv ` - Moore-Penrose pseudo-inverse of a matrix
1491+
1492+ ### Status
1493+
1494+ Experimental
1495+
1496+ ### Description
1497+
1498+ This function computes the Moore-Penrose pseudo-inverse of a ` real ` or ` complex ` matrix.
1499+ The pseudo-inverse, \( A^{+} \) , generalizes the matrix inverse and satisfies the conditions:
1500+ - \( A \cdot A^{+} \cdot A = A \)
1501+ - \( A^{+} \cdot A \cdot A^{+} = A^{+} \)
1502+ - \( (A \cdot A^{+})^T = A \cdot A^{+} \)
1503+ - \( (A^{+} \cdot A)^T = A^{+} \cdot A \)
1504+
1505+ The computation is based on singular value decomposition (SVD). Singular values below a relative
1506+ tolerance threshold \( \text{rtol} \cdot \sigma_ {\max} \) , where \( \sigma_ {\max} \) is the largest
1507+ singular value, are treated as zero.
1508+
1509+ ### Syntax
1510+
1511+ ` b = ` [[ stdlib_linalg(module): pinv (interface)]] ` (a, [, rtol, err]) `
1512+
1513+ ### Arguments
1514+
1515+ ` a ` : Shall be a rank-2, ` real ` or ` complex ` array of shape ` [m, n] ` containing the coefficient matrix.
1516+ It is an ` intent(in) ` argument.
1517+
1518+ ` rtol ` (optional): Shall be a scalar ` real ` value specifying the relative tolerance for singular value cutoff.
1519+ If ` rtol ` is not provided, the default relative tolerance is \( \text{rtol} = \text{max}(m, n) \cdot \epsilon \) ,
1520+ where \( \epsilon \) is the machine precision for the element type of ` a ` . It is an ` intent(in) ` argument.
1521+
1522+ ` err ` (optional): Shall be a ` type(linalg_state_type) ` value. It is an ` intent(out) ` argument.
1523+
1524+ ### Return value
1525+
1526+ Returns an array value of the same type, kind, and rank as ` a ` with shape ` [n, m] ` , that contains the pseudo-inverse matrix \( A^{+} \) .
1527+
1528+ Raises ` LINALG_ERROR ` if the underlying SVD did not converge.
1529+ Raises ` LINALG_VALUE_ERROR ` if ` a ` has invalid size.
1530+ If ` err ` is not present, exceptions trigger an ` error stop ` .
1531+
1532+ ### Example
1533+
1534+ ``` fortran
1535+ {!example/linalg/example_pseudoinverse.f90!}
1536+ ```
1537+
1538+ ## ` pseudoinvert ` - Moore-Penrose pseudo-inverse of a matrix
1539+
1540+ ### Status
1541+
1542+ Experimental
1543+
1544+ ### Description
1545+
1546+ This subroutine computes the Moore-Penrose pseudo-inverse of a ` real ` or ` complex ` matrix.
1547+ The pseudo-inverse \( A^{+} \) is a generalization of the matrix inverse and satisfies the following properties:
1548+ - \( A \cdot A^{+} \cdot A = A \)
1549+ - \( A^{+} \cdot A \cdot A^{+} = A^{+} \)
1550+ - \( (A \cdot A^{+})^T = A \cdot A^{+} \)
1551+ - \( (A^{+} \cdot A)^T = A^{+} \cdot A \)
1552+
1553+ The computation is based on singular value decomposition (SVD). Singular values below a relative
1554+ tolerance threshold \( \text{rtol} \cdot \sigma_ {\max} \) , where \( \sigma_ {\max} \) is the largest
1555+ singular value, are treated as zero.
1556+
1557+ On return, matrix ` pinva ` ` [n, m] ` will store the pseudo-inverse of ` a ` ` [m, n] ` .
1558+
1559+ ### Syntax
1560+
1561+ ` call ` [[ stdlib_linalg(module): pseudoinvert (interface)]] ` (a, pinva [, rtol] [, err]) `
1562+
1563+ ### Arguments
1564+
1565+ ` a ` : Shall be a rank-2, ` real ` or ` complex ` array containing the coefficient matrix.
1566+ It is an ` intent(in) ` argument.
1567+
1568+ ` pinva ` : Shall be a rank-2 array of the same kind as ` a ` , and size equal to that of ` transpose(a) ` .
1569+ On output, it contains the Moore-Penrose pseudo-inverse of ` a ` .
1570+
1571+ ` rtol ` (optional): Shall be a scalar ` real ` value specifying the relative tolerance for singular value cutoff.
1572+ If not provided, the default threshold is \( \text{max}(m, n) \cdot \epsilon \) , where \( \epsilon \) is the
1573+ machine precision for the element type of ` a ` .
1574+
1575+ ` err ` (optional): Shall be a ` type(linalg_state_type) ` value. It is an ` intent(out) ` argument.
1576+
1577+ ### Return value
1578+
1579+ Computes the Moore-Penrose pseudo-inverse of the matrix \( A \) , \( A^{+} \) , and returns it in matrix ` pinva ` .
1580+
1581+ Raises ` LINALG_ERROR ` if the underlying SVD did not converge.
1582+ Raises ` LINALG_VALUE_ERROR ` if ` pinva ` and ` a ` have degenerate or incompatible sizes.
1583+ If ` err ` is not present, exceptions trigger an ` error stop ` .
1584+
1585+ ### Example
1586+
1587+ ``` fortran
1588+ {!example/linalg/example_pseudoinverse.f90!}
1589+ ```
1590+
1591+ ## ` .pinv. ` - Moore-Penrose Pseudo-Inverse operator
1592+
1593+ ### Status
1594+
1595+ Experimental
1596+
1597+ ### Description
1598+
1599+ This operator returns the Moore-Penrose pseudo-inverse of a ` real ` or ` complex ` matrix \( A \) .
1600+ The pseudo-inverse \( A^{+} \) is computed using Singular Value Decomposition (SVD), and singular values
1601+ below a given threshold are treated as zero.
1602+
1603+ This interface is equivalent to the function [[ stdlib_linalg(module): pinv (interface)]] .
1604+
1605+ ### Syntax
1606+
1607+ ` b = ` [[ stdlib_linalg(module): operator (.pinv.)(interface)]] ` a `
1608+
1609+ ### Arguments
1610+
1611+ ` a ` : Shall be a rank-2 array of any ` real ` or ` complex ` kinds, with arbitrary dimensions \( m \times n \) . It is an ` intent(in) ` argument.
1612+
1613+ ### Return value
1614+
1615+ Returns a rank-2 array with the same type, kind, and rank as ` a ` , that contains the Moore-Penrose pseudo-inverse of ` a ` .
1616+
1617+ If an exception occurs, or if the input matrix is degenerate (e.g., rank-deficient), the returned matrix will contain ` NaN ` s.
1618+ For more detailed error handling, it is recommended to use the ` subroutine ` or ` function ` interfaces.
1619+
1620+ ### Example
1621+
1622+ ``` fortran
1623+ {!example/linalg/example_pseudoinverse.f90!}
1624+ ```
1625+
14591626## ` get_norm ` - Computes the vector norm of a generic-rank array.
14601627
14611628### Status
0 commit comments