Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
655458b4
Commit
655458b4
authored
11 years ago
by
Sebastien Blaise
Browse files
Options
Downloads
Patches
Plain Diff
Added LU factorization and substitution to fullMatrix
parent
4baacdf3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Numeric/fullMatrix.cpp
+25
-4
25 additions, 4 deletions
Numeric/fullMatrix.cpp
Numeric/fullMatrix.h
+16
-0
16 additions, 0 deletions
Numeric/fullMatrix.h
with
41 additions
and
4 deletions
Numeric/fullMatrix.cpp
+
25
−
4
View file @
655458b4
...
...
@@ -208,6 +208,8 @@ extern "C" {
void
F77NAME
(
dgesv
)(
int
*
N
,
int
*
nrhs
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
double
*
b
,
int
*
ldb
,
int
*
info
);
void
F77NAME
(
dgetrf
)(
int
*
M
,
int
*
N
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
int
*
info
);
void
F77NAME
(
dgetrs
)(
char
*
trans
,
int
*
N
,
int
*
nrhs
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
double
*
b
,
int
*
ldb
,
int
*
info
);
void
F77NAME
(
dgetri
)(
int
*
M
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
double
*
work
,
int
*
lwork
,
int
*
info
);
void
F77NAME
(
dgesvd
)(
const
char
*
jobu
,
const
char
*
jobvt
,
int
*
M
,
int
*
N
,
...
...
@@ -284,10 +286,29 @@ bool fullMatrix<double>::luSolve(const fullVector<double> &rhs, fullVector<doubl
F77NAME
(
dgesv
)(
&
N
,
&
nrhs
,
_data
,
&
lda
,
ipiv
,
result
.
_data
,
&
ldb
,
&
info
);
delete
[]
ipiv
;
if
(
info
==
0
)
return
true
;
// if(info > 0)
// Msg::Error("U(%d,%d)=0 in LU decomposition", info, info);
// else
// Msg::Error("Wrong %d-th argument in LU decomposition", -info);
return
false
;
}
template
<
>
bool
fullMatrix
<
double
>::
luFactor
()
{
int
M
=
size1
(),
N
=
size2
(),
lda
=
size1
(),
info
;
int
*
ipiv
=
new
int
[
std
::
min
(
M
,
N
)];
F77NAME
(
dgetrf
)(
&
M
,
&
N
,
_data
,
&
lda
,
ipiv
,
&
info
);
delete
[]
ipiv
;
if
(
info
==
0
)
return
true
;
return
false
;
}
template
<
>
bool
fullMatrix
<
double
>::
luSubstitute
(
const
fullVector
<
double
>
&
rhs
,
fullVector
<
double
>
&
result
)
{
int
N
=
size1
(),
nrhs
=
1
,
lda
=
N
,
ldb
=
N
,
info
;
int
*
ipiv
=
new
int
[
N
];
for
(
int
i
=
0
;
i
<
N
;
i
++
)
result
(
i
)
=
rhs
(
i
);
F77NAME
(
dgetrs
)(
"N"
,
&
N
,
&
nrhs
,
_data
,
&
lda
,
ipiv
,
result
.
_data
,
&
ldb
,
&
info
);
delete
[]
ipiv
;
if
(
info
==
0
)
return
true
;
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
Numeric/fullMatrix.h
+
16
−
0
View file @
655458b4
...
...
@@ -679,11 +679,27 @@ class fullMatrix
}
}
bool
luSolve
(
const
fullVector
<
scalar
>
&
rhs
,
fullVector
<
scalar
>
&
result
)
#if !defined(HAVE_LAPACK)
{
Msg
::
Error
(
"LU factorization and substitution requires LAPACK"
);
return
false
;
}
#endif
;
bool
luFactor
()
#if !defined(HAVE_LAPACK)
{
Msg
::
Error
(
"LU factorization requires LAPACK"
);
return
false
;
}
#endif
;
bool
luSubstitute
(
const
fullVector
<
double
>
&
rhs
,
fullVector
<
double
>
&
result
)
#if !defined(HAVE_LAPACK)
{
Msg
::
Error
(
"LU substitution requires LAPACK"
);
return
false
;
}
#endif
;
bool
invertInPlace
()
...
...
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