Skip to content

Commit

Permalink
Added C++ tests for LLE basic algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Oct 3, 2011
1 parent 2f5de9d commit c0c4231
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/undocumented/libshogun/Makefile
Expand Up @@ -38,6 +38,9 @@ TARGETS = basic_minimal classifier_libsvm classifier_minimal_svm \
library_fibonacci_heap \
library_hashset \
mathematics_lapack \
preprocessor_locallylinearembedding \
preprocessor_localtangentspacealignment \
preprocessor_hessianlocallylinearembedding \

all: $(TARGETS)

Expand Down
@@ -0,0 +1,39 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/HessianLocallyLinearEmbedding.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CHessianLocallyLinearEmbedding* hlle = new CHessianLocallyLinearEmbedding();
hlle->set_target_dim(2);
hlle->set_k(8);
hlle->apply_to_feature_matrix(features);
hlle->parallel->set_num_threads(4);
SG_UNREF(hlle);
SG_UNREF(features);
exit_shogun();
return 0;
}
@@ -0,0 +1,39 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/LocallyLinearEmbedding.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CLocallyLinearEmbedding* lle = new CLocallyLinearEmbedding();
lle->set_target_dim(2);
lle->set_k(4);
lle->apply_to_feature_matrix(features);
lle->parallel->set_num_threads(4);
SG_UNREF(lle);
SG_UNREF(features);
exit_shogun();
return 0;
}
@@ -0,0 +1,39 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2011 Sergey Lisitsyn
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/

#include <shogun/base/init.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/preprocessor/DimensionReductionPreprocessor.h>
#include <shogun/preprocessor/LocalTangentSpaceAlignment.h>

using namespace shogun;

int main(int argc, char** argv)
{
init_shogun();

int N = 100;
int dim = 3;
float64_t* matrix = new double[N*dim];
for (int i=0; i<N*dim; i++)
matrix[i] = i;

CSimpleFeatures<double>* features = new CSimpleFeatures<double>(SGMatrix<double>(matrix,dim,N));
SG_REF(features);
CLocalTangentSpaceAlignment* ltsa = new CLocalTangentSpaceAlignment();
ltsa->set_target_dim(2);
ltsa->set_k(4);
ltsa->apply_to_feature_matrix(features);
ltsa->parallel->set_num_threads(4);
SG_UNREF(ltsa);
SG_UNREF(features);
exit_shogun();
return 0;
}

0 comments on commit c0c4231

Please sign in to comment.