You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -331,13 +331,73 @@ where \f$ \Sigma^+ \f$ is the inverse of the nonzero singular values in \f$ \Sig
331
331
**Description**: Singular values $S$ from $A = U S V^t$.
332
332
**Usage**: `s = svdvals(A)` where `s` is a real array with the same precision as `A`.
333
333
334
-
## `eye(m)`
335
-
**Type**: Function
336
-
**Description**: Identity matrix of size `m`.
337
-
**Optional arguments**:
338
-
-`n`: Optional column size.
339
-
-`mold`: Optional datatype (default: real64).
340
-
-`err`: Error handler.
334
+
## [diag](@ref la_eye::diag) - Diagonal matrix.
335
+
336
+
### Syntax
337
+
338
+
`d = diag(n, source [, err])` for scalar input
339
+
`d = diag(source(:) [, err])` for array input
340
+
341
+
### Description
342
+
343
+
This function generates a square diagonal matrix where the diagonal elements are populated either by a scalar value or an array of values. The size of the matrix is determined by the input parameter \f$n\f$ or the size of the input array.
344
+
If a scalar is provided, the diagonal elements are all set to the same value. If an array is provided, its length determines the size of the matrix, and its elements are placed along the diagonal.
345
+
346
+
### Arguments
347
+
348
+
-`n`: The size of the square matrix (only used if a scalar is provided for the diagonal).
349
+
-`source`:
350
+
- If a scalar, this value is used to populate all the diagonal elements of the matrix.
351
+
- If an array, the elements of the array are used to populate the diagonal of the matrix. The size of the array determines the matrix size.
352
+
-`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.
353
+
354
+
### Return value
355
+
356
+
The function returns a matrix of size \f$n \times n\f$, where the diagonal elements are either all equal to the scalar `source` or populated by the values from the input array.
357
+
358
+
### Errors
359
+
360
+
- Raises [LINALG_VALUE_ERROR](@ref la_state_type::linalg_value_error) if the dimensions of the matrix are invalid or if the array size does not match the expected matrix size.
361
+
- If `err` is not provided, the function will stop execution on errors.
362
+
363
+
### Notes
364
+
365
+
- The diagonal elements are set to the specified scalar or the array values in the order they appear in the input.
366
+
- If the `err` parameter is provided, the error state of the function will be returned.
367
+
368
+
369
+
## [eye](@ref la_eye::eye) - Identity matrix.
370
+
371
+
### Syntax
372
+
373
+
`eye = eye(m [, n] [, mold] [, err])`
374
+
375
+
### Description
376
+
377
+
This function constructs an identity matrix of size \f$m \times n\f$, where the diagonal elements are set to 1 and all off-diagonal elements are set to 0. If only the number of rows \f$m\f$ is provided, a square matrix of size \f$m \times m\f$ is returned. The matrix is populated with a real data type, by default `real(real64)`, or a type specified by the user.
378
+
379
+
### Arguments
380
+
381
+
-`m`: The number of rows of the identity matrix.
382
+
-`n` (optional): The number of columns of the identity matrix. If omitted, the matrix is square (\f$m \times m\f$).
383
+
-`mold` (optional): The data type to define the return type. Defaults to `real(real64)`.
384
+
-`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.
385
+
386
+
### Return value
387
+
388
+
The function returns a matrix of size \f$m \times n\f$ (or \f$m \times m\f$ if \f$n\f$ is omitted) with diagonal elements set to 1 and all other elements set to 0.
389
+
390
+
### Errors
391
+
392
+
- Raises [LINALG_VALUE_ERROR](@ref la_state_type::linalg_value_error) if the dimensions of the matrix are invalid (e.g., negative values).
393
+
- If `err` is not provided, the function will stop execution on errors.
394
+
395
+
### Notes
396
+
397
+
- The identity matrix is constructed with the specified data type, which defaults to `real(real64)` if no type is specified.
398
+
- The `mold` scalar is used to provide a function return type.
399
+
- If the `err` parameter is provided, the error state of the function will be returned.
400
+
341
401
342
402
## `eigvals(A)`
343
403
**Type**: Function
@@ -370,19 +430,9 @@ where \f$ \Sigma^+ \f$ is the inverse of the nonzero singular values in \f$ \Sig
370
430
-`overwrite_a`: Option to let A be destroyed.
371
431
-`err`: Return state handler.
372
432
373
-
## `diag(n, source)`
374
-
**Type**: Function
375
-
**Description**: Diagonal matrix from scalar input value.
376
-
**Optional arguments**:
377
-
-`err`: Error handler.
378
433
379
-
## `diag(source)`
380
-
**Type**: Function
381
-
**Description**: Diagonal matrix from array input values.
382
-
**Optional arguments**:
383
-
-`err`: Error handler.
384
434
385
-
## [qr](@ref la_qr::qr) - Compute the QR factorization of a matrix.
435
+
## [qr](@ref la_qr::qr) - QR factorization of a matrix.
386
436
387
437
### Syntax
388
438
@@ -459,6 +509,83 @@ The workspace size \f$ lwork \f$ that should be allocated before calling the QR
459
509
- This subroutine is useful for preallocating memory for QR factorization in large systems.
460
510
- It is important to ensure that the workspace size is correctly allocated before proceeding with QR factorization to avoid memory issues.
461
511
512
+
## [schur](@ref la_schur::schur) - Schur decomposition of a matrix.
This subroutine computes the Schur decomposition of a `real` or `complex` matrix \f$ A = Z T Z^H \f$, where \f$ Z \f$ is an orthonormal/unitary matrix, and \f$ T \f$ is an upper-triangular or quasi-upper-triangular matrix. The matrix \f$ A \f$ has size \f$ [m,m] \f$.
521
+
522
+
The decomposition produces:
523
+
- \f$ T \f$, which is upper-triangular for `complex` matrices and quasi-upper-triangular for `real` matrices (with possible \f$ 2 \times 2 \f$ blocks on the diagonal).
524
+
- \f$ Z \f$, the transformation matrix, which is optional.
525
+
- Optionally, the eigenvalues corresponding to the diagonal elements of \f$ T \f$.
526
+
527
+
If a pre-allocated workspace is provided, no internal memory allocations take place.
528
+
529
+
### Arguments
530
+
531
+
-`a`: A `real` or `complex` matrix of size \f$ [m,m] \f$. If `overwrite_a = .false.`, this is an input argument. If `overwrite_a = .true.`, it is an `inout` argument and is overwritten upon return.
532
+
-`t`: A rank-2 array of the same type and kind as `a`, representing the Schur form of `a`. This is an output argument with shape \f$ [m,m] \f$.
533
+
-`z` (optional): A rank-2 array of the same type and kind as `a`, representing the unitary/orthonormal transformation matrix \f$ Z \f$. This is an output argument with shape \f$ [m,m] \f$.
534
+
-`eigvals` (optional): A complex array of size \f$ [m] \f$, representing the eigenvalues that appear on the diagonal of \f$ T \f$. This is an output argument.
535
+
-`storage` (optional): A rank-1 array of the same type and kind as `a`, providing working storage for the solver. Its minimum size can be determined by a call to [schur_space](@ref la_schur::schur_space). This is an input argument.
536
+
-`overwrite_a` (optional, default = `.false.`): A logical flag that determines whether the input matrix `a` can be overwritten. If `.true.`, the matrix `a` is used as temporary storage and overwritten to avoid internal memory allocation. This is an input argument.
537
+
-`err` (optional): A [type(la_state)](@ref la_state_type::la_state) variable that returns the error state. If not provided, the function will stop execution on error.
538
+
539
+
### Return value
540
+
541
+
The Schur decomposition matrices \f$ T \f$ and optionally \f$ Z \f$ are returned in the corresponding arguments.
542
+
543
+
### Errors
544
+
545
+
- Raises [LINALG_VALUE_ERROR](@ref la_state_type::linalg_value_error) if the sizes of the matrices are incompatible.
546
+
- Raises [LINALG_ERROR](@ref la_state_type::linalg_error) if the algorithm did not converge.
547
+
- If `err` is not provided, exceptions will trigger an `error stop`.
548
+
549
+
### Notes
550
+
551
+
- This subroutine computes the Schur decomposition using LAPACK's Schur decomposition routines ([GEES](@ref la_lapack:gees)).
552
+
- Sorting options for eigenvalues can be requested, utilizing LAPACK's eigenvalue sorting mechanism.
553
+
- If `overwrite_a` is enabled, the input matrix `a` will be modified during computation.
554
+
555
+
556
+
## [schur_space](@ref la_schur::schur_space) - Workspace size for Schur decomposition.
557
+
558
+
### Syntax
559
+
560
+
`call schur_space(a, lwork [, err])`
561
+
562
+
### Description
563
+
564
+
This subroutine computes the minimum workspace size required for performing Schur decomposition. The size of the workspace array needed is determined based on the input matrix \f$ A \f$.
565
+
566
+
The input matrix \f$ A \f$ has size \f$ [m,m] \f$, and the output value \f$ lwork \f$ represents the minimum size of the workspace array that should be allocated for Schur decomposition operations.
567
+
568
+
### Arguments
569
+
570
+
-`a`: A `real` or `complex` matrix of size \f$ [m,m] \f$, representing the input matrix used to determine the required workspace size.
571
+
-`lwork`: An integer variable that will return the minimum workspace size required for Schur decomposition.
572
+
-`err` (optional): A [type(la_state)](@ref la_state_type::la_state) variable that returns the error state. If not provided, the function will stop execution on error.
573
+
574
+
### Return value
575
+
576
+
The workspace size \f$ lwork \f$ that should be allocated before calling the Schur decomposition routine is returned.
577
+
578
+
### Errors
579
+
580
+
- Raises [LINALG_ERROR](@ref la_state_type::linalg_error) if there is an issue determining the required workspace size.
581
+
- If `err` is not provided, exceptions will trigger an `error stop`.
582
+
583
+
### Notes
584
+
585
+
- This subroutine is useful for preallocating memory for Schur decomposition in large systems.
586
+
- It is important to ensure that the workspace size is correctly allocated before proceeding with Schur decomposition to avoid memory issues.
587
+
588
+
462
589
463
590
# BLAS, LAPACK
464
591
Modern Fortran modules with full explicit typing features are available as modules `la_blas` and `la_lapack`.
0 commit comments