Skip to content

Instantly share code, notes, and snippets.

@lambday
Created June 7, 2013 11:43
Show Gist options
  • Save lambday/5728708 to your computer and use it in GitHub Desktop.
Save lambday/5728708 to your computer and use it in GitHub Desktop.
/*
* 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) 2013 Heiko Strathmann
*/
#include <shogun/lib/config.h>
#ifdef HAVE_EIGEN3
#include <shogun/labels/RegressionLabels.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/regression/GaussianProcessRegression.h>
#include <shogun/regression/gp/ExactInferenceMethod.h>
#include <shogun/regression/gp/ZeroMean.h>
#include <shogun/regression/gp/GaussianLikelihood.h>
#include <shogun/io/SerializableAsciiFile.h>
#include <shogun/statistics/QuadraticTimeMMD.h>
#include <shogun/lib/DynamicObjectArray.h>
#include <shogun/io/SerializableJsonFile.h>
using namespace shogun;
void test()
{
char a='a';
char b='b';
TSGDataType type(CT_SCALAR, ST_NONE, PT_CHAR);
TParameter* param1=new TParameter(&type, &a, "param", "");
TParameter* param2=new TParameter(&type, &b, "param", "");
const char* filename="char_param.json";
CSerializableJsonFile *file=new CSerializableJsonFile(filename, 'w');
param1->save(file);
file->close();
SG_UNREF(file);
file=new CSerializableJsonFile(filename, 'r');
param2->load(file);
file->close();
SG_UNREF(file);
param1->equals(param2);
delete param1;
delete param2;
}
int main(int argc, char **argv)
{
init_shogun_with_defaults();
sg_io->set_loglevel(MSG_DEBUG);
test();
exit_shogun();
return 0;
}
#endif //HAVE_EIGEN3
@lambday
Copy link
Author

lambday commented Jun 7, 2013

[DEBUG] Saving parameter 'param' of type 'char'
[DEBUG] Loading parameter 'param' of type 'char'
[DEBUG] entering TParameter::equals()
[DEBUG] Comparing datatypes
[DEBUG] entering TSGDataType::equals()
[DEBUG] leaving TSGDataType::equals(): datatypes are equal
[DEBUG] Comparing stype
[DEBUG] CT_SCALAR
[DEBUG] entering TParameter::compare_stype()
[DEBUG] ST_NONE
[DEBUG] entering TParameter::compare_ptype()
[DEBUG] leaving TParameter::compare_ptype(): PT_CHAR: data1=a, data2=�
[DEBUG] leaving TParameter::equals(): scalar data differes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment