Skip to main content
added 136 characters in body; edited tags
Source Link
Anton Menshov
  • 8.7k
  • 7
  • 41
  • 94

I have just started with PETSc hence it might seem like a very stupid question but I couldn't find any answer in manual. After Calling KSPSolve, where can I access the soluition for my linear system? Example for a matrix:

|2 -1 0 | |x|   |1|
|-1 2 -1| |y| = |0|
|0 -1 2 | |z|   |1|

$$ \left(\begin{array}{ccc} 2 &-1 & 0\\ -1 &2&-1\\ 0&-1&2 \end{array}\right) \left(\begin{array}{c} x\\y\\z \end{array}\right)= \left(\begin{array}{c} 1\\0\\1 \end{array}\right) $$

I want to get vector [3/4, 1/2, 1/4] back $$ \left(\begin{array}{c} 3/4\\1/2\\1/4 \end{array}\right) $$ back. The The documentation for KSP Solve says x - the solution (this may be the same vector as b, then b will be overwritten with answer)

but I keep getting xx vector as [1,1,1]. $$ \left(\begin{array}{c} 1\\1\\1 \end{array}\right) $$

Is there something wrong in my understanding?

Sorry for really poor formatting I could not find latex editor here || denotes the matrix.

I have just started with PETSc hence it might seem like a very stupid question but I couldn't find any answer in manual. After Calling KSPSolve, where can I access the soluition for my linear system? Example for a matrix:

|2 -1 0 | |x|   |1|
|-1 2 -1| |y| = |0|
|0 -1 2 | |z|   |1|

I want to get vector [3/4, 1/2, 1/4] back. The documentation for KSP Solve says x - the solution (this may be the same vector as b, then b will be overwritten with answer)

but I keep getting x vector as [1,1,1]. Is there something wrong in my understanding?

Sorry for really poor formatting I could not find latex editor here || denotes the matrix.

I have just started with PETSc hence it might seem like a very stupid question but I couldn't find any answer in manual. After Calling KSPSolve, where can I access the soluition for my linear system? Example for a matrix:

$$ \left(\begin{array}{ccc} 2 &-1 & 0\\ -1 &2&-1\\ 0&-1&2 \end{array}\right) \left(\begin{array}{c} x\\y\\z \end{array}\right)= \left(\begin{array}{c} 1\\0\\1 \end{array}\right) $$

I want to get vector $$ \left(\begin{array}{c} 3/4\\1/2\\1/4 \end{array}\right) $$ back. The documentation for KSP Solve says x - the solution (this may be the same vector as b, then b will be overwritten with answer)

but I keep getting x vector as $$ \left(\begin{array}{c} 1\\1\\1 \end{array}\right) $$

Is there something wrong in my understanding?

Source Link
ipcamit
  • 135
  • 4

How to access solution to linear system in PETSc?

I have just started with PETSc hence it might seem like a very stupid question but I couldn't find any answer in manual. After Calling KSPSolve, where can I access the soluition for my linear system? Example for a matrix:

|2 -1 0 | |x|   |1|
|-1 2 -1| |y| = |0|
|0 -1 2 | |z|   |1|

I want to get vector [3/4, 1/2, 1/4] back. The documentation for KSP Solve says x - the solution (this may be the same vector as b, then b will be overwritten with answer)

but I keep getting x vector as [1,1,1]. Is there something wrong in my understanding?

Sorry for really poor formatting I could not find latex editor here || denotes the matrix.