Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
1cc09d3e
Commit
1cc09d3e
authored
8 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
add makeCompressed to all functions in sparse_utils
parent
78061ef4
No related branches found
No related tags found
1 merge request
!111
Jet autodiff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ceres_wrapper/sparse_utils.h
+17
-0
17 additions, 0 deletions
src/ceres_wrapper/sparse_utils.h
with
17 additions
and
0 deletions
src/ceres_wrapper/sparse_utils.h
+
17
−
0
View file @
1cc09d3e
...
@@ -17,21 +17,35 @@ namespace wolf
...
@@ -17,21 +17,35 @@ namespace wolf
void
eraseBlockRow
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
RowMajor
>&
A
,
const
unsigned
int
&
_row
,
const
unsigned
int
&
_n_rows
)
void
eraseBlockRow
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
RowMajor
>&
A
,
const
unsigned
int
&
_row
,
const
unsigned
int
&
_n_rows
)
{
{
A
.
middleRows
(
_row
,
_n_rows
)
=
Eigen
::
SparseMatrixs
(
_n_rows
,
A
.
cols
());
A
.
middleRows
(
_row
,
_n_rows
)
=
Eigen
::
SparseMatrixs
(
_n_rows
,
A
.
cols
());
A
.
makeCompressed
();
}
}
void
eraseBlockRow
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
ColMajor
>&
A
,
const
unsigned
int
&
_row
,
const
unsigned
int
&
_n_rows
)
void
eraseBlockRow
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
ColMajor
>&
A
,
const
unsigned
int
&
_row
,
const
unsigned
int
&
_n_rows
)
{
{
A
.
prune
([
&
](
int
i
,
int
,
Scalar
)
{
return
i
>=
_row
&&
i
<
_row
+
_n_rows
;
});
A
.
prune
([
&
](
int
i
,
int
,
Scalar
)
{
return
i
>=
_row
&&
i
<
_row
+
_n_rows
;
});
A
.
makeCompressed
();
}
}
void
eraseBlockCol
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
ColMajor
>&
A
,
const
unsigned
int
&
_col
,
const
unsigned
int
&
_n_cols
)
void
eraseBlockCol
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
ColMajor
>&
A
,
const
unsigned
int
&
_col
,
const
unsigned
int
&
_n_cols
)
{
{
A
.
middleCols
(
_col
,
_n_cols
)
=
Eigen
::
SparseMatrixs
(
A
.
rows
(),
_n_cols
);
A
.
middleCols
(
_col
,
_n_cols
)
=
Eigen
::
SparseMatrixs
(
A
.
rows
(),
_n_cols
);
A
.
makeCompressed
();
}
}
void
eraseBlockCol
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
RowMajor
>&
A
,
const
unsigned
int
&
_col
,
const
unsigned
int
&
_n_cols
)
void
eraseBlockCol
(
Eigen
::
SparseMatrix
<
Scalar
,
Eigen
::
RowMajor
>&
A
,
const
unsigned
int
&
_col
,
const
unsigned
int
&
_n_cols
)
{
{
A
.
prune
([
&
](
int
,
int
j
,
Scalar
)
{
return
j
>=
_col
&&
j
<
_col
+
_n_cols
;
});
A
.
prune
([
&
](
int
,
int
j
,
Scalar
)
{
return
j
>=
_col
&&
j
<
_col
+
_n_cols
;
});
A
.
makeCompressed
();
}
template
<
int
_Options
,
typename
_StorageIndex
>
void
assignSparseBlock
(
const
Eigen
::
MatrixXs
&
ins
,
Eigen
::
SparseMatrix
<
Scalar
,
_Options
,
_StorageIndex
>&
original
,
const
unsigned
int
&
row
,
const
unsigned
int
&
col
)
{
for
(
auto
ins_row
=
0
;
ins_row
<
ins
.
rows
();
ins_row
++
)
for
(
auto
ins_col
=
0
;
ins_col
<
ins
.
cols
();
ins_col
++
)
original
.
coeffRef
(
row
+
ins_row
,
col
+
ins_col
)
=
ins
(
ins_row
,
ins_col
);
original
.
makeCompressed
();
}
}
template
<
int
_Options
,
typename
_StorageIndex
>
template
<
int
_Options
,
typename
_StorageIndex
>
...
@@ -58,6 +72,7 @@ void assignBlockRow(Eigen::SparseMatrix<Scalar, Eigen::RowMajor>& A, const Eigen
...
@@ -58,6 +72,7 @@ void assignBlockRow(Eigen::SparseMatrix<Scalar, Eigen::RowMajor>& A, const Eigen
{
{
assert
(
A
.
rows
()
>=
_row
+
ins
.
rows
()
&&
A
.
cols
()
==
ins
.
cols
());
assert
(
A
.
rows
()
>=
_row
+
ins
.
rows
()
&&
A
.
cols
()
==
ins
.
cols
());
A
.
middleRows
(
_row
,
ins
.
rows
())
=
ins
;
A
.
middleRows
(
_row
,
ins
.
rows
())
=
ins
;
A
.
makeCompressed
();
}
}
Eigen
::
SparseMatrixs
createBlockDiagonal
(
const
std
::
vector
<
Eigen
::
MatrixXs
>&
_diag_blocs
)
Eigen
::
SparseMatrixs
createBlockDiagonal
(
const
std
::
vector
<
Eigen
::
MatrixXs
>&
_diag_blocs
)
...
@@ -74,6 +89,8 @@ Eigen::SparseMatrixs createBlockDiagonal(const std::vector<Eigen::MatrixXs>& _di
...
@@ -74,6 +89,8 @@ Eigen::SparseMatrixs createBlockDiagonal(const std::vector<Eigen::MatrixXs>& _di
pos
+=
dim
;
pos
+=
dim
;
}
}
M
.
makeCompressed
();
return
M
;
return
M
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment