Class: NoyesC::Segmenter

Inherits:
Object
  • Object
show all
Defined in:
lib/cext/segmenter.c

Instance Method Summary collapse

Constructor Details

#initializeObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cext/segmenter.c', line 10

static VALUE t_init(VALUE self, VALUE args) {
  int winsz = 205;
  int winshift = 80;
  int len = RARRAY_LEN(args);
  if (len > 0) {
     winsz = NUM2INT(rb_ary_entry(args, 0));
  }
  if (len > 1) {
    winshift = NUM2INT(rb_ary_entry(args, 1));
  }

  Segmenter *s = new_segmenter(winsz, winshift);
  VALUE segmenter = Data_Wrap_Struct(cSegmenter, 0, _segmenter_free, s);
  rb_iv_set(self, "@segmenter", segmenter);

  return self;
}

Instance Method Details

#<<Object


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cext/segmenter.c', line 28

static VALUE t_left_shift(VALUE self, VALUE obj) {
  Carr *M = r2carr(obj); 
  VALUE segmenter = rb_iv_get(self, "@segmenter");
  Segmenter *s;
  Data_Get_Struct(segmenter, Segmenter, s);
  Cmat *N = segmenter_apply(s, M);
  VALUE result = cmat2r(N);
  cmat_free(N);
  carr_free(M);
  return result;
}