<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p>Hello</p>
<p><br>
</p>
<p>I've noticed that doing a singular value decomposition of a real matrix appears to result in non-real singular vectors. This should not be the case - singular vectors of a real matrix must be real-valued.</p>
<p><br>
</p>
<p>In the example attached I read a matrix from a binary file (also attached), perform the SVD, and write singular vectors to an HDF5 file which I subsequently inspect using h5dump, revealing non-zero imaginary parts of vector elements as highlighted below:</p>
<blockquote>
<p></p>
<div>[pjool@svol mwes]$ h5dump -d U0_sample_svd -c "5,2" sample_svecs.h5 <br>
HDF5 "sample_svecs.h5" {<br>
DATASET "U0_sample_svd" {<br>
DATATYPE H5T_IEEE_F64LE<br>
DATASPACE SIMPLE { ( 882, 2 ) / ( 882, 2 ) }<br>
SUBSET {<br>
START ( 0, 0 );<br>
STRIDE ( 1, 1 );<br>
COUNT ( 5, 2 );<br>
BLOCK ( 1, 1 );<br>
DATA {<br>
(0,0): 0.0226108, <span style="color: rgb(255, 0, 0);">0.0299595</span><b></b>,<br>
(1,0): 0.035414, <span style="color: rgb(255, 0, 0);">0.0469237</span>,<br>
(2,0): 0.0276317, <span style="color: rgb(255, 0, 0);">0.0366122,</span><br>
(3,0): 0.0145344, <span style="color: rgb(255, 0, 0);">0.0192581</span>,<br>
(4,0): 0.0110376, <span style="color: rgb(255, 0, 0);">0.0146249</span><br>
}<br>
}<br>
ATTRIBUTE "complex" {<br>
DATATYPE H5T_STD_I32LE<br>
DATASPACE SCALAR<br>
DATA {<br>
(0): 1<br>
}<br>
}<br>
}<br>
}<br>
</div>
<p></p>
</blockquote>
<p>I also extract the imaginary part of the input matrix and print its norm to ensure that the matrix is indeed real.</p>
<p><br>
</p>
<p>I'm running v3.14, but I don't believe that alone should cause the issue, since it what I'm trying to do appears like a rather common and basic task.<br>
</p>
<p><br>
</p>
<p>What might be the reason behind this behavior, and what can be done to resolve it?</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><br>
</p>
<p>Med venlig hilsen / Best Regards</p>
<p><br>
</p>
<p>Peder Jørgensgaard Olesen</p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">PhD Student, Turbulence Research Lab</span></p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">Dept. of Mechanical Engineering</span></p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">Technical University of Denmark</span></p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">Niels Koppels Allé</span></p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">Bygning 403, Rum 105</span></p>
<p><span style="font-size:10pt; color:rgb(117,123,128)">DK-2800 Kgs. Lyngby</span></p>
</div>
</div>
</div>
</body>
</html>