fastica_main.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00041 #include "fastica.h"
00042
00079 const fx_entry_doc fastica_main_entries[] = {
00080 {"data", FX_REQUIRED, FX_STR, NULL,
00081 " A file containing data.\n"},
00082 {"ic_filename", FX_PARAM, FX_STR, NULL,
00083 " Filename to which independent components are written.\n"},
00084 {"unmixing_filename", FX_PARAM, FX_STR, NULL,
00085 " Filename to which unmixing matrix is written.\n"},
00086 FX_ENTRY_DOC_DONE
00087 };
00088
00089 const fx_submodule_doc fastica_main_submodules[] = {
00090 {"fastica", &fastica_doc,
00091 " Responsible for performing fastica.\n"},
00092 FX_SUBMODULE_DOC_DONE
00093 };
00094
00095 const fx_module_doc fastica_main_doc = {
00096 fastica_main_entries, fastica_main_submodules,
00097 "This program performs fastica.\n"
00098 };
00099
00100
00101
00102 int main(int argc, char *argv[]) {
00103 fx_module* root = fx_init(argc, argv, &fastica_main_doc);
00104
00105 Matrix X;
00106 const char* data = fx_param_str_req(NULL, "data");
00107 data::Load(data, &X);
00108
00109 const char* ic_filename = fx_param_str(NULL, "ic_filename", "ic.dat");
00110 const char* unmixing_filename =
00111 fx_param_str(NULL, "unmixing_filename", "unmixing.dat");
00112 struct datanode* fastica_module =
00113 fx_submodule(root, "fastica");
00114
00115 FastICA fastica;
00116
00117 int success_status = SUCCESS_FAIL;
00118 if(fastica.Init(X, fastica_module) == SUCCESS_PASS) {
00119 Matrix W, Y;
00120 if(fastica.DoFastICA(&W, &Y) == SUCCESS_PASS) {
00121 SaveCorrectly(unmixing_filename, W);
00122 data::Save(ic_filename, Y);
00123 success_status = SUCCESS_PASS;
00124 VERBOSE_ONLY( W.PrintDebug("W") );
00125 }
00126 }
00127
00128
00129 if(success_status == SUCCESS_FAIL) {
00130 VERBOSE_ONLY( printf("FAILED!\n") );
00131 }
00132
00133 fx_done(root);
00134
00135 return success_status;
00136 }