<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri, sans-serif" size="2">
<div>Hello,</div>
<div> </div>
<div> I would like to ask if there’s any special setup for PTESc to solve an Ax=b problem where A is a rectangular matrix instead of a square matrix. For example, when my A matrix is 3*3, the problem can be solved properly. But when my A matrix is 4*3,
the error message is:</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>[0]PETSC ERROR: Arguments are incompatible!</div>
<div>[0]PETSC ERROR: Incompatible vector local lengths 4 != 3!</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>PS: I created the matrix in SeqAIJ format and I could view the matrix was constructed correctly by MatView.</div>
<div><font face="Times New Roman, serif"> </font></div>
<div> // determine number of nonzeros per row in the new matrix</div>
<div> PetscMalloc((n+1)*sizeof(PetscInt),&cnt);</div>
<div> for (i=0;i<n;i++) {</div>
<div> cnt[i]=irow[i+1]-irow[i];</div>
<div> }</div>
<div> MatCreateSeqAIJ(PETSC_COMM_SELF,n,m,0,cnt,&A);</div>
<div> MatSetOption(A,MAT_IGNORE_ZERO_ENTRIES,PETSC_TRUE);</div>
<div> // copy over the matrix entries from the inputs</div>
<div> for (i=0;i<n;i++) {</div>
<div> PetscMalloc(cnt[i]*sizeof(PetscInt),&col);</div>
<div> for (j=0;j<cnt[i];j++) {</div>
<div> col[j]=icol[irow[i]+j-1]-1;</div>
<div> }</div>
<div> MatSetValues(A,1,&i,cnt[i],col,&ival[irow[i]-1],INSERT_VALUES);</div>
<div> }</div>
<div> MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);</div>
<div> MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);</div>
<div> ierr=PetscPrintf(PETSC_COMM_WORLD,"Matrix A:\n");CHKERRQ(ierr);</div>
<div> MatView(A,PETSC_VIEWER_STDOUT_SELF);</div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> <font face="Calibri, sans-serif">I’m new to PETSc. </font><font face="Calibri, sans-serif">Sorry if</font><font face="Calibri, sans-serif"> my questions is </font><font face="Calibri, sans-serif">naïve to you</font><font face="Calibri, sans-serif">.</font><font face="Calibri, sans-serif">
But </font><font face="Calibri, sans-serif"> </font><font face="Calibri, sans-serif">a</font><font face="Calibri, sans-serif">ny comment is highly appreciated!</font></font></div>
<div><font face="Times New Roman, serif"> </font></div>
<div>Thanks,</div>
<div>Shuangshuang</div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> </font></div>
</font>
</body>
</html>