Xmipp  v3.23.11-Nereus
lltsa.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Sergio Calvo Gonzalez sergiocg90@gmail.com (2013)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  * 02111-1307 USA
19  *
20  * All comments concerning this program package may be sent to the
21  * e-mail address 'xmipp@cnb.csic.es'
22  ***************************************************************************/
23 
24 #include "lltsa.h"
25 
27 {
29  Ap.resize(MAT_YSIZE(A),MAT_XSIZE(A)-N);
30  for (size_t i = 0; i < MAT_YSIZE(A); ++i)
31  memcpy(&MAT_ELEM(Ap,i,0),&MAT_ELEM(A,i,0),MAT_XSIZE(Ap)*sizeof(double));
32  A=Ap;
33 }
34 
36 {
37  Matrix2D<double> B, XtBX, XtX;
39 
40  Matrix1D<double> DEigs;
41  matrixOperation_AtB(*X, B, XtBX);
42  matrixOperation_AtA(*X, XtX);
43  XtBX = XtBX * (*X);
44  generalizedEigs(XtBX, XtX, DEigs, A);
46  Y = *X * A;
47  if (fnMapping!="")
48  A.write(fnMapping);
49 }
#define MAT_YSIZE(m)
Definition: matrix2d.h:124
Matrix2D< double > Y
Output data.
Definition: dimred_tools.h:147
Matrix2D< double > * X
Pointer to input data.
Definition: dimred_tools.h:141
Matrix2D< double > A
Definition: lltsa.h:41
void matrixOperation_AtA(const Matrix2D< double > &A, Matrix2D< double > &B)
Definition: matrix2d.cpp:436
#define i
void eraseLastNColumns(Matrix2D< double > &A, int N)
Definition: lltsa.cpp:26
size_t outputDim
Output dim.
Definition: dimred_tools.h:144
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
void matrixOperation_AtB(const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix2D< double > &C)
Definition: matrix2d.cpp:475
void generalizedEigs(const Matrix2D< double > &A, const Matrix2D< double > &B, Matrix1D< double > &D, Matrix2D< double > &P)
Definition: matrix2d.cpp:267
void reduceDimensionality()
Reduce dimensionality.
Definition: lltsa.cpp:35
FileName fnMapping
Save mapping.
Definition: dimred_tools.h:153
#define MAT_XSIZE(m)
Definition: matrix2d.h:120
void write(const FileName &fn) const
Definition: matrix2d.cpp:113
void computeAlignmentMatrix(Matrix2D< double > &B)
Common part.
Definition: ltsa.cpp:56
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
Definition: matrix2d.cpp:1022