Class: TreeScore
- Inherits:
-
Object
- Object
- TreeScore
- Defined in:
- ext/TreeScore.c
Class Method Summary collapse
-
.makeBestList(dm) ⇒ Object
Makes a list consisting of only the best quartets (1/3 as many as full).
-
.makeFullList(dm) ⇒ Object
Makes a list of every quartet with corresponding cost.
Instance Method Summary collapse
-
#best ⇒ Object
Return the best possible tree cost total.
- #penalty ⇒ Object
- #penalty=(val) ⇒ Object
- #score(tree) ⇒ Object
-
#worst ⇒ Object
Return the worst possible tree cost total.
Class Method Details
.makeBestList(dm) ⇒ Object
Makes a list consisting of only the best quartets (1/3 as many as full)
109 110 111 112 113 114 115 116 117 |
# File 'ext/TreeScore.c', line 109
static VALUE ts_makeBest(VALUE cl, VALUE dm)
{
struct TreeScore *ts = newTreeScore();
VALUE tdata = Data_Wrap_Struct(cl, 0, ts_free, ts);
struct DistMatrix *gdm = convertDistMatrixFromRuby(dm);
ts->ql = makeBestQuartetList(gdm, &ts->worst, &ts->best);
freeDistMatrix(gdm);
return tdata;
}
|
.makeFullList(dm) ⇒ Object
Makes a list of every quartet with corresponding cost.
122 123 124 125 126 127 128 129 130 |
# File 'ext/TreeScore.c', line 122
static VALUE ts_makeFull(VALUE cl, VALUE dm)
{
struct TreeScore *ts = newTreeScore();
VALUE tdata = Data_Wrap_Struct(cl, 0, ts_free, ts);
struct DistMatrix *gdm = convertDistMatrixFromRuby(dm);
ts->ql = makeFullQuartetList(gdm, &ts->worst, &ts->best);
freeDistMatrix(gdm);
return tdata;
}
|
Instance Method Details
#best ⇒ Object
Return the best possible tree cost total. This is used to calculate S(T).
145 146 147 148 149 150 |
# File 'ext/TreeScore.c', line 145
static VALUE ts_best(VALUE self)
{
struct TreeScore *ts;
Data_Get_Struct(self, struct TreeScore, ts);
return rb_float_new(ts->best);
}
|
#penalty ⇒ Object
187 188 189 190 191 192 |
# File 'ext/TreeScore.c', line 187
static VALUE ts_penalty(VALUE self)
{
struct TreeScore *ts;
Data_Get_Struct(self, struct TreeScore, ts);
return rb_float_new(ts->penalty);
}
|
#penalty=(val) ⇒ Object
179 180 181 182 183 184 185 |
# File 'ext/TreeScore.c', line 179
static VALUE ts_penaltyeq(VALUE self, VALUE val)
{
struct TreeScore *ts;
Data_Get_Struct(self, struct TreeScore, ts);
ts->penalty = NUM2DBL(val);
return rb_float_new(ts->penalty);
}
|
#score(tree) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'ext/TreeScore.c', line 212
static VALUE ts_score(VALUE self, VALUE tree)
{
int badNodeCount;
struct TreeScore *ts;
struct FastTree *ft = convertTreeFromRuby(tree);
weight_t score;
float result, radj;
Data_Get_Struct(self, struct TreeScore, ts);
score = calculateWeightedScore(ft, ts->ql);
result = (score - ts->worst) / (ts->best - ts->worst);
badNodeCount = countBadNodes(ft);
radj = - ts->penalty * countBadNodes(ft);
freeFastTree(ft);
return rb_float_new(result + radj);
}
|
#worst ⇒ Object
Return the worst possible tree cost total. This is used to calculate S(T).
135 136 137 138 139 140 |
# File 'ext/TreeScore.c', line 135
static VALUE ts_worst(VALUE self)
{
struct TreeScore *ts;
Data_Get_Struct(self, struct TreeScore, ts);
return rb_float_new(ts->worst);
}
|