~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to packages/zoltan/src/util/converters_for_JPDC_adaptive_mesh_experiments/exo2chaco/chaco/util/bit_reverse.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This software was developed by Bruce Hendrickson and Robert Leland   *
 
2
 * at Sandia National Laboratories under US Department of Energy        *
 
3
 * contract DE-AC04-76DP00789 and is copyrighted by Sandia Corporation. */
 
4
 
 
5
/* Reverse the bits of a number. */
 
6
int       bit_reverse(int val, int nbits)
 
7
                                /* value to reverse bits of */
 
8
                                /* number of significant bits */
 
9
{
 
10
    int       mask_low, mask_high;      /* masks for bits to interchange */
 
11
    int       bit_low, bit_high;/* values of the bits in question */
 
12
    int       i;                /* loop counter */
 
13
 
 
14
    mask_low = 1;
 
15
    mask_high = 1 << (nbits - 1);
 
16
    for (i = 0; i < nbits / 2; i++) {
 
17
        bit_low = (val & mask_low) >> i;
 
18
        bit_high = (val & mask_high) >> (nbits - i - 1);
 
19
        mask_low <<= 1;
 
20
        mask_high >>= 1;
 
21
        if (bit_low != bit_high) {
 
22
            val ^= (1 << i) ^ (1 << (nbits - i - 1));
 
23
        }
 
24
    }
 
25
    return (val);
 
26
}