Tapkee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
random_projection.hpp
Go to the documentation of this file.
1 /* This software is distributed under BSD 3-clause license (see LICENSE file).
2  *
3  * Copyright (c) 2012-2013 Sergey Lisitsyn
4  */
5 
6 #ifndef TAPKEE_RandomProjection_H_
7 #define TAPKEE_RandomProjection_H_
8 
9 /* Tapkee includes */
10 #include <tapkee/defines.hpp>
11 #include <tapkee/utils/time.hpp>
12 /* End of Tapkee includes */
13 
14 namespace tapkee
15 {
16 namespace tapkee_internal
17 {
18 
19 DenseMatrix gaussian_projection_matrix(IndexType target_dimension, IndexType current_dimension)
20 {
21  DenseMatrix projection_matrix(target_dimension,current_dimension);
22 
23  for (IndexType i=0; i<target_dimension; ++i)
24  {
25  for (IndexType j=0; j<current_dimension; ++j)
26  {
27  projection_matrix(i,j) = tapkee::gaussian_random()/sqrt(target_dimension);
28  }
29  }
30 
31  return projection_matrix;
32 }
33 
34 }
35 }
36 
37 #endif
Eigen::Matrix< tapkee::ScalarType, Eigen::Dynamic, Eigen::Dynamic > DenseMatrix
dense matrix type (non-overridable)
Definition: types.hpp:23
int IndexType
indexing type (non-overridable) set to int for compatibility with OpenMP 2.0
Definition: types.hpp:19
ScalarType gaussian_random()
Definition: random.hpp:39
DenseMatrix gaussian_projection_matrix(IndexType target_dimension, IndexType current_dimension)