Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
b03f81ee
Commit
b03f81ee
authored
Feb 06, 2013
by
Pierre Kraemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try some changes in Eigen cholesky solver
parent
734a59a7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
44 deletions
+56
-44
SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h
...s/Plugins/surfaceDeformation/include/surfaceDeformation.h
+3
-1
SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
...pps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
+2
-0
ThirdParty/include/OpenNL/cholesky_solver.h
ThirdParty/include/OpenNL/cholesky_solver.h
+28
-31
ThirdParty/include/OpenNL/linear_solver.h
ThirdParty/include/OpenNL/linear_solver.h
+10
-3
ThirdParty/include/OpenNL/linear_solver.hpp
ThirdParty/include/OpenNL/linear_solver.hpp
+13
-9
No files found.
SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h
View file @
b03f81ee
...
@@ -6,12 +6,14 @@
...
@@ -6,12 +6,14 @@
#include "ui_surfaceDeformation.h"
#include "ui_surfaceDeformation.h"
#include "Utils/drawer.h"
//
#include "Utils/drawer.h"
using
namespace
CGoGN
;
using
namespace
CGoGN
;
using
namespace
SCHNApps
;
using
namespace
SCHNApps
;
namespace
CGoGN
{
namespace
Utils
{
class
Drawer
;
}
}
enum
SelectionMode
enum
SelectionMode
{
{
...
...
SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
View file @
b03f81ee
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
#include "Algo/Selection/raySelector.h"
#include "Algo/Selection/raySelector.h"
#include "Algo/Selection/collector.h"
#include "Algo/Selection/collector.h"
#include "Utils/drawer.h"
#include <QKeyEvent>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QMouseEvent>
...
...
ThirdParty/include/OpenNL/cholesky_solver.h
View file @
b03f81ee
...
@@ -32,17 +32,12 @@
...
@@ -32,17 +32,12 @@
#define __CHOLESKY_SOLVER__
#define __CHOLESKY_SOLVER__
#include <cassert>
#include <cassert>
#include "OpenNL/sparse_matrix.h"
#include "cholmod.h"
#include "CHOLMOD/cholmod.h"
template
<
class
MATRIX
,
class
VECTOR
>
template
<
typename
CoeffType
>
class
Solver_CHOLESKY
class
Solver_CHOLESKY
{
{
public:
public:
typedef
MATRIX
Matrix
;
typedef
VECTOR
Vector
;
typedef
typename
Vector
::
CoeffType
CoeffType
;
Solver_CHOLESKY
()
{
Solver_CHOLESKY
()
{
N
=
0
;
N
=
0
;
factorized_
=
false
;
factorized_
=
false
;
...
@@ -58,40 +53,42 @@ public:
...
@@ -58,40 +53,42 @@ public:
bool
factorized
()
{
return
factorized_
;
}
bool
factorized
()
{
return
factorized_
;
}
void
factorize
(
const
MATRIX
&
A_in
)
{
void
factorize
(
const
Eigen
::
SparseMatrix
<
CoeffType
>&
A_in
)
{
assert
(
A_in
.
n
()
==
A_in
.
m
())
;
assert
(
A_in
.
rows
()
==
A_in
.
cols
())
;
assert
(
A_in
.
has_symmetric_storage
())
;
//
assert(A_in.has_symmetric_storage()) ;
N
=
A_in
.
n
()
;
N
=
A_in
.
rows
()
;
int
NNZ
=
A_in
.
nnz
()
;
// int NNZ = A_in.nonZeros
() ;
// Translate sparse matrix into cholmod format
// Translate sparse matrix into cholmod format
cholmod_sparse
*
A
=
cholmod_allocate_sparse
(
N
,
N
,
NNZ
,
false
,
true
,
-
1
,
CHOLMOD_REAL
,
&
c
);
//
cholmod_sparse* A = cholmod_allocate_sparse(N, N, NNZ, false, true, -1, CHOLMOD_REAL, &c);
int
*
colptr
=
static_cast
<
int
*>
(
A
->
p
)
;
//
int* colptr = static_cast<int*>(A->p) ;
int
*
rowind
=
static_cast
<
int
*>
(
A
->
i
)
;
//
int* rowind = static_cast<int*>(A->i) ;
double
*
a
=
static_cast
<
double
*>
(
A
->
x
)
;
//
double* a = static_cast<double*>(A->x) ;
// Convert local Matrix into CHOLMOD Matrix
// Convert local Matrix into CHOLMOD Matrix
int
count
=
0
;
// int count = 0 ;
for
(
int
j
=
0
;
j
<
N
;
j
++
)
{
// for(int j = 0; j < N; j++) {
const
typename
SparseMatrix
<
CoeffType
>::
Column
&
Cj
=
A_in
.
column
(
j
)
;
// const typename SparseMatrix<CoeffType>::Column& Cj = A_in.column(j) ;
colptr
[
j
]
=
count
;
// colptr[j] = count ;
for
(
unsigned
int
ii
=
0
;
ii
<
Cj
.
nb_coeffs
();
ii
++
)
{
// for(unsigned int ii = 0; ii < Cj.nb_coeffs(); ii++) {
a
[
count
]
=
Cj
.
coeff
(
ii
).
a
;
// a[count] = Cj.coeff(ii).a ;
rowind
[
count
]
=
Cj
.
coeff
(
ii
).
index
;
// rowind[count] = Cj.coeff(ii).index ;
count
++
;
// count++ ;
}
// }
}
// }
colptr
[
N
]
=
NNZ
;
// colptr[N] = NNZ ;
cholmod_sparse
A
=
Eigen
::
viewAsCholmod
(
A_in
);
// Factorize
// Factorize
L
=
cholmod_analyze
(
A
,
&
c
)
;
L
=
cholmod_analyze
(
&
A
,
&
c
)
;
cholmod_factorize
(
A
,
L
,
&
c
)
;
cholmod_factorize
(
&
A
,
L
,
&
c
)
;
factorized_
=
true
;
factorized_
=
true
;
// Cleanup
// Cleanup
cholmod_free_sparse
(
&
A
,
&
c
)
;
//
cholmod_free_sparse(&A, &c) ;
}
}
void
solve
(
const
VECTOR
&
b_in
,
VECTOR
&
x_out
)
{
void
solve
(
const
VECTOR
&
b_in
,
VECTOR
&
x_out
)
{
...
...
ThirdParty/include/OpenNL/linear_solver.h
View file @
b03f81ee
...
@@ -36,6 +36,9 @@
...
@@ -36,6 +36,9 @@
#include <cassert>
#include <cassert>
#include <cstdlib>
#include <cstdlib>
//#include "cholesky_solver.h"
#include <Eigen/Cholesky>
#include <Eigen/Sparse>
#include <Eigen/Sparse>
...
@@ -188,9 +191,13 @@ private:
...
@@ -188,9 +191,13 @@ private:
Eigen
::
Matrix
<
CoeffType
,
Eigen
::
Dynamic
,
1
>*
x_
;
Eigen
::
Matrix
<
CoeffType
,
Eigen
::
Dynamic
,
1
>*
x_
;
Eigen
::
Matrix
<
CoeffType
,
Eigen
::
Dynamic
,
1
>*
b_
;
Eigen
::
Matrix
<
CoeffType
,
Eigen
::
Dynamic
,
1
>*
b_
;
Eigen
::
ConjugateGradient
<
Eigen
::
SparseMatrix
<
CoeffType
>
>*
symmetric_solver_
;
// Solver_CHOLESKY<CoeffType>* direct_solver_;
Eigen
::
BiCGSTAB
<
Eigen
::
SparseMatrix
<
CoeffType
>
>*
nonsymmetric_solver_
;
Eigen
::
SimplicialLDLT
<
Eigen
::
SparseMatrix
<
CoeffType
>
>*
direct_solver_
;
Eigen
::
LDLT
<
Eigen
::
SparseMatrix
<
CoeffType
>
>*
direct_solver_
;
// Eigen::ConjugateGradient<Eigen::SparseMatrix<CoeffType> >* symmetric_solver_;
// Eigen::BiCGSTAB<Eigen::SparseMatrix<CoeffType> >* nonsymmetric_solver_;
// Eigen::SimplicialLDLT<Eigen::SparseMatrix<CoeffType> >* direct_solver_;
}
;
}
;
#include "OpenNL/linear_solver.hpp"
#include "OpenNL/linear_solver.hpp"
...
...
ThirdParty/include/OpenNL/linear_solver.hpp
View file @
b03f81ee
...
@@ -33,8 +33,8 @@ LinearSolver<CoeffType>::LinearSolver(unsigned int nb_variables) {
...
@@ -33,8 +33,8 @@ LinearSolver<CoeffType>::LinearSolver(unsigned int nb_variables) {
A_
=
NULL
;
A_
=
NULL
;
x_
=
NULL
;
x_
=
NULL
;
b_
=
NULL
;
b_
=
NULL
;
symmetric_solver_
=
NULL
;
//
symmetric_solver_ = NULL;
nonsymmetric_solver_
=
NULL
;
//
nonsymmetric_solver_ = NULL;
direct_solver_
=
NULL
;
direct_solver_
=
NULL
;
}
}
...
@@ -172,7 +172,10 @@ void LinearSolver<CoeffType>::end_row() {
...
@@ -172,7 +172,10 @@ void LinearSolver<CoeffType>::end_row() {
template
<
typename
CoeffType
>
template
<
typename
CoeffType
>
void
LinearSolver
<
CoeffType
>::
end_system
()
{
void
LinearSolver
<
CoeffType
>::
end_system
()
{
if
(
least_squares_
&&
direct_
&&
!
direct_solver_
)
if
(
least_squares_
&&
direct_
&&
!
direct_solver_
)
direct_solver_
=
new
Eigen
::
SimplicialLDLT
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
(
*
A_
);
direct_solver_
=
new
Eigen
::
LDLT
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
(
*
A_
);
// if(least_squares_ && direct_ && !direct_solver_->factorized())
// direct_solver_->factorize(*A_);
transition
(
IN_SYSTEM
,
CONSTRUCTED
)
;
transition
(
IN_SYSTEM
,
CONSTRUCTED
)
;
}
}
...
@@ -185,12 +188,12 @@ void LinearSolver<CoeffType>::solve() {
...
@@ -185,12 +188,12 @@ void LinearSolver<CoeffType>::solve() {
if
(
direct_
)
{
if
(
direct_
)
{
*
x_
=
direct_solver_
->
solve
(
*
b_
)
;
*
x_
=
direct_solver_
->
solve
(
*
b_
)
;
}
else
{
}
else
{
symmetric_solver_
=
new
Eigen
::
ConjugateGradient
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
(
*
A_
)
;
Eigen
::
ConjugateGradient
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
solver
(
*
A_
)
;
*
x_
=
s
ymmetric_solver_
->
solve
(
*
b_
)
;
*
x_
=
s
olver
->
solve
(
*
b_
)
;
}
}
}
else
{
}
else
{
nonsymmetric_solver_
=
new
Eigen
::
BiCGSTAB
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
(
*
A_
)
;
Eigen
::
BiCGSTAB
<
Eigen
::
SparseMatrix
<
CoeffType
>
>
solver
(
*
A_
)
;
*
x_
=
nonsymmetric_solver_
->
solve
(
*
b_
)
;
*
x_
=
solver
->
solve
(
*
b_
)
;
}
}
vector_to_variables
()
;
vector_to_variables
()
;
transition
(
CONSTRUCTED
,
SOLVED
)
;
transition
(
CONSTRUCTED
,
SOLVED
)
;
...
@@ -206,9 +209,10 @@ void LinearSolver<CoeffType>::reset(bool keep_matrix) {
...
@@ -206,9 +209,10 @@ void LinearSolver<CoeffType>::reset(bool keep_matrix) {
delete
A_
;
A_
=
NULL
;
delete
A_
;
A_
=
NULL
;
delete
x_
;
x_
=
NULL
;
delete
x_
;
x_
=
NULL
;
delete
b_
;
b_
=
NULL
;
delete
b_
;
b_
=
NULL
;
if
(
symmetric_solver_
)
delete
symmetric_solver_
;
symmetric_solver_
=
NULL
;
//
if(symmetric_solver_) delete symmetric_solver_ ; symmetric_solver_ = NULL ;
if
(
nonsymmetric_solver_
)
delete
nonsymmetric_solver_
;
nonsymmetric_solver_
=
NULL
;
//
if(nonsymmetric_solver_) delete nonsymmetric_solver_ ; nonsymmetric_solver_ = NULL ;
if
(
direct_solver_
)
delete
direct_solver_
;
direct_solver_
=
NULL
;
if
(
direct_solver_
)
delete
direct_solver_
;
direct_solver_
=
NULL
;
// direct_solver_->reset();
matrix_already_set_
=
false
;
matrix_already_set_
=
false
;
for
(
unsigned
int
i
=
0
;
i
<
nb_variables_
;
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
nb_variables_
;
++
i
)
{
variable_
[
i
].
unlock
()
;
variable_
[
i
].
unlock
()
;
...
...
Write
Preview
Markdown
is supported
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