dilatate Function

private elemental function dilatate(i, b, z) result(d)

Dilatate integer of 32 bits to integer of 64 bits.

See On Spatial Orders and Location Codes, Stocco, LJ and Schrack, G, IEEE Transaction on Computers, vol 58, n 3, March 2009. The resulting integer has 64 bits; it has only b significant bits interleaved by z zeros: bb/zx0/bb-1/zx0../b1/zx0/b0; e.g. for (b=4, z=1): b3/b2/b1/b0 => b3/0/b2/0/b1/0/b0.

Arguments

Type IntentOptional AttributesName
integer(kind=I4P), intent(in) :: i

Input integer.

integer(kind=I2P), intent(in) :: b

Number of significant bits of 'i' (2/4/8/16/32).

integer(kind=I1P), intent(in) :: z

Number of zero 'i' (1/2).

Return Value integer(kind=I8P)

Dilated integer.

Called By

proc~~dilatate~~CalledByGraph proc~dilatate dilatate proc~morton3d morton3D proc~morton3d->proc~dilatate proc~morton2d morton2D proc~morton2d->proc~dilatate proc~test_morton3d test_morton3D proc~test_morton3d->proc~morton3d proc~test_16_16_16 test_16_16_16 proc~test_16_16_16->proc~morton3d program~mortif_test_correctness mortif_test_correctness program~mortif_test_correctness->proc~test_morton3d
Help

Source Code


Source Code

  elemental function dilatate(i, b, z) result(d)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Dilatate integer of 32 bits to integer of 64 bits.
  !<
  !< See *On Spatial Orders and Location Codes*, Stocco, LJ and Schrack, G, IEEE Transaction on Computers, vol 58, n 3, March 2009.
  !< The resulting integer has 64 bits; it has only `b` significant bits interleaved by `z` zeros: `bb/zx0/bb-1/zx0../b1/zx0/b0`;
  !< e.g. for `(b=4, z=1)`: `b3/b2/b1/b0 => b3/0/b2/0/b1/0/b0`.
  !---------------------------------------------------------------------------------------------------------------------------------
  integer(I4P), intent(in) :: i !< Input integer.
  integer(I2P), intent(in) :: b !< Number of significant bits of 'i' (2/4/8/16/32).
  integer(I1P), intent(in) :: z !< Number of zero 'i' (1/2).
  integer(I8P)             :: d !< Dilated integer.
  integer(I1P)             :: l !< Counter.
  integer(I1P)             :: m !< Counter.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  l = int(log10(b*1._R4P)*log10_2_inv, I1P)
  d = int(i, I8P)
  d = iand(d, signif(l))
  do m=l, 1_I1P, -1_I1P !(5/4/3/2/1,1,-1)
    d = iand(ior(d, ishft(d, shft(m,z))), mask(m,z))
  enddo
  !---------------------------------------------------------------------------------------------------------------------------------
  endfunction dilatate