Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

DataSet* dataset_derivative ( gint  idx  ) 

Take the derivative of each frame in a DataSet.

A new DataSet is created by taking the derivative of each frame of an existing DataSet. The new DataSet is added to the global_data_set_list, and given a name "D<label>" where <label> is the label of the original DataSet. The new DataSet is given the type YG_DERIVATIVE, and its cmpt_set points to the original data.

Parameters:
idx The DataSet index of the original data set within the global_data_set_list.
Returns:
The newly created DataSet containing the derivative data.

Definition at line 470 of file special_fn.c.

References _DataSet::cmpt_set, data_set_init(), dataset_append_frame(), _DataSet::frame, frame_derivative(), global_data_set_list, _DataSet::name, _DataSet::nframes, and _DataSet::type.

Referenced by plot_window_derivative().

{
  Frame* f;
  Frame* df;
  DataSet* data;
  DataSet* d_data;
  gint i;
  gint name_len;
  
  data = g_array_index(global_data_set_list, DataSet*, idx);

  d_data = data_set_init(NULL);
  d_data->type = YG_DERIVATIVE;
  g_array_append_val(d_data->cmpt_set, idx);

  name_len = strlen(data->name) + 2;
  d_data->name = g_malloc(name_len*sizeof(gchar));
  g_snprintf(d_data->name, name_len, "D%s", data->name);

  for (i=0; i<data->nframes; ++i)
    {
      f = g_array_index(data->frame, Frame*, i);
      df = frame_derivative(f);
      dataset_append_frame(d_data, df);
    }

  return d_data;
}


Generated by  Doxygen 1.6.0   Back to index