Created
June 7, 2013 10:53
-
-
Save karlnapf/5728519 to your computer and use it in GitHub Desktop.
json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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() | |
{ | |
float64_t a=1.7126587125; | |
float64_t b=0.0; | |
TSGDataType type(CT_SCALAR, ST_NONE, PT_FLOAT64); | |
TParameter* param1=new TParameter(&type, &a, "param", ""); | |
TParameter* param2=new TParameter(&type, &b, "param", ""); | |
const char* filename="float64_param.json"; | |
// save parameter to an json file | |
CSerializableJsonFile *file=new CSerializableJsonFile(filename, 'w'); | |
param1->save(file); | |
file->close(); | |
SG_UNREF(file); | |
// load parameter from an json file | |
file=new CSerializableJsonFile(filename, 'r'); | |
param2->load(file); | |
file->close(); | |
SG_UNREF(file); | |
// check for equality | |
float64_t accuracy=0.01; | |
// EXPECT_TRUE(param1->equals(param2, accuracy)); | |
param1->equals(param2, accuracy); | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment