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