Tapkee
projection.hpp
Go to the documentation of this file.
00001 /* This software is distributed under BSD 3-clause license (see LICENSE file).
00002  *
00003  * Copyright (c) 2012-2013 Sergey Lisitsyn, Fernando Iglesias
00004  */
00005 
00006 #ifndef TAPKEE_PROJECTION_H_
00007 #define TAPKEE_PROJECTION_H_
00008 
00009 namespace tapkee
00010 {
00011 
00013 struct ProjectionImplementation
00014 {
00015     virtual ~ProjectionImplementation()
00016     {
00017     }
00021     virtual DenseVector project(const DenseVector& vec) = 0;
00022 };
00023 
00025 struct ProjectingFunction
00026 {
00027     ProjectingFunction() : implementation(NULL) {};
00028     ProjectingFunction(ProjectionImplementation* impl) : implementation(impl) {};
00030     void clear() 
00031     { 
00032         delete implementation;
00033     }
00037     inline DenseVector operator()(const DenseVector& vec)
00038     {
00039         return implementation->project(vec);
00040     }
00041     ProjectionImplementation* implementation;
00042 };
00043 
00046 struct MatrixProjectionImplementation : public ProjectionImplementation
00047 {
00048     MatrixProjectionImplementation(DenseMatrix matrix, DenseVector mean) : proj_mat(matrix), mean_vec(mean)
00049     {
00050     }
00051 
00052     virtual ~MatrixProjectionImplementation()
00053     {
00054     }
00055 
00056     virtual DenseVector project(const DenseVector& vec) 
00057     {
00058         return proj_mat*(vec-mean_vec);
00059     }
00060 
00061     DenseMatrix proj_mat;
00062     DenseVector mean_vec;
00063 };
00064 
00065 }
00066 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines