How can I generate a map key for this vector in MATLAB?

前端 未结 3 1695
名媛妹妹
名媛妹妹 2021-01-18 23:39

I have a function that is looking at a number of elements. Each element is of the form of an 8x1 column vector. Each entry in the vector is an integer less than 1000. Every

3条回答
  •  温柔的废话
    2021-01-19 00:15

    your idea is good. but you need to find a better hash function. use some standard hash function. There is an implementation of 'sha' algorithms you's like to see:

    http://www.se.mathworks.com/matlabcentral/fileexchange/31795-sha-algorithms-160224256384-512

    If you find the sha algorithm slow then you can probably resort to some tricks. One that i can think of now is following:

    1. take a seed number > 1000 e.g. 1024
    2. divide each number in the vector by the seed and store the remainder in a string.
    3. concatenate all the remainders which will serve as your 'code' for your vector element. which can be used for comparison when a you see a new element.

    this should probably work but you'll have to check.

提交回复
热议问题