Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
153f847a
Commit
153f847a
authored
Mar 18, 2020
by
Kutalmış Berçin
Committed by
Andrew Heather
Jun 05, 2020
Browse files
BUG: fix pinv() for single-element input matrices
ENH: return zero-valued matrix when input zero-valued matrix in pinv()
parent
af221634
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/matrices/QRMatrix/QRMatrix.C
View file @
153f847a
...
...
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019
-2020
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -497,15 +497,17 @@ MatrixType Foam::pinv
{
typedef
typename
MatrixType
::
cmptType
cmptType
;
#if FULLDEBUG
if
(
A
.
empty
())
{
FatalErrorInFunction
<<
"Empty matrix."
<<
abort
(
FatalError
);
<<
"Empty matrix found."
<<
abort
(
FatalError
);
}
// Check if A is full-rank
#endif
if
(
A
.
size
()
==
1
)
{
return
MatrixType
({
1
,
1
},
cmptType
(
1
.
0
)
/
(
A
(
0
,
0
)
+
cmptType
(
VSMALL
)));
}
QRMatrix
<
MatrixType
>
QRM
(
...
...
@@ -534,9 +536,12 @@ MatrixType Foam::pinv
if
(
firstZeroElemi
==
0
)
{
FatalError
InFunction
Warning
InFunction
<<
"The largest (magnitude) diagonal element is (almost) zero."
<<
abort
(
FatalError
);
<<
nl
<<
"Returning a zero matrix."
<<
endl
;
return
MatrixType
(
A
.
sizes
(),
Zero
);
}
// Exclude the first (almost) zero diagonal row and the rows below
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment