sparse_identity Subroutine

private subroutine sparse_identity(n, res)

Create an identity matrix (boolean sparse, represented in Yale format) of dimension .

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: n

Rank of the output matrix

type(yale_sparse), intent(out) :: res

Output matrix


Called by

proc~~sparse_identity~~CalledByGraph proc~sparse_identity sparse_identity proc~build_conn_upto_n build_conn_upto_n proc~build_conn_upto_n->proc~sparse_identity proc~check_conn_matrix check_conn_matrix proc~check_conn_matrix->proc~build_conn_upto_n proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~mmpol_init_from_xyz->proc~build_conn_upto_n proc~mmpol_init_from_xyz->proc~check_conn_matrix proc~mmpol_prepare mmpol_prepare proc~mmpol_init_from_xyz->proc~mmpol_prepare proc~ommp_system_from_qm_helper ommp_system_from_qm_helper proc~ommp_system_from_qm_helper->proc~build_conn_upto_n proc~ommp_system_from_qm_helper->proc~check_conn_matrix proc~ommp_system_from_qm_helper->proc~mmpol_prepare proc~mmpol_prepare->proc~build_conn_upto_n proc~init_vdw_for_link_atom init_vdw_for_link_atom proc~init_vdw_for_link_atom->proc~check_conn_matrix proc~mmpol_init_from_mmp mmpol_init_from_mmp proc~mmpol_init_from_mmp->proc~mmpol_prepare proc~init_bonded_for_link_atom init_bonded_for_link_atom proc~init_bonded_for_link_atom->proc~check_conn_matrix proc~c_ommp_system_from_qm_helper C_ommp_system_from_qm_helper proc~c_ommp_system_from_qm_helper->proc~ommp_system_from_qm_helper proc~ommp_init_xyz ommp_init_xyz proc~ommp_init_xyz->proc~mmpol_init_from_xyz proc~ommp_create_link_atom ommp_create_link_atom proc~ommp_create_link_atom->proc~init_vdw_for_link_atom proc~ommp_create_link_atom->proc~init_bonded_for_link_atom proc~c_ommp_init_xyz C_ommp_init_xyz proc~c_ommp_init_xyz->proc~ommp_init_xyz proc~ommp_init_mmp ommp_init_mmp proc~ommp_init_mmp->proc~mmpol_init_from_mmp proc~c_ommp_create_link_atom C_ommp_create_link_atom proc~c_ommp_create_link_atom->proc~ommp_create_link_atom proc~c_ommp_init_mmp C_ommp_init_mmp proc~c_ommp_init_mmp->proc~ommp_init_mmp

Contents

Source Code


Source Code

        subroutine sparse_identity(n, res)
            !! Create an identity matrix (boolean sparse, represented in
            !! Yale format) of dimension \(n\).
            implicit none

            integer(ip), intent(in) :: n
            !! Rank of the output matrix
            type(yale_sparse), intent(out) :: res
            !! Output matrix

            integer(ip) :: i

            res%n = n
            allocate(res%ci(res%n))
            allocate(res%ri(res%n+1))
            
            !$omp parallel do
            do i = 1, n
                res%ci(i) = i
                res%ri(i) = i
            end do
            res%ri(n+1) = n+1

        end subroutine sparse_identity