Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkmat_incidence_factor #138

Closed
zhaotianjing opened this issue Apr 11, 2023 · 0 comments
Closed

mkmat_incidence_factor #138

zhaotianjing opened this issue Apr 11, 2023 · 0 comments

Comments

@zhaotianjing
Copy link
Collaborator

old:
#get an incidence matrix Z to reorder uID to yID by yID = Z*uID
function mkmat_incidence_factor(yID,uID)
Z = spzeros(length(yID),length(uID))

uIDdict = Dict()
for (index,id) in enumerate(uID)
    uIDdict[id]=index
end

rowi = 1
for id in yID
    if haskey(uIDdict,id)
        index = uIDdict[id]
    else
        error(id, " is not found!")
    end
    Z[rowi,index]=1
    rowi = rowi+1
end
return Z

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant