<div dir="ltr"><div dir="ltr">On Tue, Jun 20, 2023 at 1:43 PM Diego Magela Lemos <<a href="mailto:diegomagela@usp.br">diegomagela@usp.br</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Using all recommended approaches it worked!<div>Thank you all in advance.</div><div><br></div><div>Now, I'm facing problems when solving a linear system using each approach.<div><br></div><div><b><u>COO approach</u></b></div></div></div></div></blockquote><div><br></div><div>I can answer this one.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><div>Using <font face="monospace">MatSetPreallocationCOO</font> and then <font face="monospace">MatSetValuesCOO</font>, I'm able to fill in the matrix when running with 1 MPI process. </div><div>But, if I run with more than one MPI process, the values entries are multiplied by the number of MPI processes being used. </div><div>Is this behavior correct?<br><br></div><div>Consider the following code:</div></div><div><br></div><div><font face="monospace">// fill_in_matrix.cc</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">static char help[] = "Fill in a parallel COO format sparse matrix.";<br><br>#include <petsc.h><br>#include <vector><br><br>int main(int argc, char **args)<br>{<br>    std::vector<PetscInt> coo_i{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscInt> coo_j{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscScalar> coo_v{2, -1, 2, 3, 4, 5};<br><br>    Mat A;<br><br>    PetscInt size = 5;<br><br>    PetscCall(PetscInitialize(&argc, &args, NULL, help));<br><br>    // Create matrix<br>    PetscCall(MatCreate(PETSC_COMM_WORLD, &A));<br>    PetscCall(MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, size, size));<br>    PetscCall(MatSetFromOptions(A));<br><br>    // Populate matrix<br>    PetscCall(MatSetPreallocationCOO(A, coo_v.size(), coo_i.data(), coo_j.data()));<br>    PetscCall(MatSetValuesCOO(A, coo_v.data(), ADD_VALUES));<br>    <br>    // View matrix<br>    PetscCall(MatView(A, PETSC_VIEWER_STDERR_WORLD));<br><br>    PetscCall(MatDestroy(&A));<br><br>    PetscCall(PetscFinalize());<br>    return 0;<br>}</font></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">When running with </font><font face="monospace">petscmpiexec -n 1 ./fill_in_matrix</font>, I got</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">Mat Object: 1 MPI process<br></font><font face="monospace">  type: seqaij<br></font><font face="monospace">row 0: (0, 1.)<br> </font><font face="monospace">row 1: (1, 2.)<br> </font><font face="monospace">row 2: (2, 3.)<br> </font><font face="monospace">row 3: (3, 4.)<br> </font><font face="monospace">row 4: (4, 5.) </font></blockquote><div><br></div><div>Which is a correct result. But, when running it with petscmpiexec -n 2 ./fill_in_matrix, I get</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">Mat Object: 2 MPI process<br></font><font face="monospace">  type: mpiaij<br></font><font face="monospace">row 0: (0, 2.)<br> </font><font face="monospace">row 1: (1, 4.)<br> </font><font face="monospace">row 2: (2, 6.)<br> </font><font face="monospace">row 3: (3, 8.)<br> </font><font face="monospace">row 4: (4, 10.)  </font></blockquote><div><br></div><div>The matrix entries are multiplied by 2, that is, the number of processes used to execute the code.</div></div></div></div></blockquote><div><br></div><div>No. This was mostly intended for GPUs, where there is 1 process. If you want to use multiple MPI processes, then each process can only introduce some disjoint subset of the values. This is also how MatSetValues() works, but it might not be as obvious.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><b><u>MatSetValues approach</u></b><br></div><div><b><u><br></u></b></div><div>I obtain the same behavior when filling in the matrix by using MatSetValues</div><div><br></div><div>static char help[] = "Fill in a parallel COO format sparse matrix.";<br><br><font face="monospace">// fill_in_matrix.cc<br><br>#include <petsc.h><br>#include <vector><br><br>int main(int argc, char **args)<br>{<br>    std::vector<PetscInt> coo_i{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscInt> coo_j{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscScalar> coo_v{2, -1, 2, 3, 4, 5};<br><br>    Mat A;<br>    PetscInt size = 5;<br><br>    PetscCall(PetscInitialize(&argc, &args, NULL, help));<br><br>    // Create matrix<br>    PetscCall(MatCreate(PETSC_COMM_WORLD, &A));<br>    PetscCall(MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, size, size));<br>    PetscCall(MatSetFromOptions(A));<br><br>    // Populate matrix<br>    for (size_t i = 0; i < coo_v.size(); i++)<br>        PetscCall(MatSetValues(A, 1, &<a href="http://coo_i.at" target="_blank">coo_i.at</a>(i), 1, &<a href="http://coo_j.at" target="_blank">coo_j.at</a>(i), &<a href="http://coo_v.at" target="_blank">coo_v.at</a>(i), ADD_VALUES));<br><br>    PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY));<br>    PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY));<br><br>    // View matrix<br>    PetscCall(MatView(A, PETSC_VIEWER_STDERR_WORLD));<br><br>    PetscCall(MatDestroy(&A));<br><br>    PetscCall(PetscFinalize());<br>    return 0;<br>}</font><br></div><div><br></div><div>When solving a linear system, I get the correct answer no matter the number of MPI processes when using <font face="monospace">MatSetValues</font> approach.</div><div>The same is not true when using <font face="monospace">COO</font> approach, whose result is only correct when using 1 MPI process.</div><div><br></div><font face="monospace">static char help[] = "Fill in a parallel COO format sparse matrix and solve a linear system.";<br><br>#include <petsc.h><br>#include <vector><br><br>int main(int argc, char **args)<br>{<br>    std::vector<PetscInt> coo_i{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscInt> coo_j{0, 0, 1, 2, 3, 4};<br>    std::vector<PetscScalar> coo_v{2, -1, 2, 3, 4, 5};<br><br>    Mat A;<br>    Vec B, X, U;<br>    KSP ksp;<br>    PC pc;<br>    PetscReal norm; // norm of solution error<br>    PetscInt its;<br><br>    PetscInt size = 5;<br><br>    PetscCall(PetscInitialize(&argc, &args, NULL, help));<br><br>    // Create matrix<br><br>    PetscCall(MatCreate(PETSC_COMM_WORLD, &A));<br>    PetscCall(MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, size, size));<br>    PetscCall(MatSetFromOptions(A));<br><br><br>    // Populate matrix<br><br>    // COO<br>    PetscCall(MatSetPreallocationCOO(A, coo_v.size(), coo_i.data(), coo_j.data()));<br>    PetscCall(MatSetValuesCOO(A, coo_v.data(), ADD_VALUES));<br><br>    // MatSetValues for-loop<br>    // for (size_t i = 0; i < coo_v.size(); i++)<br>    //     PetscCall(MatSetValues(A, 1, &<a href="http://coo_i.at" target="_blank">coo_i.at</a>(i), 1, &<a href="http://coo_j.at" target="_blank">coo_j.at</a>(i), &<a href="http://coo_v.at" target="_blank">coo_v.at</a>(i), ADD_VALUES));<br><br>    // PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY));<br>    // PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY));<br><br>    // View matrix<br>    PetscCall(MatView(A, PETSC_VIEWER_STDERR_WORLD));<br><br>    // Create vector B<br>    PetscCall(VecCreate(PETSC_COMM_WORLD, &B));<br>    PetscCall(VecSetSizes(B, PETSC_DECIDE, size));<br>    PetscCall(VecSetFromOptions(B));<br>    PetscCall(VecSetUp(B));<br><br>    // Populate vector<br>    PetscCall(VecSetValues(B, coo_i.size(), coo_i.data(), coo_v.data(), ADD_VALUES));<br>    PetscCall(VecAssemblyBegin(B));<br>    PetscCall(VecAssemblyEnd(B));<br><br>    // View vector<br>    PetscCall(VecView(B, PETSC_VIEWER_STDERR_WORLD));<br><br>    // Define solution and auxiliary vector<br>    PetscCall(VecDuplicate(B, &X));<br>    PetscCall(VecDuplicate(B, &U));<br>    PetscCall(VecSet(U, 1.0));<br><br>    // Create solver<br>    PetscCall(KSPCreate(PETSC_COMM_WORLD, &ksp));<br>    PetscCall(KSPSetOperators(ksp, A, A));<br>    PetscCall(KSPGetPC(ksp, &pc));<br>    PetscCall(PCSetType(pc, PCJACOBI));<br>    PetscCall(KSPSetFromOptions(ksp));<br>    PetscCall(KSPSetTolerances(ksp, 1.e-5, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT));<br><br>    // Solve<br>    PetscCall(KSPSolve(ksp, B, X));<br><br>    // View solution vector<br>    PetscCall(VecView(X, PETSC_VIEWER_STDERR_WORLD));<br><br>    // Verify the solution<br>    PetscCall(VecAXPY(X, -1.0, U));<br>    PetscCall(VecNorm(X, NORM_2, &norm));<br>    PetscCall(KSPGetIterationNumber(ksp, &its));<br>    PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Norm of error %g, Iterations %" PetscInt_FMT "\n", (double)norm, its));<br><br>    PetscCall(MatDestroy(&A));<br>    PetscCall(VecDestroy(&B));<br>    PetscCall(VecDestroy(&X));<br>    PetscCall(VecDestroy(&U));<br>    PetscCall(KSPDestroy(&ksp));<br><br>    PetscCall(PetscFinalize());<br>    return 0;<br></font><div><font face="monospace">}</font> </div><div><br></div><div>Why am I getting wrong results using the <font face="monospace">COO</font> approach with more than one MPI process?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Em ter., 20 de jun. de 2023 às 13:13, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div>  Since you have 6 entries that needed to be added to the matrix you will need to call MatSetValues() six time for the six entries.<br><div><br><blockquote type="cite"><div>On Jun 20, 2023, at 11:06 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr">On Tue, Jun 20, 2023 at 10:55 AM Diego Magela Lemos via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span style="color:rgb(35,38,41);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-size:15px">Considering, for instance, the following COO sparse matrix format, with repeated indices:</span><div><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit"><br></span></div><div><font face="monospace"><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">std::vector<</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">size_t</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">> rows{</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">};</span></font></div><div><font face="monospace"><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">std::vector<</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">size_t</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">> cols{</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">};</span></font></div><div><font face="monospace"><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">std::vector<</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">double</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">> values{</span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">-1</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">, </span><span style="background-color:transparent;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">5</span><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">};</span></font><div><br></div><div>that represents a 5x5 diagonal matrix A.</div><div><br></div><div>So far, the code that I have is:</div><div><br></div><div><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">// fill_in_matrix.cc</span>

