KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
question is easy. Lets say you have function double interpolate (double x); and you have a table that has map of known x-> y for example 5 15 7 18 10 22 note: real tables are bigger ofc, this is just example. so for 8 you would return 18+((8-7)/(10-7))*(22-18)=19.3333333 One cool way I found is http://www.bnikolic.co.uk/blog/cpp-map-interp.html (long story short it uses std::map, key= x, value = y for x->y data pairs). If somebody asks what is the if else if else way in title it is basically: if ((x>=5) && (x<=7)) { //interpolate } else if((x>=7) && x<=10) { //interpolate } So is there a more clever way to do it or map way is the state of the art? :) Btw I prefer soutions in C++ but obviously any language solution that has 1:1 mapping to C++ is nice.
Tags (comma-separated)
Save Edits
Cancel