Permalink
Browse files

Modified some code to reduce warnings in setup.rb

(e.g. removed unused variables)
(untouched matrix_source.c and vector_source.c to
 avoid conflict since
 these are now extensively developed)


git-svn-id: http://rb-gsl.rubyforge.org/svn/trunk/rb-gsl@69 6e764f74-f39f-46f8-8c54-8307d62afe8d
  • Loading branch information...
1 parent 436a981 commit 1a19da7507d06f817fe0767c2863cc8d32c4c89e ytsunesada committed Nov 6, 2008
Showing with 51 additions and 34 deletions.
  1. +5 −4 ext/array.c
  2. +14 −7 ext/blas1.c
  3. +2 −2 ext/graph.c
  4. +1 −1 ext/histogram.c
  5. +4 −2 ext/integration.c
  6. +2 −2 ext/interp.c
  7. +6 −4 ext/linalg.c
  8. +6 −3 ext/math.c
  9. +3 −3 ext/matrix_complex.c
  10. +1 −1 ext/multifit.c
  11. +3 −2 ext/signal.c
  12. +3 −2 ext/spline.c
  13. +1 −1 ext/wavelet.c
View
@@ -216,7 +216,8 @@ void carray_set_from_rarray(double *a, VALUE ary)
for (i = 0; i < size; i++) {
val = rb_ary_entry(ary, i);
Need_Float(val);
- a[i] = RFLOAT(val)->value;
+ a[i] = NUM2DBL(val);
+ // a[i] = RFLOAT(val)->value;
}
}
@@ -485,9 +486,9 @@ int gsl_vector_complex_div(gsl_vector_complex *cv, const gsl_vector_complex *cv2
VALUE rb_gsl_range2ary(VALUE obj)
{
- double beg, en;
- size_t n;
- int step;
+ // double beg, en;
+ // size_t n;
+ // int step;
VALUE ary;
if (CLASS_OF(obj) != rb_cRange)
rb_raise(rb_eTypeError, "wrong argument type %s (Range expected)",
View
@@ -234,14 +234,16 @@ static VALUE rb_gsl_blas_daxpy(int argc, VALUE *argv, VALUE obj)
case T_OBJECT:
get_vector2(argc-1, argv+1, obj, &x, &y);
Need_Float(argv[0]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
break;
default:
Data_Get_Struct(obj, gsl_vector, x);
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
argc);
Need_Float(argv[0]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
Data_Get_Vector(argv[1], y);
break;
}
@@ -259,15 +261,17 @@ static VALUE rb_gsl_blas_daxpy2(int argc, VALUE *argv, VALUE obj)
case T_OBJECT:
get_vector2(argc-1, argv+1, obj, &x, &y);
Need_Float(argv[0]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
break;
default:
Data_Get_Struct(obj, gsl_vector, x);
if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)",
argc);
Need_Float(argv[0]);
CHECK_VECTOR(argv[1]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
Data_Get_Struct(argv[1], gsl_vector, y);
break;
}
@@ -344,7 +348,8 @@ static VALUE rb_gsl_blas_dscal(int argc, VALUE *argv, VALUE obj)
argc);
Need_Float(argv[0]);
CHECK_VECTOR(argv[1]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
Data_Get_Struct(argv[1], gsl_vector, x);
gsl_blas_dscal(a, x);
return argv[1];
@@ -353,7 +358,8 @@ static VALUE rb_gsl_blas_dscal(int argc, VALUE *argv, VALUE obj)
if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
argc);
Need_Float(argv[0]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
Data_Get_Struct(obj, gsl_vector, x);
gsl_blas_dscal(a, x);
return obj;
@@ -403,7 +409,8 @@ static VALUE rb_gsl_blas_zdscal(int argc, VALUE *argv, VALUE obj)
argc);
Need_Float(argv[0]);
CHECK_VECTOR_COMPLEX(argv[1]);
- a = RFLOAT(argv[0])->value;
+ // a = RFLOAT(argv[0])->value;
+ a = NUM2DBL(argv[0]);
Data_Get_Struct(argv[1], gsl_vector_complex, x);
gsl_blas_zdscal(a, x);
return argv[1];
View
@@ -1237,7 +1237,7 @@ static VALUE rb_gsl_graph_graph(int argc, VALUE *argv, VALUE obj)
}
break;
default:
- rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3");
+ rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3)", argc);
break;
}
if (VECTOR_P(g->xdata)) Data_Get_Struct(g->xdata, gsl_vector, x);
@@ -1306,7 +1306,7 @@ static VALUE rb_gsl_graph_step(int argc, VALUE *argv, VALUE obj)
}
break;
default:
- rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3");
+ rb_raise(rb_eArgError, "wrong number of argumeuts (%d for 1-3)", argc);
break;
}
if (VECTOR_P(g->xdata)) Data_Get_Struct(g->xdata, gsl_vector, x);
View
@@ -301,7 +301,7 @@ static VALUE rb_gsl_histogram_set_ranges_uniform(int argc, VALUE *argv, VALUE ob
xmax = NUM2DBL(argv[1]);
break;
default:
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)");
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
break;
}
Data_Get_Struct(obj, gsl_histogram, h);
View
@@ -58,8 +58,10 @@ static int get_a_b(int argc, VALUE *argv, int argstart, double *a, double *b)
aa = rb_ary_entry(argv[argstart], 0);
bb = rb_ary_entry(argv[argstart], 1);
Need_Float(aa); Need_Float(bb);
- *a = RFLOAT(aa)->value;
- *b = RFLOAT(bb)->value;
+ // *a = RFLOAT(aa)->value;
+ // *b = RFLOAT(bb)->value;
+ *a = NUM2DBL(aa);
+ *b = NUM2DBL(bb);
itmp = argstart + 1;
} else {
Need_Float(argv[argstart]); Need_Float(argv[argstart+1]);
View
@@ -189,11 +189,11 @@ static VALUE rb_gsl_interp_evaluate(VALUE obj, VALUE xxa, VALUE yya, VALUE xx,
Data_Get_Struct(obj, rb_gsl_interp, rgi);
ptrx = get_vector_ptr(xxa, &stridex, &size);
if (size != rgi->p->size ){
- rb_raise(rb_eTypeError, "size mismatch (xa:%d != %d)", size, rgi->p->size);
+ rb_raise(rb_eTypeError, "size mismatch (xa:%d != %d)", (int) size, (int) rgi->p->size);
}
ptry = get_vector_ptr(yya, &stridey, &size);
if (size != rgi->p->size ){
- rb_raise(rb_eTypeError, "size mismatch (ya:%d != %d)", size, rgi->p->size);
+ rb_raise(rb_eTypeError, "size mismatch (ya:%d != %d)", (int) size, (int) rgi->p->size);
}
if (CLASS_OF(xx) == rb_cRange) xx = rb_gsl_range2ary(xx);
switch (TYPE(xx)) {
View
@@ -156,7 +156,7 @@ static gsl_vector* get_vector2(VALUE obj, int *flagv);
static gsl_matrix* get_matrix(VALUE obj, VALUE klass, int *flagm)
{
gsl_matrix *mtmp = NULL, *m = NULL;
- gsl_matrix_view mv;
+ // gsl_matrix_view mv;
#ifdef HAVE_NARRAY_H
struct NARRAY *na;
#endif
@@ -195,7 +195,7 @@ static gsl_permutation* get_permutation(VALUE obj, size_t size, int *flagp)
static gsl_vector* get_vector2(VALUE obj, int *flagv)
{
gsl_vector *v = NULL;
- gsl_vector_view vv;
+ // gsl_vector_view vv;
#ifdef HAVE_NARRAY_H
struct NARRAY *na;
#endif
@@ -1085,15 +1085,17 @@ static VALUE rb_gsl_linalg_QRLQ_QTvec(int argc, VALUE *argv, VALUE obj,
VALUE ret;
switch (TYPE(obj)) {
case T_MODULE: case T_CLASS: case T_OBJECT:
- if (argc != 3) rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)");
+ if (argc != 3) rb_raise(rb_eArgError,
+ "wrong number of arguments (%d for 3)", argc);
CHECK_MATRIX(argv[0]); CHECK_VECTOR(argv[1]); CHECK_VECTOR(argv[2]);
Data_Get_Struct(argv[0], gsl_matrix, QR);
Data_Get_Struct(argv[1], gsl_vector, tau);
Data_Get_Struct(argv[2], gsl_vector, v);
ret = argv[2];
break;
default:
- if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)");
+ if (argc != 2) rb_raise(rb_eArgError,
+ "wrong number of arguments (%d for 2)", argc);
CHECK_VECTOR(argv[2]); CHECK_VECTOR(argv[1]);
Data_Get_Struct(obj, gsl_matrix, QR);
Data_Get_Struct(argv[0], gsl_vector, tau);
View
@@ -158,7 +158,8 @@ static VALUE rb_gsl_math_eval(double (*func)(const double), VALUE xx)
for (i = 0; i < size; i++) {
x = rb_ary_entry(xx, i);
Need_Float(x);
- rb_ary_store(ary, i, rb_float_new((*func)(RFLOAT(x)->value)));
+ // rb_ary_store(ary, i, rb_float_new((*func)(RFLOAT(x)->value)));
+ rb_ary_store(ary, i, rb_float_new((*func)(NUM2DBL(x))));
}
return ary;
break;
@@ -217,7 +218,8 @@ static VALUE rb_gsl_math_eval2(double (*func)(const double, const double), VALUE
x = rb_ary_entry(xx, i);
y = rb_ary_entry(yy, i);
Need_Float(x); Need_Float(y);
- rb_ary_store(ary, i, rb_float_new((*func)(RFLOAT(x)->value, RFLOAT(y)->value)));
+ // rb_ary_store(ary, i, rb_float_new((*func)(RFLOAT(x)->value, RFLOAT(y)->value)));
+ rb_ary_store(ary, i, rb_float_new((*func)(NUM2DBL(x), NUM2DBL(y))));
}
return ary;
break;
@@ -420,7 +422,8 @@ static VALUE rb_gsl_pow_int(VALUE obj, VALUE xx, VALUE nn)
for (i = 0; i < size; i++) {
x = rb_ary_entry(xx, i);
Need_Float(x);
- rb_ary_store(ary, i, rb_float_new(gsl_pow_int(RFLOAT(x)->value, n)));
+ // rb_ary_store(ary, i, rb_float_new(gsl_pow_int(RFLOAT(x)->value, n)));
+ rb_ary_store(ary, i, rb_float_new(gsl_pow_int(NUM2DBL(x), n)));
}
return ary;
break;
View
@@ -1366,7 +1366,7 @@ static VALUE rb_gsl_matrix_complex_indgen_bang(int argc, VALUE *argv[], VALUE ob
step = NUM2DBL(argv[1]);
break;
default:
- rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-2)");
+ rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-2)", argc);
}
Data_Get_Struct(obj, gsl_matrix_complex, m);
x = start;
@@ -1395,7 +1395,7 @@ static VALUE rb_gsl_matrix_complex_indgen(int argc, VALUE *argv, VALUE obj)
step = NUM2DBL(argv[1]);
break;
default:
- rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-2)");
+ rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-2)", argc);
}
Data_Get_Struct(obj, gsl_matrix_complex, m);
mnew = gsl_matrix_complex_calloc(m->size1, m->size2);
@@ -1431,7 +1431,7 @@ static VALUE rb_gsl_matrix_complex_indgen_singleton(int argc, VALUE *argv, VALUE
step = NUM2DBL(argv[3]);
break;
default:
- rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-4)");
+ rb_raise(rb_eArgError, "Wrong number of arguments (%d for 0-4)", argc);
}
mnew = gsl_matrix_complex_calloc(n1, n2);
x = start;
View
@@ -236,7 +236,7 @@ static VALUE rb_gsl_multifit_fdfsolver_new(int argc, VALUE *argv, VALUE klass)
}
break;
default:
- rb_raise(rb_eTypeError, "wrong argument type (Fixnum or String)",
+ rb_raise(rb_eTypeError, "wrong argument type %s (Fixnum or String)",
rb_class2name(CLASS_OF(argv[0])));
break;
}
View
@@ -106,13 +106,14 @@ static VALUE rb_gsl_fft_conv_corr(int argc, VALUE *argv, VALUE obj,
{
double *data1, *data2, *data3;
size_t stride1, stride2, stride3 = 1, size1, size2;
- int naflag1, naflag2, shape;
+ // int naflag1, naflag2, shape;
+ int naflag1, naflag2;
gsl_vector *v = NULL;
gsl_fft_halfcomplex_wavetable *table = NULL;
gsl_fft_real_wavetable *rtable = NULL;
gsl_fft_real_workspace *space = NULL, *space2 = NULL;
int flagt = 0, flagw = 0;
- size_t i;
+ // size_t i;
gsl_vector *vtmp1 = NULL, *vtmp2 = NULL;
VALUE ary;
switch (argc) {
View
@@ -229,7 +229,8 @@ static VALUE rb_gsl_spline_find(VALUE obj, VALUE vv, VALUE xx)
size_t size, stride;
Data_Get_Struct(obj, rb_gsl_spline, sp);
ptr = get_vector_ptr(vv, &stride, &size);
- x = RFLOAT(xx)->value;
+ // x = RFLOAT(xx)->value;
+ x = NUM2DBL(xx);
return INT2FIX(gsl_interp_accel_find(sp->a, ptr, size, x));
}
@@ -315,7 +316,7 @@ static VALUE rb_gsl_spline_info(VALUE obj)
char buf[256];
Data_Get_Struct(obj, rb_gsl_spline, p);
sprintf(buf, "Class: %s\n", rb_class2name(CLASS_OF(obj)));
- sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS(CLASS_OF(obj))->super));
+ // sprintf(buf, "%sSuperClass: %s\n", buf, rb_class2name(RCLASS(CLASS_OF(obj))->super));
sprintf(buf, "%sType: %s\n", buf, gsl_interp_name(p->s->interp));
sprintf(buf, "%sxmin: %f\n", buf, p->s->interp->xmin);
sprintf(buf, "%sxmax: %f\n", buf, p->s->interp->xmax);
View
@@ -136,7 +136,7 @@ static const gsl_wavelet_type* rb_gsl_wavelet_get_type_int(int t)
T = gsl_wavelet_bspline_centered;
break;
default:
- rb_raise(rb_eArgError, "unknown type %s", t);
+ rb_raise(rb_eArgError, "unknown type %d", t);
break;
}
return T;

0 comments on commit 1a19da7

Please sign in to comment.