Added some extra files
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: dual_manifold_engine.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 03/18/2008 11:08:05 PM EDT
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: Nikolaos Vasiloglou (NV), nvasil@ieee.org
|
||||
* Company: Georgia Tech Fastlab-ESP Lab
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
#ifndef DUAL_MANIFOLD_ENGINE_
|
||||
#define DUAL_MANIFOLD_ENGINE_
|
||||
#include "dual_manifold_objective.h"
|
||||
#include "../l_bfgs/l_bfgs.h"
|
||||
|
||||
template<typename OptimizedFunction>
|
||||
class DualManifoldEngine {
|
||||
public:
|
||||
void Init(datanode *module);
|
||||
void Destruct();
|
||||
|
||||
|
||||
private:
|
||||
LBfgs<OptimizedFunction> lbfgs1_;
|
||||
LBfgs<OptimizedFunction> lbfgs2_;
|
||||
};
|
||||
|
||||
#include "dual_manifold_engine_impl.h"
|
||||
#endif // DUAL_MANIFOLD_ENGINE_
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: dual_manifold_engine_impl.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 03/18/2008 11:34:02 PM EDT
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: Nikolaos Vasiloglou (NV), nvasil@ieee.org
|
||||
* Company: Georgia Tech Fastlab-ESP Lab
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
template<typename OptimizedFunction>
|
||||
DualManifoldEngine<OptimizedFunction>::Init(datanode *module,
|
||||
Matrix &matrix1, Matrix &matrix2,
|
||||
ArrayList<std::pair<index_t, index_t> > &pairs_to_consider,
|
||||
ArrayList<double> &dot_prod_values) {
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class DualMaxVariance {
|
||||
|
||||
private:
|
||||
datanode *module_;
|
||||
ArrayList<std::pair<index_t, index_t> > *pairs_to_consider_;
|
||||
ArrayList<std::pair<index_t, index_t> > pairs_to_consider_;
|
||||
ArrayList<double> *dot_prod_values_;
|
||||
Matrix *other_part_;
|
||||
Vector eq_lagrange_mult_;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
*/
|
||||
|
||||
void DualMaxVarianc::eInit(datanode *module, Matrix *other_part,
|
||||
ArrayList<std::pair<index_t, index_t> > *pairs_to_consider,
|
||||
ArrayList<std::pair<index_t, index_t> > pairs_to_consider,
|
||||
ArrayList<double> *dot_prod_values) {
|
||||
other_part_=other_part;
|
||||
module_=module;
|
||||
pairs_to_consider_=pairs_to_consider;
|
||||
dot_prod_values_=dot_prod_values;
|
||||
eq_lagrange_mult_.Init(pairs_to_consider_->size());
|
||||
eq_lagrange_mult_.Init(pairs_to_consider_.size());
|
||||
eq_lagrange_mult_.SetAll(1.0);
|
||||
}
|
||||
void DualMaxVariance::ComputeGradient(Matrix &coordinates,
|
||||
@@ -31,8 +31,8 @@ void DualMaxVariance::ComputeGradient(Matrix &coordinates,
|
||||
gradient->CopyValues(coordinates);
|
||||
la::Scale(-2.0, &gradient);
|
||||
for(index_t i=0; i<pairs_to_concider_.size(); i++) {
|
||||
index_t n1=(*pairs_to_consider_a)[i].first;
|
||||
index_t n2=(*pairs_to_consider_a)[i].second;
|
||||
index_t n1=pairs_to_consider_[i].first;
|
||||
index_t n2=pairs_to_consider_[i].second;
|
||||
double *p1=coordinates.GetColumnPtr(n1);
|
||||
double *p2=other_part_->GetColumnPtr(n2);
|
||||
double diff=la::Dot(dimension, p1, p2)-(*dot_prod_values)[i];
|
||||
@@ -56,8 +56,8 @@ void DualMaxVariance::ComputeFeasibilityError(Matrix &coordinates,
|
||||
*error=0;
|
||||
index_t dimension=coordinates.n_rows();
|
||||
for(index_t i=0; i<pairs_to_concider_.size(); i++) {
|
||||
index_t n1=(*pairs_to_consider_a)[i].first;
|
||||
index_t n2=(*pairs_to_consider_a)[i].second;
|
||||
index_t n1=pairs_to_consider_[i].first;
|
||||
index_t n2=pairs_to_consider_[i].second;
|
||||
double *p1=coordinates.GetColumnPtr(n1);
|
||||
double *p2=other_part_->GetColumnPtr(n2);
|
||||
*error+=math::Sqr(la::Dot(dimension, p1, p2)-(*dot_prod_values)[i]);
|
||||
@@ -67,8 +67,8 @@ double DualMaxVariance::ComputeLagrangian(Matrix &coordinates) {
|
||||
double lagrangian=0;
|
||||
ComputeObjective(coordinates, &lagrangian);
|
||||
for(index_t i=0; i<pairs_to_concider_.size(); i++) {
|
||||
index_t n1=(*pairs_to_consider_a)[i].first;
|
||||
index_t n2=(*pairs_to_consider_a)[i].second;
|
||||
index_t n1=pairs_to_consider_[i].first;
|
||||
index_t n2=pairs_to_consider_[i].second;
|
||||
double *p1=coordinates.GetColumnPtr(n1);
|
||||
double *p2=other_part_->GetColumnPtr(n2);
|
||||
double diff=la::Dot(dimension, p1, p2)-(*dot_prod_values)[i];
|
||||
@@ -79,8 +79,8 @@ double DualMaxVariance::ComputeLagrangian(Matrix &coordinates) {
|
||||
void DualMaxVariance::UpdateLagrangeMult(Matrix &coordinates) {
|
||||
index_t dimension=coordinates.n_rows();
|
||||
for(index_t i=0; i<num_of_nearest_pairs_; i++) {
|
||||
index_t n1=(*pairs_to_consider_a)[i].first;
|
||||
index_t n2=(*pairs_to_consider_a)[i].second;
|
||||
index_t n1=pairs_to_consider_[i].first;
|
||||
index_t n2=pairs_to_consider_[i].second;
|
||||
double *p1=coordinates.GetColumnPtr(n1);
|
||||
double *p2=other_part_->GetColumnPtr(n2);
|
||||
double diff=la::Dot(dimension, p1, p2)-(*dot_prod_values)[i];
|
||||
|
||||
Reference in New Issue
Block a user