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
05393d34
Commit
05393d34
authored
16 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
added invert()
parent
ac4fb19e
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/GmshMatrix.cpp
+36
-0
36 additions, 0 deletions
Numeric/GmshMatrix.cpp
Numeric/GmshMatrix.h
+8
-0
8 additions, 0 deletions
Numeric/GmshMatrix.h
with
44 additions
and
0 deletions
Numeric/GmshMatrix.cpp
+
36
−
0
View file @
05393d34
...
...
@@ -99,6 +99,8 @@ extern "C" {
void
dgesv_
(
int
*
N
,
int
*
nrhs
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
double
*
b
,
int
*
ldb
,
int
*
info
);
void
dgetrf_
(
int
*
M
,
int
*
N
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
int
*
info
);
void
dgetri_
(
int
*
M
,
double
*
A
,
int
*
lda
,
int
*
ipiv
,
double
*
work
,
int
*
lwork
,
int
*
info
);
void
dgesvd_
(
const
char
*
jobu
,
const
char
*
jobvt
,
int
*
M
,
int
*
N
,
double
*
A
,
int
*
lda
,
double
*
S
,
double
*
U
,
int
*
ldu
,
double
*
VT
,
int
*
ldvt
,
double
*
work
,
int
*
lwork
,
int
*
info
);
...
...
@@ -120,6 +122,40 @@ bool gmshMatrix<double>::lu_solve(const gmshVector<double> &rhs, gmshVector<doub
return
false
;
}
template
<
>
bool
gmshMatrix
<
double
>::
invert
(
gmshMatrix
<
double
>
&
result
)
{
int
M
=
size1
(),
N
=
size2
(),
lda
=
size1
(),
info
;
int
*
ipiv
=
new
int
[
std
::
min
(
M
,
N
)];
bool
ret
=
true
;
result
=
*
this
;
dgetrf_
(
&
M
,
&
N
,
result
.
_data
,
&
lda
,
ipiv
,
&
info
);
if
(
info
==
0
){
int
lwork
=
M
*
4
;
double
*
work
=
new
double
[
lwork
];
dgetri_
(
&
M
,
result
.
_data
,
&
lda
,
ipiv
,
work
,
&
lwork
,
&
info
);
if
(
info
>
0
){
Msg
::
Error
(
"U(%d, %d)=0 in LU decomposition"
,
info
,
info
);
ret
=
false
;
}
else
if
(
info
<
0
){
Msg
::
Error
(
"Wrong %d-th argument in matrix inversion"
,
-
info
);
ret
=
false
;
}
delete
[]
work
;
}
else
if
(
info
>
0
){
Msg
::
Error
(
"U(%d, %d)=0 in LU decomposition"
,
info
,
info
);
ret
=
false
;
}
else
{
Msg
::
Error
(
"Wrong %d-th argument in matrix factorization"
,
-
info
);
ret
=
false
;
}
delete
[]
ipiv
;
return
ret
;
}
template
<
>
double
gmshMatrix
<
double
>::
determinant
()
const
{
...
...
This diff is collapsed.
Click to expand it.
Numeric/GmshMatrix.h
+
8
−
0
View file @
05393d34
...
...
@@ -173,6 +173,14 @@ class gmshMatrix
Msg
::
Error
(
"LU factorization requires LAPACK"
);
return
false
;
}
#endif
;
bool
invert
(
gmshMatrix
<
scalar
>
&
result
)
#if !defined(HAVE_LAPACK)
{
Msg
::
Error
(
"LU factorization requires LAPACK"
);
return
false
;
}
#endif
;
gmshMatrix
<
scalar
>
cofactor
(
int
i
,
int
j
)
const
...
...
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