Ejemplo n.º 1
0
t_vector	waves(t_vector n, t_vector normal_perturb, t_vector p)
{
  t_vector	tmp;

  tmp = new_vector(n.x, n.y, n.z);
  if (!double_are_same(normal_perturb.x, 0.0))
    tmp.x = calc_wave(n, n.x, normal_perturb.x, p.x);
  if (!double_are_same(normal_perturb.y, 0.0))
    tmp.y = calc_wave(n, n.y, normal_perturb.y, p.y);
  if (!double_are_same(normal_perturb.z, 0.0))
    tmp.z = calc_wave(n, n.z, normal_perturb.z, p.z);
  if (!double_are_same(n.x, tmp.x))
    n.x = tmp.x;
  if (!double_are_same(n.y, tmp.y))
    n.y = tmp.y;
  if (!double_are_same(n.z, tmp.z))
    n.z = tmp.z;
  return (n);
}
/*
 * Executes the entire simulation.
 *
 * i_max: how many data points are on a single wave
 * t_max: how many iterations the simulation should run
 * num_threads: how many threads to use
 * old_array: array of size i_max filled with data for t-1
 * current_array: array of size i_max filled with data for t
 * next_array: array of size i_max. You should fill this with t+1
 */
double *simulate(const int i_max, const int t_max, const int num_threads,
        double *old_array, double *current_array, double *next_array)
{

    old = old_array;
    cur = current_array;
    next = next_array;
    g_i_max = i_max;
    g_t_max = t_max;
    g_num_threads = num_threads;

    calc_wave();

    return current_array;
}