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

Slow edges implementation #67

Open
chanlenn opened this issue Sep 18, 2020 · 6 comments
Open

Slow edges implementation #67

chanlenn opened this issue Sep 18, 2020 · 6 comments

Comments

@chanlenn
Copy link

Hi. I'm pretty new to this Eigen library and I implemented edges, but it uses nested loops and takes around 30 seconds to complete. I compared it to the igl implementation and that takes less than a second. I heard in tutorial that you won't be marking us on runtime, except if it's too slow.

Is this slow implementation okay or am I in the wrong track? Are there any tips or hints on how to implement this faster? Are matrix operations the way to do it?

@otmanon
Copy link
Collaborator

otmanon commented Sep 18, 2020

Yeah i'd like an answer to this too. Specifically my code can take like 45 secs running in debug but less than 5 in release

@chanlenn
Copy link
Author

After researching Eigen and IGL more, I was able to make a fast implementation. I think the question still needs to be answered for other people though.

@alecjacobson
Copy link
Owner

Aim for the correct asymptotic runtime performance. Determining what the correct asymptotic runtime performance is is implicitly part of the assignment.

@cuppajoeman
Copy link

I was also thinking about this. If we naively just check if an edge we want to add is already in the matrix by iterating until we do (or don't) find it, I think the runtime would be O(n^2) (which doesn't seem good, n being the number of edges). Are we suppose to use a hash table or something like that to lower the cost of checking if an edge is already in the matrix?

@rikingurditta
Copy link

There are tradeoffs between time and space too though. My current implementation could be made asymptotically faster if I required it to use asymptotically greater space. Should I prioritize time over space?

@cuppajoeman
Copy link

There is a property about the edges so that you don't have to use different data structures and it runs quickly. (If you find it, I don't think you have to check for the edge through the matrix anymore)

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

5 participants