GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
predrandfeats.h
00001 /*
00002  * The GURLS Package in C++
00003  *
00004  * Copyright (C) 2011-1013, Matteo Santoro
00005  * All rights reserved.
00006  *
00007  * author:  M. Santoro
00008  * email:   matteo.santoro@gmail.com
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  *
00014  *     * Redistributions of source code must retain the above
00015  *       copyright notice, this list of conditions and the following
00016  *       disclaimer.
00017  *     * Redistributions in binary form must reproduce the above
00018  *       copyright notice, this list of conditions and the following
00019  *       disclaimer in the documentation and/or other materials
00020  *       provided with the distribution.
00021  *     * Neither the name(s) of the copyright holders nor the names
00022  *       of its contributors or of the Massacusetts Institute of
00023  *       Technology or of the Italian Institute of Technology may be
00024  *       used to endorse or promote products derived from this software
00025  *       without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00028  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00029  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00030  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00031  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00032  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00033  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00034  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00036  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00037  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00038  * POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef _GURLS_PREDRANDFEATS_H
00042 #define _GURLS_PREDRANDFEATS_H
00043 
00044 #include <cmath>
00045 
00046 #include "gurls++/pred.h"
00047 
00048 #include "gurls++/gmath.h"
00049 #include "gurls++/gmat2d.h"
00050 #include "gurls++/options.h"
00051 #include "gurls++/optlist.h"
00052 #include "gurls++/utils.h"
00053 
00054 
00055 namespace gurls {
00056 
00066 template <typename T>
00067 class PredRandFeats: public Prediction<T> {
00068 
00069 public:
00080     GurlsOptionsList *execute(const gMat2D<T>& X, const gMat2D<T>& Y, const GurlsOptionsList& opt);
00081 };
00082 
00083 template <typename T>
00084 GurlsOptionsList *PredRandFeats<T>::execute(const gMat2D<T>& X, const gMat2D<T>& /*Y*/, const GurlsOptionsList &opt)
00085 {
00086 
00087 //    G = rp_apply_real(X, opt.rls.proj);
00088     const gMat2D<T>& proj = opt.getOptValue<OptMatrix<gMat2D<T> > >("optimizer.proj");
00089     gMat2D<T> *G = rp_apply_real(X, proj);
00090 
00091 //    scores = G*opt.rls.W;
00092     const gMat2D<T>& W = opt.getOptValue<OptMatrix<gMat2D<T> > >("optimizer.W");
00093 
00094     gMat2D<T> *scores_mat = new gMat2D<T>(G->rows(), W.cols());
00095     dot(G->getData(), W.getData(), scores_mat->getData(), G->rows(), G->cols(), W.rows(), W.cols(), G->rows(), W.cols(), CblasNoTrans, CblasNoTrans, CblasColMajor);
00096 
00097 
00098     GurlsOptionsList* pred = new GurlsOptionsList("pred");
00099     pred->addOpt("scores", new OptMatrix<gMat2D<T> >(*scores_mat));
00100 
00101     return pred;
00102 }
00103 
00104 }
00105 
00106 #endif // _GURLS_PREDRANDFEATS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends