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
ba0abeed
Commit
ba0abeed
authored
3 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
7f761d7d
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
+4
-8
4 additions, 8 deletions
sm/lib/gpc/gpc.c
sm/lib/gpc/gpc_utils.c
+20
-2
20 additions, 2 deletions
sm/lib/gpc/gpc_utils.c
sm/lib/gpc/gpc_utils.h
+3
-1
3 additions, 1 deletion
sm/lib/gpc/gpc_utils.h
with
27 additions
and
11 deletions
sm/lib/gpc/gpc.c
+
4
−
8
View file @
ba0abeed
...
...
@@ -131,12 +131,11 @@ int gpc_solve(int K, const struct gpc_corr*c,
/* mS = mD - mB.trans * mA.inv * mB;
temp22b = inv(A) */
if
(
singular
(
mA
)
)
if
(
m_inv
(
mA
,
temp22b
)
==
0
)
{
sm_error
(
"gpc_solve: mA is singular!
\n
"
);
return
0
;
}
m_inv
(
mA
,
temp22b
);
/* temp22c = inv(A) * mB */
m_mult
(
temp22b
,
mB
,
temp22c
);
/* temp22 = mB' */
...
...
@@ -146,12 +145,11 @@ int gpc_solve(int K, const struct gpc_corr*c,
m_add
(
mD
,
temp22b
,
mS
);
/* mSa = mS.inv * mS.det; */
if
(
singular
(
mS
)
)
if
(
m_inv
(
mS
,
mSa
)
==
0
)
{
sm_error
(
"gpc_solve: mS is singular!
\n
"
);
return
0
;
}
m_inv
(
mS
,
mSa
);
m_scale
(
m_det
(
mS
),
mSa
);
if
(
TRACE_ALGO
)
{
...
...
@@ -173,12 +171,11 @@ int gpc_solve(int K, const struct gpc_corr*c,
m_trans
(
g1
,
g1t
);
m_trans
(
g2
,
g2t
);
m_trans
(
mB
,
mBt
);
if
(
singular
(
mA
)
)
if
(
m_inv
(
mA
,
mAi
)
==
0
)
{
sm_error
(
"gpc_solve: mA is singular!
\n
"
);
return
0
;
}
m_inv
(
mA
,
mAi
);
M
(
m1t
,
1
,
2
);
M
(
m1
,
2
,
1
);
M
(
m2t
,
1
,
2
);
M
(
m2
,
2
,
1
);
...
...
@@ -270,12 +267,11 @@ int gpc_solve(int K, const struct gpc_corr*c,
m_scale
(
2
*
lambda
,
W
);
gsl_matrix_add
(
bigM
,
W
);
if
(
singular
(
bigM
)
)
if
(
m_inv
(
bigM
,
temp44
)
==
0
)
{
sm_error
(
"gpc_solve: bigM is singular!
\n
"
);
return
0
;
}
m_inv
(
bigM
,
temp44
);
m_mult
(
temp44
,
g
,
x
);
m_scale
(
-
1
.
0
,
x
);
...
...
This diff is collapsed.
Click to expand it.
sm/lib/gpc/gpc_utils.c
+
20
−
2
View file @
ba0abeed
...
...
@@ -22,7 +22,7 @@ void m_add (const gsl_matrix*A, const gsl_matrix*B, gsl_matrix*ApB){
gsl_matrix_add
(
ApB
,
B
);
}
void
m_inv
(
const
gsl_matrix
*
A
,
gsl_matrix
*
invA
)
{
int
m_inv
(
const
gsl_matrix
*
A
,
gsl_matrix
*
invA
)
{
unsigned
int
n
=
A
->
size1
;
gsl_matrix
*
m
=
gsl_matrix_alloc
(
n
,
n
);
gsl_matrix_memcpy
(
m
,
A
);
...
...
@@ -33,12 +33,15 @@ void m_inv(const gsl_matrix*A, gsl_matrix*invA) {
if
(
singular
(
m
))
{
fprintf
(
stderr
,
"m_inv: m is singular!
\n
"
);
return
;
print_mat
(
A
);
return
0
;
}
/* Invert the matrix m */
gsl_linalg_LU_invert
(
m
,
perm
,
invA
);
gsl_permutation_free
(
perm
);
gsl_matrix_free
(
m
);
return
1
;
}
double
m_det
(
const
gsl_matrix
*
A
)
{
...
...
@@ -149,3 +152,18 @@ int singular (const gsl_matrix * LU)
return
0
;
}
void
print_mat
(
const
gsl_matrix
*
LU
)
{
size_t
i
,
j
,
n
=
LU
->
size1
,
m
=
LU
->
size2
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
j
=
0
;
j
<
m
;
j
++
)
{
printf
(
"
\t
%.5f"
,
gsl_matrix_get
(
LU
,
i
,
j
));
}
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
}
This diff is collapsed.
Click to expand it.
sm/lib/gpc/gpc_utils.h
+
3
−
1
View file @
ba0abeed
...
...
@@ -18,7 +18,7 @@ void m_add(const gsl_matrix*A, const gsl_matrix*B, gsl_matrix*ApB);
void
m_add_to
(
const
gsl_matrix
*
A
,
gsl_matrix
*
B
);
void
m_scale
(
double
m
,
gsl_matrix
*
A
);
double
m_dot
(
const
gsl_matrix
*
A
,
const
gsl_matrix
*
B
);
void
m_inv
(
const
gsl_matrix
*
A
,
gsl_matrix
*
invA
);
int
m_inv
(
const
gsl_matrix
*
A
,
gsl_matrix
*
invA
);
double
m_det
(
const
gsl_matrix
*
A
);
/* Returns the real part of the roots in roots */
...
...
@@ -30,4 +30,6 @@ void m_display(const char*str, gsl_matrix*m);
int
singular
(
const
gsl_matrix
*
LU
);
void
print_mat
(
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