<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1487592671895_3132"><span id="yui_3_16_0_ym19_1_1487592671895_3181">Hello,</span></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">Some questions wrt complex number - I have compiled PETSc with complex data type, but having problems of setting/getting the values:</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">- MatView does not seem to print complex number ? </div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">- Does MATSEQAIJ support row major SetValues for complex number ? I have tested real number, it is ok. I can not get the right values with MatGetRow. Still troubleshooting if it is my program problem...</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">This is how I set the matrix:</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"> PetscComplex *buffer; // this is the column data buffer, malloc'ed</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"> // setting the values</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"> buffer [i] = double1 + double2 * PETSC_i;</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">Then call MatSetValues, passing buffer. </div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"> </div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">The program is ok for real numbers, btw.</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">I use a 5x5 matrix, when setting buffer for column 2, I can see these are the data passed to MatSetValues (row, col):</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3690">(0, 2) 1 + 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3691">(1, 2) 1 + 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3692">(3, 2) -1 + 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3693"><br id="yui_3_16_0_ym19_1_1487592671895_3694"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498">But MatGetRow return:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498">(0, 2) 1. + 1. i<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498">(1, 2) 0. + 1. i</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498">(3, 2) 1. + 0. i<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_3498"><br></div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr">(I have used MatRestoreRow after MatGetRow).</div><div id="yui_3_16_0_ym19_1_1487592671895_3132" dir="ltr"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4252">for ( i = 0; i < rows; i++ ) {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4254"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4255"> </span>MatGetRow ( Z, i, ¤t_doubles, &col_index, &complex_buffer );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4256"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4257"> </span>if ( current_doubles > 0 ) {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4258"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4259"> </span>for ( j = 0; j < current_doubles; j++ ) {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4260"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4261"> </span>PetscPrintf ( PETSC_COMM_WORLD, "(%d, %d) %g + %g i\n", i, col_index[j], PetscRealPart(complex_buffer[j]), PetscImaginaryPart (complex_buffer[j]) );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4262"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4263"> </span>}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4264"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4265"> </span>}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4266"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487592671895_4267"> </span>MatRestoreRow( Z, i, ¤t_doubles, &col_index, &complex_buffer );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4268">}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487592671895_4270"><br id="yui_3_16_0_ym19_1_1487592671895_4271"></div><div></div><div id="yui_3_16_0_ym19_1_1487592671895_3133"> </div><div class="signature" id="yui_3_16_0_ym19_1_1487592671895_3134">thanks !<br>LX</div></div></body></html>