<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">static</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">char</span> help[] = <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">"Fill in a parallel COO format sparse matrix."</span>;

<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">#<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">include</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit"><petsc.h></span></span>
<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">#<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">include</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit"><vector></span></span>

<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit"><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">int</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">main</span><span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">int</span> argc, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit">char</span> **args)</span>
</span>{
    Mat A;
    PetscInt m = <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">5</span>, i, Istart, Iend;

    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscInitialize</span>(&argc, &args, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">NULL</span>, help));

    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatCreate</span>(PETSC_COMM_WORLD, &A));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatSetSizes</span>(A, PETSC_DECIDE, PETSC_DECIDE, m, m));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatSetFromOptions</span>(A));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatSetUp</span>(A));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatGetOwnershipRange</span>(A, &Istart, &Iend));

    std::vector<PetscInt> II{<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span>};
    std::vector<PetscInt> JJ{<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span>};
    std::vector<PetscScalar> XX{<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">-1</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">5</span>};

    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">for</span> (i = Istart; i < Iend; i++)
        <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatSetValues</span>(A, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>, &II.<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">at</span>(i), <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>, &JJ.<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">at</span>(i), &XX.<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">at</span>(i), ADD_VALUES));

    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatAssemblyBegin</span>(A, MAT_FINAL_ASSEMBLY));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatAssemblyEnd</span>(A, MAT_FINAL_ASSEMBLY));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatView</span>(A, PETSC_VIEWER_STDERR_WORLD));

    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">MatDestroy</span>(&A));
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscCall</span>(<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">PetscFinalize</span>());
    <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">return</span> <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>;
}</code></pre></div><div><span style="color:rgb(35,38,41);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-size:15px">When running it with</span><br></div><div><span style="color:rgb(35,38,41);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-size:15px"><br></span></div><div><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">petscmpiexec -n <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span> ./fill_in_matrix</code></pre><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><br></code></pre><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><font face="arial, sans-serif"><span style="background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">I get</span><br></font></pre><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><br></code></pre></div><div> <span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit">Mat Object: </span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant:inherit;font-weight:inherit;white-space:inherit;margin:0px;padding:0px;border:0px;font-stretch:inherit;line-height:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span><span style="background-color:transparent;font-family:inherit;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit"> MPI processes</span></div><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">  type: mpiaij
row <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>: (<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">0</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1.</span>) 
row <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>: (<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">1</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2.</span>) 
row <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>: (<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">2</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3.</span>) 
row <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span>: (<span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">3</span>, <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4.</span>) 
row <span style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit">4</span>:</code></pre><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><br></code></pre><pre style="margin-top:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:inherit;font-kerning:inherit;font-feature-settings:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"><p style="margin:0px 0px 1.1em;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-kerning:inherit;font-feature-settings:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41);white-space:normal">Which is missing the entry of the last row.</p><div style="margin:0px;padding:0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-variant-alternates:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI Adjusted","Segoe UI","Liberation Sans",sans-serif;font-kerning:inherit;font-feature-settings:inherit;font-size:15px;vertical-align:baseline;box-sizing:inherit;clear:both;color:rgb(35,38,41);white-space:normal">What am I missing? Even better, which would be the best way to fill in this matrix?</div></code></pre></div></div>
</blockquote></div>We have a new interface for this:<div><br></div><div>  <a href="https://petsc.org/main/manualpages/Mat/MatSetValuesCOO/" target="_blank">https://petsc.org/main/manualpages/Mat/MatSetValuesCOO/</a></div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt<br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></blockquote></div>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>