/*
 * Estimates the total area between the curves f1 and f2 in the interval
 * [start, end], with samples taken at the given resolution and the given
 * delay applied to f2. The higher the resolution given, the higher better the
 * estimate will be, but the computation will also take longer.
 */
double total_area_estimate(void* f1, void* f2, double start, double end,
			   double resolution, double delay, char* type)
{
    if (f1 == NULL || f2 == NULL || !interval_valid(start, end) || resolution <= 0)
	return -1;

    double current = start, pt = 0;
    double sum = 0;
    int i = 0;

    while(current <= end){
	if (strcmp(type, "gauss") == 0){
	    pt = area_at_point_gauss((gauss_vector*)f1, (gauss_vector*)f2, current, delay);
	} else if (strcmp(type, "base") == 0){
	    pt = area_at_point_base((est_arr*)f1, (est_arr*)f2, current, delay);
	}
	if (pt != -1){
	    sum += pt;
	    ++i;
	}
	current += resolution;
    }

    return sum/i;
}
Ejemplo n.º 2
0
/**
 * g_time_zone_get_offset:
 * @tz: a #GTimeZone
 * @interval: an interval within the timezone
 *
 * Determines the offset to UTC in effect during a particular @interval
 * of time in the time zone @tz.
 *
 * The offset is the number of seconds that you add to UTC time to
 * arrive at local time for @tz (ie: negative numbers for time zones
 * west of GMT, positive numbers for east).
 *
 * Returns: the number of seconds that should be added to UTC to get the
 *          local time in @tz
 *
 * Since: 2.26
 **/
gint32
g_time_zone_get_offset (GTimeZone *tz,
                        gint       interval)
{
  g_return_val_if_fail (interval_valid (tz, interval), 0);

  if (tz->header == NULL)
    return 0;

  return interval_offset (tz, interval);
}
Ejemplo n.º 3
0
/**
 * g_time_zone_is_dst:
 * @tz: a #GTimeZone
 * @interval: an interval within the timezone
 *
 * Determines if daylight savings time is in effect during a particular
 * @interval of time in the time zone @tz.
 *
 * Returns: %TRUE if daylight savings time is in effect
 *
 * Since: 2.26
 **/
gboolean
g_time_zone_is_dst (GTimeZone *tz,
                    gint       interval)
{
  g_return_val_if_fail (interval_valid (tz, interval), FALSE);

  if (tz->header == NULL)
    return FALSE;

  return interval_isdst (tz, interval);
}
Ejemplo n.º 4
0
/**
 * g_time_zone_get_abbreviation:
 * @tz: a #GTimeZone
 * @interval: an interval within the timezone
 *
 * Determines the time zone abbreviation to be used during a particular
 * @interval of time in the time zone @tz.
 *
 * For example, in Toronto this is currently "EST" during the winter
 * months and "EDT" during the summer months when daylight savings time
 * is in effect.
 *
 * Returns: the time zone abbreviation, which belongs to @tz
 *
 * Since: 2.26
 **/
const gchar *
g_time_zone_get_abbreviation (GTimeZone *tz,
                              gint       interval)
{
  g_return_val_if_fail (interval_valid (tz, interval), NULL);

  if (tz->header == NULL)
    return "UTC";

  return tz->abbrs + interval_abbrind (tz, interval);
}