rotation_matrix Function

public function rotation_matrix(A, rotation) result(G)

Function to create a rotation matrix

This function generates a rotation matrix G based on the input matrix A and the specified rotation indices.

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), DIMENSION(:, :) :: A
integer, intent(in), DIMENSION(2) :: rotation

Return Value real(kind=dp), DIMENSION(SIZE(A, 1),SIZE(A, 2))


Calls

proc~~rotation_matrix~~CallsGraph proc~rotation_matrix rotation_matrix proc~identity_n Identity_n proc~rotation_matrix->proc~identity_n

Called by

proc~~rotation_matrix~~CalledByGraph proc~rotation_matrix rotation_matrix proc~qr_givens_decomposition QR_Givens_decomposition proc~qr_givens_decomposition->proc~rotation_matrix proc~qr_decomposition QR_decomposition proc~qr_decomposition->proc~qr_givens_decomposition proc~eigen Eigen proc~eigen->proc~qr_decomposition proc~is_spd is_SPD proc~is_spd->proc~eigen

Source Code

    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