# Some questions about Matrix and Vectors

**URL:** <https://fenicsproject.discourse.group/t/some-questions-about-matrix-and-vectors/12385>\
**Category:** dolfinx\
**Created:** [October 5, 2023, 2:05pm UTC](https://fenicsproject.discourse.group/t/some-questions-about-matrix-and-vectors/12385 "2023-10-05T14:05:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [October 5, 2023, 2:05pm UTC](https://fenicsproject.discourse.group/t/some-questions-about-matrix-and-vectors/12385/1 "2023-10-05T14:05:14Z")

</div>

Hello, in DOLFINX, it seems like we users have more power on the matrix and vector of the linear system. But I’m confused about some lines of the codes in this demo [https://github.com/FEniCS/dolfinx/blob/v0.6.0/python/dolfinx/fem/petsc.py#L680](https://github.com/FEniCS/dolfinx/blob/v0.6.0/python/dolfinx/fem/petsc.py#L680)

![WX20231005-155304](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/8/83ae565227a7a7b29d91341b42a9b930d31b32b3.png)

1. It seems to me that from line 221-224, we have already assemble the matrix, then what the function fem::set\_diagonal actually does?
2. For the vectors, I suppose that we employ the function apply\_lifting() to apply the boundary condition, then what is the point to use the function set\_bc?

Thanks very much!

---

<div class="post-metadata">

**Author:** ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)\
**Post date:** [October 5, 2023, 3:16pm UTC](https://fenicsproject.discourse.group/t/some-questions-about-matrix-and-vectors/12385/2 "2023-10-05T15:16:54Z")

</div>

Refer to the DOLFINx [documentation](https://docs.fenicsproject.org/dolfinx/main/cpp/fem.html) and PETSc [documentation](https://petsc.org/main/manualpages/Mat/MatAssemblyBegin/).

---

<div class="post-metadata">

**Author:** ![WjjSteve](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/wjjsteve/32/4389_2.png) [@WjjSteve](https://fenicsproject.discourse.group/u/WjjSteve)\
**Post date:** [October 5, 2023, 4:45pm UTC](https://fenicsproject.discourse.group/t/some-questions-about-matrix-and-vectors/12385/3 "2023-10-05T16:45:50Z")

</div>

Thanks for replying.
