Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fdt
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
FSL
fdt
Commits
4c9ad8e2
Commit
4c9ad8e2
authored
12 years ago
by
Moises Fernandez
Browse files
Options
Downloads
Patches
Plain Diff
A method to solve at the same time the Matrix operations: InverseMatrix X Other_Matrix.
parent
5a76f4ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CUDA/solver_mult_inverse.cu
+157
-0
157 additions, 0 deletions
CUDA/solver_mult_inverse.cu
with
157 additions
and
0 deletions
CUDA/solver_mult_inverse.cu
0 → 100644
+
157
−
0
View file @
4c9ad8e2
#include
"options.h"
// X = A.i() * B . Used in Levenberg-Marquardt
// MATRIX INVERSE AS NEWMAT LU SOLVER
// implemented in NEWMAT:newmat7.cpp GeneralSolvI.
__device__
void
solver
(
// INPUT
double
*
A
,
double
*
P
,
int
length
,
//OUTPUT
double
*
B
)
{
double
C
[
NPARAMS
*
NPARAMS
];
for
(
int
i
=
0
;
i
<
length
;
i
++
){
for
(
int
j
=
0
;
j
<
length
;
j
++
){
C
[
i
*
length
+
j
]
=
A
[
i
*
length
+
j
];
}
}
bool
d
=
true
;
int
indx
[
NPARAMS
];
double
*
akk
=
C
;
double
big
=
fabs
(
*
akk
);
int
mu
=
0
;
double
*
ai
=
akk
;
int
k
;
for
(
k
=
1
;
k
<
length
;
k
++
){
ai
+=
length
;
const
double
trybig
=
fabs
(
*
ai
);
if
(
big
<
trybig
){
big
=
trybig
;
mu
=
k
;
}
}
if
(
length
)
for
(
k
=
0
;;){
indx
[
k
]
=
mu
;
if
(
mu
!=
k
){
double
*
a1
=
C
+
length
*
k
;
double
*
a2
=
C
+
length
*
mu
;
d
=
!
d
;
int
j
=
length
;
while
(
j
--
){
const
double
temp
=
*
a1
;
*
a1
++
=
*
a2
;
*
a2
++
=
temp
;
}
}
double
diag
=
*
akk
;
big
=
0
;
mu
=
k
+
1
;
if
(
diag
!=
0
){
ai
=
akk
;
int
i
=
length
-
k
-
1
;
while
(
i
--
){
ai
+=
length
;
double
*
al
=
ai
;
double
mult
=
*
al
/
diag
;
*
al
=
mult
;
int
l
=
length
-
k
-
1
;
double
*
aj
=
akk
;
if
(
l
--
!=
0
){
double
aux
=
al
[
1
]
-
(
mult
*
*
(
++
aj
));
*
(
++
al
)
=
aux
;
//*(++al) = __dadd_rn (*al,-mult* *(++aj)); //FAIL in cuda 4.2 compiler
const
double
trybig
=
fabs
(
*
al
);
if
(
big
<
trybig
){
big
=
trybig
;
mu
=
length
-
i
-
1
;
}
while
(
l
--
){
double
aux
=
al
[
1
]
-
(
mult
*
*
(
++
aj
));
*
(
++
al
)
=
aux
;
//*(++al) = __dadd_rn (*al,-mult* *(++aj)); //FAIL in cuda 4.2 compiler
}
}
}
}
if
(
++
k
==
length
)
break
;
akk
+=
length
+
1
;
}
//////////////////////////////
double
el
[
NPARAMS
];
for
(
int
e
=
0
;
e
<
length
;
e
++
){
el
[
e
]
=
P
[
e
];
}
int
j
;
int
ii
=
length
;
int
ip
;
double
temp
;
int
i
;
for
(
i
=
0
;
i
<
length
;
i
++
){
ip
=
indx
[
i
];
temp
=
el
[
ip
];
el
[
ip
]
=
el
[
i
];
el
[
i
]
=
temp
;
if
(
temp
!=
0.0
)
{
ii
=
i
;
break
;
}
}
double
*
bi
;
double
*
ai2
;
i
=
ii
+
1
;
if
(
i
<
length
){
bi
=
el
+
ii
;
ai2
=
C
+
ii
+
i
*
length
;
for
(;;){
int
ip
=
indx
[
i
];
double
sum
=
el
[
ip
];
el
[
ip
]
=
el
[
i
];
double
*
aij
=
ai2
;
double
*
bj
=
bi
;
j
=
i
-
ii
;
while
(
j
--
){
sum
-=
*
aij
++*
*
bj
++
;
}
el
[
i
]
=
sum
;
if
(
++
i
==
length
)
break
;
ai2
+=
length
;
}
}
ai2
=
C
+
length
*
length
;
for
(
i
=
length
-
1
;
i
>=
0
;
i
--
){
double
*
bj
=
el
+
i
;
ai2
-=
length
;
double
*
ajx
=
ai2
+
i
;
double
sum
=
*
bj
;
double
diag
=
*
ajx
;
j
=
length
-
i
;
while
(
--
j
){
sum
-=
*
(
++
ajx
)
*
*
(
++
bj
);
}
el
[
i
]
=
sum
/
diag
;
}
for
(
int
e
=
0
;
e
<
length
;
e
++
){
B
[
e
]
=
el
[
e
];
}
}
//END SOLVER WITH LU MATRIX INVERSE
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