Skip to content

Commit

Permalink
Adjust static examples to not do SGVector refcounting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed May 3, 2012
1 parent f4d8694 commit 1c8b9b0
Show file tree
Hide file tree
Showing 21 changed files with 7 additions and 61 deletions.
Expand Up @@ -140,7 +140,6 @@ class CTestClassFloat : public CSGObject

virtual ~CTestClassFloat()
{
m_vector.destroy_vector();
m_matrix.destroy_matrix();
SG_UNREF(m_features);
}
Expand Down
Expand Up @@ -140,7 +140,6 @@ class CTestClassFloat : public CSGObject

virtual ~CTestClassFloat()
{
m_vector.destroy_vector();
m_matrix.destroy_matrix();
SG_UNREF(m_features);
}
Expand Down
1 change: 0 additions & 1 deletion examples/undocumented/libshogun/base_map_parameters.cpp
Expand Up @@ -143,7 +143,6 @@ class CTestClassFloat : public CSGObject

virtual ~CTestClassFloat()
{
m_vector.destroy_vector();
m_matrix.destroy_matrix();
SG_UNREF(m_features);
}
Expand Down
Expand Up @@ -147,7 +147,6 @@ class CTestClassFloat : public CSGObject

virtual ~CTestClassFloat()
{
m_vector.destroy_vector();
m_matrix.destroy_matrix();
SG_UNREF(m_features);
}
Expand Down
Expand Up @@ -94,7 +94,6 @@ int main(int argc, char** argv)
CMath::display_vector(out_labels.vector, out_labels.vlen);

// Free resources
out_labels.destroy_vector();
SG_UNREF(mc_svm);
SG_UNREF(svm);
SG_UNREF(output);
Expand Down
Expand Up @@ -114,8 +114,6 @@ void test_cross_validation()
/* clean up */
SG_UNREF(cross);
SG_UNREF(features);
mean_1.destroy_vector();
mean_2.destroy_vector();
}

int main(int argc, char **argv)
Expand Down
Expand Up @@ -136,8 +136,6 @@ void test_cross_validation()
/* clean up */
SG_UNREF(cross);
SG_UNREF(features);
mean_1.destroy_vector();
mean_2.destroy_vector();
}

int main(int argc, char **argv)
Expand Down
Expand Up @@ -70,12 +70,8 @@ int main(int argc, char **argv)

SG_UNREF(f);
SG_UNREF(subset_copy);
feature_copy_subset.destroy_vector();
feature_subset.destroy_vector();

SG_SPRINT("\nEND\n");
exit_shogun();

return 0;
}

Expand Up @@ -124,11 +124,7 @@ int main(int argc, char **argv)

SG_UNREF(f);
SG_UNREF(subset_copy);
feature_copy_subset.destroy_vector();
feature_subset.destroy_vector();

exit_shogun();

return 0;
}

Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv)

SG_SPRINT("\n");

f->free_feature_vector(vec.vector, i, vec.do_free);
f->free_feature_vector(vec, i);
}


Expand All @@ -99,7 +99,7 @@ int main(int argc, char **argv)

SG_SPRINT("\n");

subset_copy->free_feature_vector(vec.vector, i, vec.do_free);
subset_copy->free_feature_vector(vec, i);
}

for (index_t i=0; i<subset_copy->get_num_vectors(); ++i)
Expand All @@ -112,13 +112,11 @@ int main(int argc, char **argv)
ASSERT(vec.vector[j]==strings.strings[offset_idx].string[j]);
}

subset_copy->free_feature_vector(vec.vector, i, vec.do_free);
subset_copy->free_feature_vector(vec, i);
}

SG_UNREF(f);
SG_UNREF(subset_copy);
feature_copy_subset.destroy_vector();
feature_subset.destroy_vector();

exit_shogun();

Expand Down
2 changes: 0 additions & 2 deletions examples/undocumented/libshogun/features_subset_labels.cpp
Expand Up @@ -77,8 +77,6 @@ int main(int argc, char **argv)
ASSERT(label==labels_data.vector[i]);
}
SG_UNREF(labels);
subset_idx.destroy_vector();

SG_SPRINT("\nEND\n");
exit_shogun();

Expand Down
Expand Up @@ -133,12 +133,8 @@ int main(int argc, char **argv)
features->free_feature_vector(vec, i);
}


SG_UNREF(features);
subset_idx.destroy_vector();

exit_shogun();

return 0;
}

Expand Up @@ -146,11 +146,7 @@ int main(int argc, char **argv)

SG_UNREF(features);
data.destroy_matrix();
subset_idx.destroy_vector();


exit_shogun();

return 0;
}

2 changes: 0 additions & 2 deletions examples/undocumented/libshogun/features_subset_stack.cpp
Expand Up @@ -55,8 +55,6 @@ int main(int argc, char **argv)

/* clean up */
SG_UNREF(stack);
subset_a.destroy_vector();
subset_b.destroy_vector();

exit_shogun();

Expand Down
Expand Up @@ -97,7 +97,6 @@ void test()
SG_UNREF(output);

SG_SPRINT("\n\n");
indices.destroy_vector();
indices=SGVector<index_t>(3);
indices.vector[0]=1;
indices.vector[1]=2;
Expand All @@ -109,7 +108,6 @@ void test()
SG_UNREF(output);

SG_SPRINT("\n\n");
indices.destroy_vector();
indices=SGVector<index_t>(4);
indices.range_fill();
CMath::display_vector(indices.vector, indices.vlen, "training indices");
Expand All @@ -132,9 +130,6 @@ void test()
SG_UNREF(features);
SG_UNREF(eval);
SG_UNREF(labels);
mean_1.destroy_vector();
mean_2.destroy_vector();
indices.destroy_vector();
}

int main(int argc, char **argv)
Expand Down
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char **argv)
{
init_shogun(&print_message, &print_message, &print_message);

SGVector<float64_t> data(10, true);
SGVector<float64_t> data(10);
CMath::range_fill_vector(data.vector, data.vlen, 1.0);

float64_t low, up, mean;
Expand All @@ -33,8 +33,6 @@ int main(int argc, char **argv)
SG_SPRINT("sample mean: %f. True mean lies in [%f,%f] with %f%%\n",
mean, low, up, 100*(1-error_prob));

data.free_vector();

SG_SPRINT("\nEND\n");
exit_shogun();

Expand Down
Expand Up @@ -29,10 +29,10 @@ void test_parameter_set_multiplication()
DynArray<Parameter*> set1;
DynArray<Parameter*> set2;

SGVector<float64_t> param_vector(8, true);
SGVector<float64_t> param_vector(8);
CMath::range_fill_vector(param_vector.vector, param_vector.vlen);

SGVector<Parameter*> parameters(4, true);
SGVector<Parameter*> parameters(4);

parameters.vector[0]=new Parameter();
parameters.vector[0]->add(&param_vector.vector[0], "0");
Expand Down Expand Up @@ -69,15 +69,12 @@ void test_parameter_set_multiplication()

for (index_t i=0; i<4; ++i)
delete parameters.vector[i];

param_vector.free_vector();
parameters.free_vector();
}

void test_leaf_sets_multiplication()
{
SG_SPRINT("\ntest_leaf_sets_multiplication()\n");
SGVector<float64_t> param_vector(6, true);
SGVector<float64_t> param_vector(6);
CMath::range_fill_vector(param_vector.vector, param_vector.vlen);

CDynamicObjectArray sets;
Expand Down Expand Up @@ -151,7 +148,6 @@ void test_leaf_sets_multiplication()
SG_UNREF(result_complex);

SG_UNREF(new_root);
param_vector.free_vector();
}

int main(int argc, char **argv)
Expand Down
Expand Up @@ -48,7 +48,6 @@ class CTestClass : public CSGObject

virtual ~CTestClass()
{
m_vec.destroy_vector();
m_mat.destroy_matrix();
SG_UNREF(m_features);
}
Expand Down
Expand Up @@ -82,9 +82,6 @@ int main(int argc, char **argv)
SG_SPRINT("%d(%d),", inverse.vector[j],
(int32_t)labels->get_label(j));
SG_SPRINT("\n\n");

subset.destroy_vector();
inverse.destroy_vector();
}

/* clean up */
Expand Down
Expand Up @@ -51,7 +51,6 @@ int main(int argc, char **argv)
/* print classes */
SGVector<float64_t> classes=labels->get_unique_labels();
CMath::display_vector(classes.vector, classes.vlen, "classes");
classes.destroy_vector();

/* build splitting strategy */
CStratifiedCrossValidationSplitting* splitting=
Expand All @@ -77,9 +76,6 @@ int main(int argc, char **argv)
SG_SPRINT("%d(%d),", inverse.vector[j],
(int32_t)labels->get_label(j));
SG_SPRINT("\n\n");

subset.destroy_vector();
inverse.destroy_vector();
}

/* check whether number of labels in every subset is nearly equal */
Expand All @@ -95,7 +91,6 @@ int main(int argc, char **argv)
if ((int32_t)labels->get_label(temp.vector[j])==i)
++count;
}
temp.destroy_vector();

/* check all subsets for same ratio */
for (index_t j=0; j<num_subsets; ++j)
Expand All @@ -107,7 +102,6 @@ int main(int argc, char **argv)
if ((int32_t)labels->get_label(subset.vector[k])==i)
++temp_count;
}
subset.destroy_vector();

/* at most one difference */
SG_SPRINT("number in subset %d: %d\n", j, temp_count);
Expand Down
2 changes: 0 additions & 2 deletions examples/undocumented/libshogun/statistics.cpp
Expand Up @@ -43,8 +43,6 @@ int main(int argc, char **argv)
SG_SPRINT("variance: %f\n", CStatistics::variance(data));
SG_SPRINT("deviation: %f\n", CStatistics::std_deviation(data));

data.free_vector();

SG_SPRINT("\nEND\n");
exit_shogun();

Expand Down

0 comments on commit 1c8b9b0

Please sign in to comment.