# Can tgv be chosen different values for Mat and vector

**URL:** <https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913>\
**Category:** General Discussion\
**Created:** [May 13, 2025, 6:23am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913 "2025-05-13T06:23:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [May 13, 2025, 6:23am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/1 "2025-05-13T06:23:37Z")

</div>

Dear all,

I find the tgvs are chosen different values for Mat and vector in this code line 34 and 36  
[laplace-adapt-3d-PETSc.edp](https://community.freefem.org/uploads/short-url/zpHlR8LkgKsx9U5Nz5v1fRHtv3J.edp) (1.9 KB)

A = vPoisson(Vh, Vh, tgv = -2);  
set(A, sparams = “-ksp\_monitor -pc\_type hypre”);  
real[int] rhs = vPoisson(0, Vh, tgv = -1);

So I have the question as shown in the title, or it’s just a typo.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 13, 2025, 6:36am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/2 "2025-05-13T06:36:35Z")

</div>

Why would it matter? Have you understood the meaning of a negative value for `tgv`?

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [May 13, 2025, 6:47am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/3 "2025-05-13T06:47:39Z")

</div>

Thank for your quick reply. My understanding is that tgv = -2 for matrix means symmetric and tgv = -1 for matrix means nonsymmetric. But I am just confused that the tgvs for Matrix and vector can be chosen differently here.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 13, 2025, 7:40am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/4 "2025-05-13T07:40:07Z")

</div>

Sorry, I meant to ask you if you understood the meaning for the linear form.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [May 13, 2025, 8:00am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/5 "2025-05-13T08:00:19Z")

</div>

Yes, it’s the variational formulation of the Poisson equation with homogeneous boundary  
−∆u = 1, on Ω  
u = 0, on Γ

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 13, 2025, 8:06am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/6 "2025-05-13T08:06:22Z")

</div>

You are not answering my question. If you answer to the question: « what is the meaning of a negative tgv for the linear form? », you will have the answer for your initial question.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [May 13, 2025, 8:45am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/7 "2025-05-13T08:45:15Z")

</div>

Thank you very much for your precious time. I truly did’t understand the meaning of tgv for the linear form before. So I search in the tutorial to learn how to assemble matrix and vector with different value of tgvs. This code  
[tgv-test.edp](https://community.freefem.org/uploads/short-url/zGhgB5ZwYJkcaev1CtUabQ0aswF.edp) (1.1 KB)  
explains clearly.

varf va(u,v)= int1d(Th)(u_v_4\*9.)+on(1,2,u=0);// mul by 12 to have integer coef ..  
// label : 1 on first DoF O  
// 2 on last DoF 2  
// tgv : -30 set column of Dof with label 1 or 2 to zero  
// tgv : -20 set row and column of Dof with label 1 or 2 to zero  
// tgv : -10 set row of Dof with label 1 or 2 to zero  
// tgv : -3 set column of Dof with label 1 or 2 to zero and set diagonal term to one  
// tgv : -2 set row and column of Dof with label 1 or 2 to zero and set diagonal term to one  
// tgv : -1 set row of Dof with label 1 or 2 to zero and set diagonal term to one  
// tgv \>=0 set diagonal term of Dof with label 1 or 2 to tgv value

Thanks agian!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [May 13, 2025, 8:53am UTC](https://community.freefem.org/t/can-tgv-be-chosen-different-values-for-mat-and-vector/3913/8 "2025-05-13T08:53:07Z")

</div>

This example is almost exclusively about the bilinear part, but OK…
