Class: NoyesC::LiveCMN

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

Instance Method Summary collapse

Constructor Details

#initializeObject


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

static VALUE t_init(VALUE self, VALUE args) {
  int dimensions=13, init_mean=45.0, window_size=100, shift=160;
  int len = RARRAY_LEN(args);
  if (len > 0)
     dimensions = NUM2INT(rb_ary_entry(args, 0));
  if (len > 1)
     init_mean= NUM2INT(rb_ary_entry(args, 1));
  if (len > 2)
     window_size = NUM2INT(rb_ary_entry(args, 2));
  if (len > 3)
     shift = NUM2INT(rb_ary_entry(args, 3));

  LiveCMN *cmn = live_cmn_new(dimensions, init_mean, window_size, shift);
  VALUE cmnv = Data_Wrap_Struct(cLiveCMN, 0, _live_cmn_free, cmn);
  rb_iv_set(self, "@cmn", cmnv);
  return self;
}

Instance Method Details

#<<Object


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

static VALUE t_left_shift(VALUE self, VALUE obj) {
  Cmat *M = r2cmat(obj);
  LiveCMN *cmn;
  VALUE cmnv = rb_iv_get(self, "@cmn");
  Data_Get_Struct(cmnv, LiveCMN, cmn);
  Cmat *N = live_cmn_apply(cmn, M);
  VALUE result = cmat2r(N);
  cmat_free(N);
  cmat_free(M);
  return result;
}