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

void dataset_calc_rescale ( DataSet data_set,
gdouble  scale 

Carry out the pointwise rescaling of a pair of DataSets.

data_set A DataSet scale A number Carry out the pointwise re-scaling of a dataset. The DataSet is modified by multiplication by a scale factor.
data_set The DataSet to be re-scaled.
scale The factor by which the data_set is to be re-scaled.

Definition at line 359 of file special_fn.c.

References _DataSet::frame, _DataSet::nframes, _Frame::npoints, _DataSet::scale, _Frame::xy_data, _Frame::y_range, and _DataSet::y_range.

Referenced by scale_set_from_entry().

  Frame* frame;
  gdouble* xy_point;
  gdouble rescale_factor;
  gint i;
  gint j;

  rescale_factor = scale / data_set->scale;
  data_set->scale = scale;
  data_set->y_range[0] = G_MAXDOUBLE;
  data_set->y_range[1] = -G_MAXDOUBLE;
  for (i=0; i < data_set->nframes; ++i)
      frame = g_array_index(data_set->frame, Frame*, i);
      frame->y_range[0] = G_MAXDOUBLE;
      frame->y_range[1] = -G_MAXDOUBLE;

      for (j=0; j<frame->npoints; ++j)
          xy_point = g_array_index(frame->xy_data, gdouble*, j);
          xy_point[1] *= rescale_factor;

          frame->y_range[0] = MIN(frame->y_range[0], xy_point[1]);
          frame->y_range[1] = MAX(frame->y_range[1], xy_point[1]);
      data_set->y_range[0] = MIN(data_set->y_range[0], frame->y_range[0]);
      data_set->y_range[1] = MAX(data_set->y_range[1], frame->y_range[1]);

Generated by  Doxygen 1.6.0   Back to index