Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.

**Stencil Implementation**

Hi,

I have a question regarding the Stencil implementation in the current homework. Taking the example that is provided in Solver.cpp:

Stencil ASten({ { 0, 1. } }, { { -1, 1. / hxSq },{ 0, -2. / hxSq },{ 1, 1. / hxSq } });

So here, the vector boundary_entries is initialized with {0,1} and the innerEntries vector is initialized with { { -1, 1. / hxSq },{ 0, -2. / hxSq },{ 1, 1. / hxSq } } ?

What does that mean for the resulting matrix then though? I assumed that the offset is always with respect to the diagonal. However, for the boundary Entries here, I only have one entry so I am not sure whether this specifies the first or the last row.

As a guess, would my matrix look like this?

[[1,0,…],

[1/hxSq, -2/hxSq,1/hxSq,…]

]

Thank you for your help and I apologize if I am missing something obvious here!

Hi,

in short:

the boundary stencil represents the first and the last row of the corresponding matrix, the inner stencil all other rows (as you assumed correctly, offsets are relative to the diagonal entry). The size is not specified at this point, but may be determined by usage, eg when multiplying with a vector.

The stencil from Solver.cpp corresponds to the matrix used as reference – if you print it, you will know how it looks like.

Best, Sebastian