Commit 7dd9cfab authored by Max Lyon's avatar Max Lyon
Browse files

Merge branch 'master' into Progressive_Embedding

parents 4ba0cf7a 4da5ab5d
Pipeline #14753 passed with stages
in 4 minutes and 16 seconds
......@@ -13,19 +13,6 @@ macos-c++11:
tags:
- Apple
CoMISo-VS2013-Qt-5.5.1-x64:
variables:
BUILD_PLATFORM: "VS2013"
ARCHITECTURE: "x64"
QT_VERSION: "Qt5.5.1"
GIT_SUBMODULE_STRATEGY: recursive
COMPILER: "VS2013"
script: "CI\\Windows.bat"
tags:
- VS2013
- Qt551
CoMISo-VS2017-Qt-5.10.1-x64:
variables:
BUILD_PLATFORM: "VS2017"
......
Base @ 5e38f629
Subproject commit 3623fbdfb4eba14a65926ff4034bc3916eab2cf0
Subproject commit 5e38f629fc7c7ae12316db1f19e6f878c1387bb2
......@@ -3,15 +3,18 @@
#include <CoMISo/Config/config.hh>
#include <CoMISo/Utils/StopWatch.hh>
#include <vector>
#include <CoMISo/NSolver/NProblemInterface.hh>
#include <Base/Code/Quality.hh>
#include <Base/Debug/DebOut.hh>
LOW_CODE_QUALITY_SECTION_BEGIN
#include <Eigen/Eigen>
#include <Eigen/Core>
#include <Eigen/Sparse>
LOW_CODE_QUALITY_SECTION_END
#include <vector>
//== NAMESPACES ===============================================================
......@@ -26,36 +29,31 @@ public:
// typedef Eigen::DynamicSparseMatrix<double,Eigen::ColMajor> SMatrixNP;
QuadraticProblem()
: A_(0,0), b_(Eigen::VectorXd::Index(0)), c_(0.0)
{
}
: A_(0, 0), b_(Eigen::VectorXd::Index(0)), c_(0.0)
{}
QuadraticProblem(SMatrixNP& _A, Eigen::VectorXd& _b, const double _c)
: A_(_A), c_(_c)
QuadraticProblem(SMatrixNP& _A, const Eigen::VectorXd& _b, const double _c)
{
if(A_.rows() != A_.cols())
std::cerr << "Warning: matrix not square in QuadraticProblem" << std::endl;
b_ = _b;
x_ = Eigen::VectorXd::Zero(A_.cols());
set_A(_A);
set_b(_b);
set_c(_c);
}
// number of unknowns
virtual int n_unknowns()
{
return A_.rows();
return A_.rows();
}
// initial value where the optimization should start from
virtual void initial_x(double* _x)
{
for( int i=0; i<this->n_unknowns(); ++i)
_x[i] = x_[i];
for (int i = 0; i < this->n_unknowns(); ++i)
_x[i] = x_[i];
}
// function evaluation at location _x
virtual double eval_f( const double* _x )
virtual double eval_f(const double* _x)
{
Eigen::Map<const Eigen::VectorXd> x(_x, this->n_unknowns());
......@@ -63,22 +61,22 @@ public:
}
// gradient evaluation at location _x
virtual void eval_gradient( const double* _x, double* _g)
virtual void eval_gradient(const double* _x, double* _g)
{
Eigen::Map<const Eigen::VectorXd> x(_x, this->n_unknowns());
Eigen::Map<Eigen::VectorXd> g(_g, this->n_unknowns());
g = A_*x - b_;
}
}
// hessian matrix evaluation at location _x
virtual void eval_hessian ( const double* _x, SMatrixNP& _H)
virtual void eval_hessian(const double* _x, SMatrixNP& _H)
{
_H = A_;
}
// print result
virtual void store_result ( const double* _x )
virtual void store_result(const double* _x)
{
Eigen::Map<const Eigen::VectorXd> x(_x, this->n_unknowns());
x_ = x;
......@@ -89,16 +87,15 @@ public:
double c() const {return c_;}
// get current solution
Eigen::VectorXd& x() { return x_;}
Eigen::VectorXd& x() { return x_; }
// advanced properties
virtual bool constant_hessian() const { return true; }
virtual bool constant_hessian() const { return true; }
void set_A(const SMatrixNP& _A)
{
DEB_error_if(_A.rows() != _A.cols(), "Square matrix expected");
A_ = _A;
if(A_.rows() != A_.cols())
std::cerr << "Warning: matrix not square in QuadraticProblem" << std::endl;
x_ = Eigen::VectorXd::Zero(A_.cols());
}
......@@ -107,19 +104,18 @@ public:
b_ = _b;
}
void set_c( const double _c)
void set_c(const double _c)
{
c_ = _c;
}
private:
// quadratic problem 0.5*x^T A x -x^t b + c
SMatrixNP A_;
Eigen::VectorXd b_;
double c_;
// current solution, which is also used as initial value
Eigen::VectorXd x_;
SMatrixNP A_;
Eigen::VectorXd b_;
double c_;
// current solution, which is also used as initial value
Eigen::VectorXd x_;
};
//=============================================================================
......
......@@ -751,11 +751,11 @@ void f(const gmm::row_matrix<GMM_VectorT>& _G, EIGEN_MatrixT& _E)
// convert a gmm col-sparse matrix into an eigen sparse matrix
template <class GMM_RealT, class EIGEN_MatrixT>
void f(const gmm::csc_matrix<GMM_RealT,0>& _G, EIGEN_MatrixT& _E)
void f(const gmm::csc_matrix<GMM_RealT>& _G, EIGEN_MatrixT& _E)
{
typedef typename EIGEN_MatrixT::Scalar Scalar;
typedef typename gmm::csc_matrix<GMM_RealT,0> GMM_MatrixT;
typedef typename gmm::csc_matrix<GMM_RealT> GMM_MatrixT;
typedef typename gmm::linalg_traits<GMM_MatrixT>::const_sub_col_type ColT;
typedef typename gmm::linalg_traits<ColT>::const_iterator CIter;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment