Skip to content

Commit f78b903

Browse files
committed
doc: determinant
1 parent 4d38582 commit f78b903

File tree

3 files changed

+65
-15
lines changed

3 files changed

+65
-15
lines changed

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,35 @@ Returns the solution array \f$ x \f$ with size \f$ n \f$ (for a single right-han
7070
- This function relies on LAPACK's least-squares solvers, such as [`*GELSS`](@ref la_lapack::gelss).
7171
- If `overwrite_a` is enabled, the original contents of `a` and `b` may be lost.
7272

73-
## `det(A)`
74-
**Type**: Function
75-
**Description**: Determinant of a scalar or square matrix.
76-
**Optional arguments**:
77-
- `overwrite_a`: Option to let A be destroyed.
78-
- `err`: Return state handler.
73+
## [det](@ref la_linalg::det) - Determinant of a scalar or rectangular matrix.
74+
75+
### Syntax
76+
77+
`d = det(a [, overwrite_a] [, err])`
78+
79+
### Description
80+
81+
This function computes the determinant of a square matrix \f$ A \f$. The matrix must be a real matrix of size \f$ [m, n] \f$, and the determinant is computed using an efficient factorization method (e.g., LU decomposition).
82+
83+
### Arguments
84+
85+
- `a`: A real matrix of size \f$ [m, n] \f$, representing the rectangular matrix for which the determinant is calculated. If `overwrite_a`, it is an `inout` argument and may be modified during computation.
86+
- `overwrite_a` (optional, default = `.false.`): A logical flag that determines whether the input matrix `a` can be overwritten. If `.true.`, the matrix `a` may be destroyed and modified in place to save memory.
87+
- `err` (optional): A state return flag of [type(la_state)](@ref la_state_type::la_state). If an error occurs and `err` is not provided, the function will stop execution.
88+
89+
### Return value
90+
91+
The function returns a scalar value representing the determinant of the input matrix \f$ A \f$. The return type is the same as the input matrix (real precision).
92+
93+
### Errors
94+
95+
- Raises [LINALG_VALUE_ERROR](@ref la_state_type::linalg_value_error) if the matrix `a` is not square.
96+
- If `err` is not provided, the function will stop execution on errors.
97+
98+
### Notes
99+
100+
- The determinant of the matrix is computed using the LAPACK [getrf](@ref la_lapack::getrf) backend.
101+
- If `overwrite_a` is enabled, the input matrix `a` will be destroyed during the computation process.
79102

80103
## `inv(A)`
81104
**Type**: Function

fypp/src/la_determinant.fypp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,24 @@ module la_determinant
1313

1414
character(*), parameter :: this = 'determinant'
1515

16-
! Numpy: det(a)
17-
! Scipy: det(a, overwrite_a=False, check_finite=True)
18-
! IMSL: DET(a)
19-
16+
!> @brief Compute the determinant of a rectangular matrix.
17+
!!
18+
!! This function computes the determinant of a real or complex rectangular matrix \f$ A \f$.
19+
!! The determinant is calculated using LU factorization.
20+
!!
21+
!! @param[in,out] A The input square matrix of size \f$ [m, n] \f$. If `overwrite_a` is true,
22+
!! the contents of A may be modified during computation.
23+
!! @param[in] overwrite_a (Optional) If `.true.`, A may be overwritten and destroyed. Default is `.false.`.
24+
!! @param[out] err (Optional) A state return flag. If an error occurs and `err` is not provided,
25+
!! the function will stop execution.
26+
!!
27+
!! @return The determinant of the matrix \f$ A \f$. The result is a `real` scalar value of the same
28+
!! kind as the input matrix.
29+
!!
30+
!! @note This function relies on a matrix factorization approach (e.g., LU decomposition) to compute
31+
!! the determinant efficiently from the [getrf](@ref la_lapack::getrf) backend.
32+
!! @warning If `overwrite_a` is enabled, the original contents of A will be lost.
33+
!!
2034
interface det
2135
#:for rk,rt,ri in ALL_KINDS_TYPES
2236
module procedure la_${ri}$determinant

src/la_determinant.f90

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ module la_determinant
77
implicit none(type,external)
88
private
99

10-
!> Determinant of a rectangular matrix
10+
!> @brief Compute the determinant of a rectangular matrix.
11+
!!
12+
!! This function computes the determinant of a real or complex rectangular matrix \f$ A \f$.
13+
!! The determinant is calculated using LU factorization.
14+
!!
15+
!! @param[in,out] A The input square matrix of size \f$ [m, n] \f$. If `overwrite_a` is true,
16+
!! the contents of A may be modified during computation.
17+
!! @param[in] overwrite_a (Optional) If `.true.`, A may be overwritten and destroyed. Default is `.false.`.
18+
!! @param[out] err (Optional) A state return flag. If an error occurs and `err` is not provided,
19+
!! the function will stop execution.
20+
!!
21+
!! @return The determinant of the matrix \f$ A \f$. The result is a `real` scalar value of the same
22+
!! kind as the input matrix.
23+
!!
24+
!! @note This function relies on a matrix factorization approach (e.g., LU decomposition) to compute
25+
!! the determinant efficiently from the [getrf](@ref la_lapack::getrf) backend.
26+
!! @warning If `overwrite_a` is enabled, the original contents of A will be lost.
27+
!!
1128
public :: det
1229

1330
character(*),parameter :: this = 'determinant'
1431

15-
! Numpy: det(a)
16-
! Scipy: det(a, overwrite_a=False, check_finite=True)
17-
! IMSL: DET(a)
18-
1932
interface det
2033
module procedure la_sdeterminant
2134
module procedure la_ddeterminant

0 commit comments

Comments
 (0)