MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Functions | Variables
peano.c File Reference
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <gsl/gsl_heapsort.h>
#include "peano.h"
Include dependency graph for peano.c:

Go to the source code of this file.

Functions

peano_t peano_hilbert_key (int x, int y, int z, int bits)
 

Variables

const unsigned char rottable3 [48][8]
 
const unsigned char subpix3 [48][8]
 

Function Documentation

◆ peano_hilbert_key()

peano_t peano_hilbert_key ( int  x,
int  y,
int  z,
int  bits 
)

This function computes a Peano-Hilbert key for an integer triplet (x,y,z), with x,y,z in the range between 0 and 2^bits-1.

Definition at line 119 of file peano.c.

120 {
121  int mask;
122  unsigned char rotation = 0;
123  peano_t key = 0;
124 
125  for(mask = 1 << (bits - 1); mask > 0; mask >>= 1)
126  {
127  unsigned char pix = ((x & mask) ? 4 : 0) | ((y & mask) ? 2 : 0) | ((z & mask) ? 1 : 0);
128 
129  key <<= 3;
130  key |= subpix3[rotation][pix];
131  rotation = rottable3[rotation][pix];
132  }
133 
134  return key;
135 }
const unsigned char subpix3[48][8]
Definition: peano.c:65
const unsigned char rottable3[48][8]
Definition: peano.c:14
uint64_t peano_t
Definition: peano.h:7

References rottable3, and subpix3.

Referenced by force_create_node_for_topnode(), and PEANO().

Here is the caller graph for this function:

Variable Documentation

◆ rottable3

const unsigned char rottable3[48][8]

Definition at line 14 of file peano.c.

Referenced by peano_hilbert_key().

◆ subpix3

const unsigned char subpix3[48][8]

Definition at line 65 of file peano.c.

Referenced by peano_hilbert_key().