Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
labrobotica
algorithms
csm
Commits
7f761d7d
Commit
7f761d7d
authored
3 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
debuging singular matrix
parent
ece31b55
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sm/lib/gpc/gpc.c
+0
-14
0 additions, 14 deletions
sm/lib/gpc/gpc.c
sm/lib/gpc/gpc_utils.c
+17
-0
17 additions, 0 deletions
sm/lib/gpc/gpc_utils.c
sm/lib/gpc/gpc_utils.h
+2
-0
2 additions, 0 deletions
sm/lib/gpc/gpc_utils.h
with
19 additions
and
14 deletions
sm/lib/gpc/gpc.c
+
0
−
14
View file @
7f761d7d
...
...
@@ -26,20 +26,6 @@
#define M(matrix, rows, col) static gsl_matrix*matrix=0; if(!matrix) matrix = gsl_matrix_alloc(rows,col);
#define MF(matrix)
/*gsl_matrix_free(matrix)*/
static
int
singular
(
const
gsl_matrix
*
LU
)
{
size_t
i
,
n
=
LU
->
size1
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
double
u
=
gsl_matrix_get
(
LU
,
i
,
i
);
if
(
u
==
0
)
return
1
;
}
return
0
;
}
int
gpc_solve
(
int
K
,
const
struct
gpc_corr
*
c
,
const
double
*
x0
,
const
double
*
cov_x0
,
double
*
x_out
)
...
...
This diff is collapsed.
Click to expand it.
sm/lib/gpc/gpc_utils.c
+
17
−
0
View file @
7f761d7d
...
...
@@ -30,6 +30,11 @@ void m_inv(const gsl_matrix*A, gsl_matrix*invA) {
/* Make LU decomposition of matrix m */
int
s
;
gsl_linalg_LU_decomp
(
m
,
perm
,
&
s
);
if
(
singular
(
m
))
{
fprintf
(
stderr
,
"m_inv: m is singular!
\n
"
);
return
;
}
/* Invert the matrix m */
gsl_linalg_LU_invert
(
m
,
perm
,
invA
);
gsl_permutation_free
(
perm
);
...
...
@@ -132,3 +137,15 @@ void m_display(const char*str, gsl_matrix*m) {
}
}
int
singular
(
const
gsl_matrix
*
LU
)
{
size_t
i
,
n
=
LU
->
size1
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
double
u
=
gsl_matrix_get
(
LU
,
i
,
i
);
if
(
u
==
0
)
return
1
;
}
return
0
;
}
This diff is collapsed.
Click to expand it.
sm/lib/gpc/gpc_utils.h
+
2
−
0
View file @
7f761d7d
...
...
@@ -28,4 +28,6 @@ int poly_greatest_real_root(unsigned int n, const double*a, double *root);
void
m_display
(
const
char
*
str
,
gsl_matrix
*
m
);
int
singular
(
const
gsl_matrix
*
LU
);
#endif
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