Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CoMISo
CoMISo
Commits
2a21d58a
Commit
2a21d58a
authored
Oct 07, 2016
by
David Bommes
Browse files
added LinearConstraintConverter
parent
1d1b3fbc
Pipeline
#3012
passed with stage
in 6 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
NSolver/LinearConstraintConverter.hh
0 → 100644
View file @
2a21d58a
//=============================================================================
//
// CLASS LinearConstraintConverter
//
//=============================================================================
#ifndef COMISO_LINEARCONSTRAINTCONVERTER_HH
#define COMISO_LINEARCONSTRAINTCONVERTER_HH
//== INCLUDES =================================================================
#include
<CoMISo/Config/CoMISoDefines.hh>
#include
"NConstraintInterface.hh"
#include
"LinearConstraint.hh"
#include
<Eigen/StdVector>
#include
<Eigen/Dense>
#include
<Eigen/Sparse>
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace
COMISO
{
//== CLASS DEFINITION =========================================================
/** \class NProblemGmmInterface NProblemGmmInterface.hh <ACG/.../NPRoblemGmmInterface.hh>
Brief Description.
A more elaborate description follows.
*/
class
COMISODLLEXPORT
LinearConstraintConverter
{
public:
// sparse vector type
typedef
NConstraintInterface
::
SVectorNC
SVectorNC
;
typedef
Eigen
::
SparseMatrix
<
double
,
Eigen
::
ColMajor
>
SparseMatrixC
;
typedef
Eigen
::
SparseMatrix
<
double
,
Eigen
::
RowMajor
>
SparseMatrixR
;
typedef
Eigen
::
VectorXd
VectorXd
;
LinearConstraintConverter
(
SparseMatrixR
&
_A
,
VectorXd
&
_b
)
:
A_
(
_A
),
b_
(
_b
),
linear_constraints_initialized_
(
false
)
{}
LinearConstraintConverter
(
SparseMatrixC
&
_A
,
VectorXd
&
_b
)
:
A_
(
_A
),
b_
(
_b
),
linear_constraints_initialized_
(
false
)
{}
std
::
vector
<
NConstraintInterface
*>&
constraints_nsolver
()
{
initialize_linear_constraints
();
return
constraint_pointers_
;
}
private:
void
initialize_linear_constraints
()
{
if
(
!
linear_constraints_initialized_
)
{
// tag as done
linear_constraints_initialized_
=
true
;
int
m
=
A_
.
rows
();
int
n
=
A_
.
cols
();
linear_constraints_
.
clear
();
linear_constraints_
.
resize
(
m
);
constraint_pointers_
.
clear
();
constraint_pointers_
.
resize
(
m
);
for
(
int
i
=
0
;
i
<
m
;
++
i
)
{
// convert i-th constraint
linear_constraints_
.
resize
(
n
);
linear_constraints_
[
i
].
coeffs
()
=
A_
.
row
(
i
);
linear_constraints_
[
i
].
b
()
=
-
b_
[
i
];
// store pointer
constraint_pointers_
[
i
]
=
&
(
linear_constraints_
[
i
]);
}
}
}
private:
SparseMatrixR
A_
;
VectorXd
b_
;
bool
linear_constraints_initialized_
;
std
::
vector
<
LinearConstraint
>
linear_constraints_
;
std
::
vector
<
NConstraintInterface
*>
constraint_pointers_
;
};
//=============================================================================
}
// namespace COMISO
//=============================================================================
//=============================================================================
#endif // ACG_LINEARCONSTRAINTCONVERTER_HH defined
//=============================================================================
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment