Class: Array
- Inherits:
-
Object
show all
- Defined in:
- lib/gsl/gnuplot.rb
Instance Method Summary
collapse
Instance Method Details
#to_gplot ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/gsl/gnuplot.rb', line 4
def to_gplot
if ( self[0].kind_of? Array ) then
tmp = self[0].zip( *self[1..-1] )
tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
elsif ( self[0].kind_of? Numeric ) then
s = ""
self.length.times { |i| s << "#{self[i]}\n" }
s
elsif ( self[0].kind_of? GSL::Vector ) then
tmp = self[0].zip( *self[1..-1] )
tmp.collect { |a| a.join(" ") }.join("\n") + "\ne"
else
self[0].zip( *self[1..-1] ).to_gplot
end
end
|
#to_gsl_integration_qawo_table ⇒ Object
726
727
728
729
730
731
732
|
# File 'ext/gsl_native/integration.c', line 726
static VALUE rb_gsl_ary_to_integration_qawo_table(VALUE ary)
{
gsl_integration_qawo_table *t = NULL;
t = make_qawo_table(ary);
return Data_Wrap_Struct(cgsl_integration_qawo_table,
0, gsl_integration_qawo_table_free, t);
}
|
#to_gsl_integration_qaws_table ⇒ Object
Also known as:
to_qaws_table
624
625
626
627
628
629
630
|
# File 'ext/gsl_native/integration.c', line 624
static VALUE rb_gsl_ary_to_integration_qaws_table(VALUE ary)
{
gsl_integration_qaws_table *t = NULL;
t = make_qaws_table(ary);
return Data_Wrap_Struct(cgsl_integration_qaws_table,
0, gsl_integration_qaws_table_free, t);
}
|
#to_gsplot ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/gsl/gnuplot.rb', line 19
def to_gsplot
f = ""
if ( self[0].kind_of? Array ) then
x = self[0]
y = self[1]
d = self[2]
x.each_with_index do |xv, i|
y.each_with_index do |yv, j|
f << [ xv, yv, d[i][j] ].join(" ") << "\n"
end
end
elsif ( self[0].kind_of? Numeric ) then
self.length.times do |i| f << "#{self[i]}\n" end
else
self[0].zip( *self[1..-1] ).to_gsplot
end
f
end
|
#to_gv ⇒ Object
Also known as:
to_gslv, to_gsl_vector
294
295
296
297
298
299
300
301
302
303
304
305
|
# File 'ext/gsl_native/vector_double.c', line 294
VALUE rb_ary_to_gv0(VALUE ary)
{
gsl_vector *v = NULL;
size_t i, size;
size = RARRAY_LEN(ary);
v = gsl_vector_alloc(size);
if (v == NULL) rb_raise(rb_eNoMemError, "gsl_vector_alloc failed");
for (i = 0; i < size; i++) {
gsl_vector_set(v, i, NUM2DBL(rb_ary_entry(ary, i)));
}
return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, v);
}
|