<div dir="ltr"><div><div>Apologies for the error on my part. <br><br></div>Does the vector binary format also work the same way : VEC_FILE_CLASSID (32 bit int), num_elements (32 bit int) , value of the elements in double (num_elements*64 bit double) ?<br><br></div>Are the doubles stored in IEEE_754 format ?<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 1:43 PM Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
You saved a Vec to the file, not a Mat.<br>
<br>
<br>
<br>
> On Dec 3, 2018, at 1:38 PM, Sajid Ali via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I ran ex10 from /vec/examples/tutorials and saved the matrix in binary format.<br>
><br>
> Looking at the matrix in binary using xxd, I see<br>
><br>
> [sajid@xrm temp]$ xxd -b vector.dat<br>
> 0000000: 00000000 00010010 01111011 01001110 00000000 00000000 ..{N..<br>
> 0000006: 00000000 00010100 00000000 00000000 00000000 00000000 ......<br>
> 000000c: 00000000 00000000 00000000 00000000 00111111 11110000 ....?.<br>
> 0000012: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000018: 01000000 00000000 00000000 00000000 00000000 00000000 @.....<br>
> 000001e: 00000000 00000000 01000000 00001000 00000000 00000000 ..@...<br>
> 0000024: 00000000 00000000 00000000 00000000 01000000 00010000 ....@.<br>
> 000002a: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000030: 01000000 00010100 00000000 00000000 00000000 00000000 @.....<br>
> 0000036: 00000000 00000000 01000000 00011000 00000000 00000000 ..@...<br>
> 000003c: 00000000 00000000 00000000 00000000 01000000 00011100 ....@.<br>
> 0000042: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000048: 01000000 00100000 00000000 00000000 00000000 00000000 @ ....<br>
> 000004e: 00000000 00000000 01000000 00100010 00000000 00000000 ..@"..<br>
> 0000054: 00000000 00000000 00000000 00000000 01000000 00100100 ....@$<br>
> 000005a: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000060: 01000000 00100110 00000000 00000000 00000000 00000000 @&....<br>
> 0000066: 00000000 00000000 01000000 00101000 00000000 00000000 ..@(..<br>
> 000006c: 00000000 00000000 00000000 00000000 01000000 00101010 ....@*<br>
> 0000072: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000078: 01000000 00101100 00000000 00000000 00000000 00000000 @,....<br>
> 000007e: 00000000 00000000 01000000 00101110 00000000 00000000 ..@...<br>
> 0000084: 00000000 00000000 00000000 00000000 01000000 00110000 ....@0<br>
> 000008a: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
> 0000090: 01000000 00110001 00000000 00000000 00000000 00000000 @1....<br>
> 0000096: 00000000 00000000 01000000 00110010 00000000 00000000 ..@2..<br>
> 000009c: 00000000 00000000 00000000 00000000 01000000 00110011 ....@3<br>
> 00000a2: 00000000 00000000 00000000 00000000 00000000 00000000 ......<br>
><br>
><br>
> The format of the binary file is supposed to be<br>
> MAT_FILE_CLASSID, num_rows, num_cols, -1 followed by data.<br>
><br>
> Converting the first 4 bytes (32 bits) of binary to int, the number<br>
> 00000000000100100111101101001110 becomes 1211214, but the value of MAT_FILE_CLASSID according to the header file petscmat.h is 1211216 (<a href="mailto:petsc@3.10.2.1" target="_blank">petsc@3.10.2.1</a> built without complex support). What causes this discrepancy ?<br>
><br>
> Also, what are the special characters at the end of every line ? Am i not reading the binary file correctly ?<br>
><br>
><br>
> Thank You,<br>
> Sajid Ali<br>
> Applied Physics<br>
> Northwestern University<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-size:12.8px">Sajid Ali<br></div><div style="font-size:12.8px">Applied Physics<br></div><div style="font-size:12.8px">Northwestern University</div></div></div>