fastica_main.cc

Go to the documentation of this file.
00001 /* MLPACK 0.2
00002  *
00003  * Copyright (c) 2008, 2009 Alexander Gray,
00004  *                          Garry Boyer,
00005  *                          Ryan Riegel,
00006  *                          Nikolaos Vasiloglou,
00007  *                          Dongryeol Lee,
00008  *                          Chip Mappus, 
00009  *                          Nishant Mehta,
00010  *                          Hua Ouyang,
00011  *                          Parikshit Ram,
00012  *                          Long Tran,
00013  *                          Wee Chin Wong
00014  *
00015  * Copyright (c) 2008, 2009 Georgia Institute of Technology
00016  *
00017  * This program is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU General Public License as
00019  * published by the Free Software Foundation; either version 2 of the
00020  * License, or (at your option) any later version.
00021  *
00022  * This program is distributed in the hope that it will be useful, but
00023  * WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program; if not, write to the Free Software
00029  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00030  * 02110-1301, USA.
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 }
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3