1. 01 Jan, 2011 1 commit
    • Moe Jette's avatar
      patch from Gerrit: 01_hostlist_parse_int_into_array.diff · 5d19de3b
      Moe Jette authored
      hostlist: shorter conversion
      
      This replaces the hostlist_parse_int_to_array() routine with a simpler and 
      equivalent routine. I was wondering what the algorithm does, when suddenly
      the flow became simpler.
      
      Problem: we want to create an array 'out' of 'dims' dimensions where
               out[i], 0 <= i < dims, has the coefficients a_j of the polynomial
      
      	 a_(dims-1) * B^(dims-1) + ... + a_1 * B + a_0
      
      	 where B is the base of the polynomial 'in' and
      	    a_0        = out[dims - 1]
      	    a_1        = out[dims - 2]
      	    ...
      	    a_(dims-1) = a[0]
      
      Using the Horner Scheme, 'in' is represented as
       * dims = 1:                                   a_0 = out[0]
       * dims = 2:                        a_1  * B + a_0 = out[0] * B + out[1]
       * dims = 3:            (a_2  * B + a_1) * B + a_0 
       * dims = 4: ((a_3 * B + a_2) * B + a_1) * B + a_0
         ...
       * dims = n: ((a_(n-1) * B + a_(n-2)) * B ... + a_1) * B + a_0
      
      We can get a_0 = out[dims-1] as "in % B" and then derive a_1, a_2, ... by
      first dividing by B, and then repeating the process.
      
      If in is 0, all 'dims' coefficients are 0, if it is negative, all coefficients
      are negative.
      5d19de3b
  2. 29 Dec, 2010 4 commits
  3. 28 Dec, 2010 15 commits
  4. 27 Dec, 2010 10 commits
  5. 22 Dec, 2010 10 commits