~ubuntu-branches/ubuntu/feisty/gnumeric/feisty-updates

« back to all changes in this revision

Viewing changes to src/tools/analysis-tools.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2006-11-14 14:02:03 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061114140203-iv3j2aii3vch6isl
Tags: 1.7.2-1ubuntu1
* Merge with debian experimental:
  - debian/control, debian/*-gtk-*, debian/rules,
    debian/shlibs.local: Xubuntu changes for
    gtk/gnome multibuild.
  - run intltool-update in po*
  - Build Depend on intltool

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
1
2
/*
2
3
 * analysis-tools.c:
3
4
 *
26
27
 */
27
28
 
28
29
#include <gnumeric-config.h>
29
 
#include <glib/gi18n.h>
 
30
#include <glib/gi18n-lib.h>
30
31
#include "gnumeric.h"
31
32
#include "analysis-tools.h"
32
33
 
84
85
        Sheet *sheet;
85
86
} data_list_specs_t;
86
87
 
87
 
/*
88
 
 *  cb_store_data:
89
 
 *  @cell:
90
 
 *  @data: pointer to a data_set_t
91
 
 */
92
88
static GnmValue *
93
 
cb_store_data (G_GNUC_UNUSED Sheet *sheet,
94
 
               G_GNUC_UNUSED int col, G_GNUC_UNUSED int row,
95
 
               GnmCell *cell, void *user_data)
 
89
cb_store_data (GnmCellIter const *iter, gpointer user)
96
90
{
97
 
        data_set_t *data_set = (data_set_t *)user_data;
 
91
        data_set_t *data_set = (data_set_t *)user;
 
92
        GnmCell *cell = iter->cell;
98
93
        gnm_float the_data;
99
94
 
100
95
        if (data_set->read_label) {
677
672
/***** Some general routines ***********************************************/
678
673
 
679
674
static gint
680
 
float_compare (const gnm_float *a, const gnm_float *b)
 
675
float_compare (gnm_float const *a, gnm_float const *b)
681
676
{
682
677
        if (*a < *b)
683
678
                return -1;
688
683
}
689
684
 
690
685
static gnm_float *
691
 
range_sort (const gnm_float *xs, int n)
 
686
range_sort (gnm_float const *xs, int n)
692
687
{
693
688
        if (n <= 0)
694
689
                return NULL;
753
748
        g_free (orig_copy);
754
749
}
755
750
 
756
 
/* Callbacks for write */
 
751
#warning 2006/May/31  Review this.  Why are we pulling elements from the front of an array ??
757
752
static GnmValue *
758
 
WriteData_ForeachCellCB (Sheet *sheet, int col, int row,
759
 
                         GnmCell *cell, GArray* data)
 
753
cb_write_data (GnmCellIter const *iter, GArray* data)
760
754
{
761
755
        gnm_float  x;
 
756
        GnmCell *cell;
762
757
        if (data->len == 0)
763
758
                return VALUE_TERMINATE;
764
 
        if (cell == NULL)
765
 
                cell = sheet_cell_new (sheet, col, row);
 
759
        if (NULL == (cell = iter->cell))
 
760
                cell = sheet_cell_create (iter->pp.sheet,
 
761
                        iter->pp.eval.col, iter->pp.eval.row);
766
762
        x = g_array_index (data, gnm_float, 0);
767
763
        g_array_remove_index (data, 0);
768
764
        sheet_cell_set_value (cell, value_new_float (x));
782
778
 
783
779
        sheet_foreach_cell_in_range (dao->sheet, CELL_ITER_ALL,
784
780
                st_col, st_row, end_col, end_row,
785
 
                (CellIterFunc)&WriteData_ForeachCellCB, data);
 
781
                (CellIterFunc)&cb_write_data, data);
786
782
}
787
783
 
788
784
static gboolean
4842
4838
} bin_t;
4843
4839
 
4844
4840
static gint
4845
 
bin_compare (const bin_t *set_a, const bin_t *set_b)
 
4841
bin_compare (bin_t const *set_a, bin_t const *set_b)
4846
4842
{
4847
4843
        gnm_float a, b;
4848
4844
 
4858
4854
}
4859
4855
 
4860
4856
static gint
4861
 
bin_pareto_at_i (const bin_t *set_a, const bin_t *set_b, guint index)
 
4857
bin_pareto_at_i (bin_t const *set_a, bin_t const *set_b, guint index)
4862
4858
{
4863
4859
        gnm_float a, b;
4864
4860
 
4877
4873
}
4878
4874
 
4879
4875
static gint
4880
 
bin_pareto (const bin_t *set_a, const bin_t *set_b)
 
4876
bin_pareto (bin_t const *set_a, bin_t const *set_b)
4881
4877
{
4882
4878
        return bin_pareto_at_i (set_a, set_b, 0);
4883
4879
}
5223
5219
 **/
5224
5220
 
5225
5221
static void
5226
 
fourier_fft (const complex_t *in, int n, int skip, complex_t **fourier, gboolean inverse)
 
5222
fourier_fft (complex_t const *in, int n, int skip, complex_t **fourier, gboolean inverse)
5227
5223
{
5228
5224
        complex_t  *fourier_1, *fourier_2;
5229
5225
        int        i;
5292
5288
                in = g_new (complex_t, desired_length);
5293
5289
                for (i = 0; i < desired_length; i++)
5294
5290
                        complex_real (&in[i],
5295
 
                                      ((const gnm_float *)current->data->data)[i]);
 
5291
                                      ((gnm_float const *)current->data->data)[i]);
5296
5292
 
5297
5293
                fourier_fft (in, desired_length, 1, &fourier, info->inverse);
5298
5294
                g_free (in);