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
`dim1`: Shall be a scalar of default type `integer`.
251
-
This is an `intent(in)` argument.
252
-
253
-
`dim2`: Shall be a scalar of default type `integer`.
254
-
This is an `intent(in)` and `optional` argument.
250
+
-`dim1`: A scalar of type `integer`. This is an `intent(in)` argument and specifies the number of rows.
251
+
-`dim2`: A scalar of type `integer`. This is an optional `intent(in)` argument specifying the number of columns. If not provided, the matrix is square (`dim1 = dim2`).
252
+
-`mold`: A scalar of any supported `integer`, `real`, or `complex` type. This is an optional `intent(in)` argument. If provided, the returned identity matrix will have the same type and kind as `mold`. If not provided, the matrix will be of type `real(real64)` by default.
255
253
256
254
### Return value
257
255
258
-
Return the identity matrix, i.e. a matrix with ones on the main diagonal and zeros elsewhere. The return value is of type `integer(int8)`.
259
-
The use of `int8` was suggested to save storage.
256
+
Returns the identity matrix, with ones on the main diagonal and zeros elsewhere.
257
+
258
+
- By default, the return value is of type `real(real64)`, which is recommended for arithmetic safety.
259
+
- If the `mold` argument is provided, the return value will match the type and kind of `mold`, allowing for arbitrary `integer`, `real`, or `complex` return types.
260
260
261
-
#### Warning
261
+
###Example
262
262
263
-
Since the result of `eye` is of `integer(int8)` type, one should be careful about using it in arithmetic expressions. For example:
264
263
```fortran
265
-
!> Be careful
266
-
A = eye(2,2)/2 !! A == 0.0
267
-
!> Recommend
268
-
A = eye(2,2)/2.0 !! A == diag([0.5,0.5])
264
+
!> Return default type (real64)
265
+
A = eye(2,2)/2 !! A == diag([0.5_dp, 0.5_dp])
266
+
!> Return 32-bit complex
267
+
A = eye(2,2, mold=(0.0,0.0))/2 !! A == diag([(0.5,0.5), (0.5,0.5)])
269
268
```
270
269
271
-
### Example
272
-
273
270
```fortran
274
271
{!example/linalg/example_eye1.f90!}
275
272
```
@@ -509,6 +506,37 @@ Returns a `logical` scalar that is `.true.` if the input matrix is skew-symmetri
509
506
{!example/linalg/example_is_skew_symmetric.f90!}
510
507
```
511
508
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)`).
0 commit comments