Function to create a rotation matrix
This function generates a rotation matrix G based on the input matrix A and the specified rotation indices.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | DIMENSION(:, :) | :: | A | ||
integer, | intent(in), | DIMENSION(2) | :: | rotation |
FUNCTION rotation_matrix(A,rotation) RESULT(G) REAL(dp), DIMENSION(:, :), INTENT(IN) :: A INTEGER, DIMENSION(2), INTENT(IN) :: rotation REAL(dp), DIMENSION(SIZE(A, 1),SIZE(A, 2)) :: G REAL(dp) :: frac, val_1, val_2 INTEGER :: i, j i = rotation(1) j = rotation(2) G = Identity_n(SIZE(A, 1)) val_1 = A(j, j) val_2 = A(i, j) frac = SQRT(val_1**2 + val_2**2) G(i,i) = val_1 / frac G(j,j) = val_1 / frac G(i,j) = - val_2 / frac G(j,i) = val_2 / frac END FUNCTION rotation_matrix