inline
void update_density(particle_t* pi, particle_t* pj, float h2, float C, float* i_rho, float* j_rho) {
	float r2 = vec3_dist2(pi->x, pj->x);
	float z = h2 - r2;
	if (z > 0) {
		float rho_ij = C * z * z * z;
		*i_rho += rho_ij;
		*j_rho += rho_ij;
	}
}
 * 
 * The formula for density is
 * \[
 *   \rho_i = \sum_j m_j W_{p6}(r_i-r_j,h)
 *          = \frac{315 m}{64 \pi h^9} \sum_{j \in N_i} (h^2 - r^2)^3.
 * \]
 * We search for neighbors of node $i$ by checking every particle,
 * which is not very efficient.  We do at least take advange of
 * the symmetry of the update ($i$ contributes to $j$ in the same
 * way that $j$ contributes to $i$).
 *@c*/

inline
void update_density(particle_t* restrict pi, particle_t* restrict pj, float h2, float C)
{
    float r2 = vec3_dist2(pi->x, pj->x);
    float z  = h2-r2;
    if (z > 0) {
        float rho_ij = C*z*z*z;
        pi->rho += rho_ij;
        //pj->rho += rho_ij;
    }
}

void compute_density(sim_state_t* restrict s, sim_param_t* restrict params)
{
    int n = s->n;
    particle_t* p = s->part;

    hash_bin_t* hash = s->hash;