Efficient comparison of 100.000 vectors

后端 未结 10 2032
礼貌的吻别
礼貌的吻别 2021-01-31 21:20

I save 100.000 Vectors of in a database. Each vector has a dimension 60. (int vector[60])

Then I take one and want present vectors to the user in order of decreasing sim

10条回答
  •  一整个雨季
    2021-01-31 22:00

    Uh, no?

    You only have to do all 99,999 against the one you picked (rather than all n(n-1)/2 possible pairs), of course, but that's as low as it goes.


    Looking at your response to nsanders's answer, it is clear you are already on top of this part. But I've thought of a special case where computing the full set of comparisons might be a win. If:

    • the list comes in slowly (say your getting them from some data acquisition system at a fixed, low rate)
    • you don't know until the end which one you want to compare to
    • you have plenty of storage
    • you need the answer fast when you do pick one (and the naive approach isn't fast enough)
    • Looks are faster than computing

    then you could pre-compute the as the data comes in and just lookup the results per pair at sort time. This might also be effective if you will end up doing many sorts...

提交回复
热议问题