00001 /* 00002 * Author: Chao Yang 00003 * Copyright (c) 2000-2006 00004 * 00005 * This software is issued under a joint BSD/GNU license. You may use the 00006 * source code in this file under either license. However, note that the 00007 * complete EMAN2 and SPARX software packages have some GPL dependencies, 00008 * so you are responsible for compliance with the licenses of these packages 00009 * if you opt to use BSD licensing. The warranty disclaimer below holds 00010 * in either instance. 00011 * 00012 * This complete copyright notice must be included in any revised version of the 00013 * source code. Additional authorship citations may be added, but existing 00014 * author citations must be preserved. 00015 * 00016 * This program is free software; you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation; either version 2 of the License, or 00019 * (at your option) any later version. 00020 * 00021 * This program is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program; if not, write to the Free Software 00028 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00029 * 00030 */ 00031 00032 //#ifndef sparx__pca_h__ 00033 //#define sparx__pca_h__ 00034 00035 #include "emdata.h" 00036 00037 namespace EMAN { 00038 class PCA { 00039 public: 00040 vector<float> singular_vals; // singular values 00041 vector<EMData*> eigenimages; // eigenimages 00042 00043 // pca in core 00044 int dopca(vector <EMData*> imgstack, EMData *mask); 00045 int dopca(vector <EMData*> imgstack, EMData *mask, int nvec); 00046 int dopca_lan(vector <EMData*> imgstack, EMData *mask, int nvec); 00047 00048 // pca out of core 00049 int dopca_ooc(const string &filename_in, const string &filename_out, 00050 const string &lanscratch, EMData *mask, int nvec); 00051 00052 // Lanczos factorization (used by dopca_lan) 00053 int Lanczos(vector <EMData*> imgstack, int *maxiter, 00054 float *diag, float *subdiag, float *V, float *beta); 00055 00056 // Lanczos factorization out-of-core (used by dopca_ooc) 00057 int Lanczos_ooc(string const& filename_in, int *kstep, 00058 float *diag, float *subdiag, 00059 string const& lanscratch, float *beta); 00060 00061 // retrieve singular vectors and values 00062 vector<float> get_vals(); 00063 vector<EMData*> get_vecs(); 00064 00065 // flush singular values and vectors 00066 void clear(); 00067 }; 00068 } 00069 00070 //#endif //sparx__pca_h__