c# - Heavy computations analysis/optimization -


First of all, I do not have the multiplication, division is in operation, so I use the transfer / add, overflow-multiplication, precalculations Can i etc. I'm just comparing one n-bit binary number to another, but according to the algorithm, the amount of such tasks is very large. Here it is:

  1. In this, the sequences of 0 and 1 are divided into blocks. The length of a sequence is SO, the length of a block is N which has some power of two (4,8,16,32, etc.). The amount of block n = s / n, there is no rocket science here.
  2. According to the chosen n, I am creating a set of all potential N-bit binary numbers, which are 2 ^ N-1 objects.
  3. After this I need to compare each binary number with each block from the source chain and calculate how often for each binary number , for example:
    S: 000000001111111100000000111111110000000011111111 ... (0000000011111111 is repeated twice, 16 bit x 6 = 96bits overall)
    N: 8
    blocks: {00000000, 11111111, 00000000, 1111111, .. .}
    Count:

.

  // _n = S / N; // _N2 = Math.Pow (2, n) -1 / s = 96, n = 8, n = 12, 2 ^ n -1 = 255 for this specific case // sourceEpsilons = input, list and block from Lieutenant list of ; String & gt; [_n] var x = new int [_n]; // The result of the frequencies for array (var i = 0; i  

Even with small S. (2 ^ N-1) (S / N) iterations, the number increases with N = 64 2 ^ 64 = (max. Value type length) is so beautiful that I'm sure the loop needs to be adapted and possibly the approach should be converted into a cardinal (c # implementation N = 32 to 2h @ dual-core pc w / parallel.For) Takes. Any idea how to make the above plan less time and resource consumption ? It seems that I have to precomput the binary number and the first loop gets rid of it by reading "I" from the file and evaluating it with the "on-the-fly" block, but filesyes (2 ^ n) * n bytes ((2 ^ N -1) +1) * N) Anyway, it is unacceptable.

It looks like what you want, it's a count how many times each specific block in your sequence Returns; If this is the case, compare each block for the all possible blocks and then the synergy is a horrible way to go about it. You're better off making a dictionary that blocks the map; Something like this:

  var dict = Dictionary & lt; Int, int & gt; (); For (int j = 0; j and lt; block_conta; j ++) {int count; If (dict.TryGetValue (Block [J], Count Out)) // First seen block, so increase [dict [block] [number] = count + 1; } And // for the first time to see this block, then count to 1 {dict [block] [j]] = 1; }}  

After this, the count for any particular block will be in q dict [the_block] , and if that key is' t Is present, then count is 0.


Comments