/usr/include/shogun/lib/tapkee/projection.hpp is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /* This software is distributed under BSD 3-clause license (see LICENSE file).
*
* Copyright (c) 2012-2013 Sergey Lisitsyn, Fernando Iglesias
*/
#ifndef TAPKEE_PROJECTION_H_
#define TAPKEE_PROJECTION_H_
namespace tapkee
{
//! A base class for implementation of projecting
struct ProjectionImplementation
{
virtual ~ProjectionImplementation()
{
}
//! Projects provided vector to new space
//! @param vec vector to be projected
//! @return projected vector
virtual DenseVector project(const DenseVector& vec) = 0;
};
//! A pimpl wrapper for projecting function
struct ProjectingFunction
{
ProjectingFunction() : implementation(NULL) {};
ProjectingFunction(ProjectionImplementation* impl) : implementation(impl) {};
//! Destroys current implementation
void clear()
{
delete implementation;
}
//! Projects provided vector to new space
//! @param vec vector to be projected
//! @return projected vector
inline DenseVector operator()(const DenseVector& vec)
{
return implementation->project(vec);
}
ProjectionImplementation* implementation;
};
//! Basic @ref ProjectionImplementation that subtracts mean from the vector
//! and multiplies projecting matrix with it.
struct MatrixProjectionImplementation : public ProjectionImplementation
{
MatrixProjectionImplementation(DenseMatrix matrix, DenseVector mean) : proj_mat(matrix), mean_vec(mean)
{
}
virtual ~MatrixProjectionImplementation()
{
}
virtual DenseVector project(const DenseVector& vec)
{
return proj_mat*(vec-mean_vec);
}
DenseMatrix proj_mat;
DenseVector mean_vec;
};
}
#endif
|