Xmipp  v3.23.11-Nereus
dimred_tools.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar coss@cnb.csic.es (2013)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 #ifndef _DIMRED_TOOLS
26 #define _DIMRED_TOOLS
27 
28 #include <core/matrix2d.h>
29 #include <core/matrix1d.h>
30 #include "core/xmipp_filename.h"
31 
32 
44 {
45 public:
49 
54 
57 
58 
59 public:
71  void generateNewDataset(const DatasetType &type, int N=1000, double noise=0.05);
72 };
73 
75 typedef double (*DimRedDistance2) (const Matrix2D<double> &X, size_t i1, size_t i2);
76 
80 void computeDistance(const Matrix2D<double> &X, Matrix2D<double> &distance, DimRedDistance2 f=NULL, bool computeSqrt=true);
81 
86 
91 void computeDistanceToNeighbours(const Matrix2D<double> &X, int K, Matrix2D<double> &distance, DimRedDistance2 f=NULL, bool computeSqrt=true);
92 
97 void computeSimilarityMatrix(Matrix2D<double> &D2, double sigma, bool skipZeros=false, bool normalize=false);
98 
103 
118 double intrinsicDimensionality(Matrix2D<double> &X, const String &method="MLE", bool normalize=true, DimRedDistance2 f=NULL);
119 
129 void kNearestNeighbours(const Matrix2D<double> &X, int K, Matrix2D<int> &idx, Matrix2D<double> &distance, DimRedDistance2 f=NULL, bool computeSqrt=true);
130 
135 
138 {
139 public:
142 
144  size_t outputDim;
145 
148 
151 
154 public:
156  DimRedAlgorithm();
157 
159  void setInputData(Matrix2D<double> &X);
160 
162  void setOutputDimensionality(size_t outputDim);
163 
165  virtual void reduceDimensionality()=0;
166 
168  const Matrix2D<double> &getReducedData();
169 };
171 #endif
void computeSimilarityMatrix(Matrix2D< double > &D2, double sigma, bool skipZeros=false, bool normalize=false)
Matrix2D< double > Y
Output data.
Definition: dimred_tools.h:147
void kNearestNeighbours(const Matrix2D< double > &X, int K, Matrix2D< int > &idx, Matrix2D< double > &distance, DimRedDistance2 f=NULL, bool computeSqrt=true)
void computeDistance(const Matrix2D< double > &X, Matrix2D< double > &distance, DimRedDistance2 f=NULL, bool computeSqrt=true)
DatasetType
Definition: dimred_tools.h:42
Matrix2D< double > * X
Pointer to input data.
Definition: dimred_tools.h:141
Matrix1D< unsigned char > label
Definition: dimred_tools.h:56
void extractNearestNeighbours(const Matrix2D< double > &X, Matrix2D< int > &idx, int i, Matrix2D< double > &Xi)
void computeGraphLaplacian(const Matrix2D< double > &G, Matrix2D< double > &L)
void computeRandomPointsDistance(const Matrix2D< double > &X, Matrix1D< double > &distance, Matrix1D< int > ind1, Matrix1D< int > ind2, DimRedDistance2 f, bool computeSqrt)
#define i
size_t outputDim
Output dim.
Definition: dimred_tools.h:144
Matrix2D< double > t
Definition: dimred_tools.h:53
viol type
double * f
void computeDistanceToNeighbours(const Matrix2D< double > &X, int K, Matrix2D< double > &distance, DimRedDistance2 f=NULL, bool computeSqrt=true)
Matrix2D< double > X
Definition: dimred_tools.h:48
quaternion_type< T > normalize(quaternion_type< T > q)
Definition: point.cpp:278
double(* DimRedDistance2)(const Matrix2D< double > &X, size_t i1, size_t i2)
Definition: dimred_tools.h:75
TYPE distance(struct Point_T *p, struct Point_T *q)
Definition: point.cpp:28
DimRedDistance2 distance
Distance function.
Definition: dimred_tools.h:150
FileName fnMapping
Save mapping.
Definition: dimred_tools.h:153
std::string String
Definition: xmipp_strings.h:34
constexpr int K
double intrinsicDimensionality(Matrix2D< double > &X, const String &method="MLE", bool normalize=true, DimRedDistance2 f=NULL)