# Rectangular Mat directly from varf

**URL:** https://community.freefem.org/t/rectangular-mat-directly-from-varf/1344
**Category:** General Discussion
**Created:** [November 22, 2021, 9:21am UTC](https://community.freefem.org/t/rectangular-mat-directly-from-varf/1344 "2021-11-22T09:21:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [November 22, 2021, 9:21am UTC](https://community.freefem.org/t/rectangular-mat-directly-from-varf/1344/1 "2021-11-22T09:21:01Z")

</div>

Dear FreeFem users,

I am trying to assemble a system from block matrices. Generally, one can create a `Mat` object and assign a value to it directly using the `varf` keyword. However, it does not seem to work for rectangular matrices. This can be demonstated by modifying the [stokes-2d-SLEPc.edp](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/stokes-2d-SLEPc.edp#L45-L46) example, because changing lines

```auto
matrix BLoc = vPbB(VhP, VhV);
B = BLoc; 

```

to

```auto
B = vPbB(VhP, VhV); 

```

results in a PETSc error. I got this result both using the recently published 4.10 version, and also by using a recent compilation of the develop branch. Is this a bug, or is there a reason why this does not work?

---

<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: [November 22, 2021, 12:53pm UTC](https://community.freefem.org/t/rectangular-mat-directly-from-varf/1344/2 "2021-11-22T12:53:25Z")

</div>

Thanks for the report. This should be fixed in [Fixes segmentation fault reported by @aszaboa · FreeFem/FreeFem-sources@fd0971d · GitHub](https://github.com/FreeFem/FreeFem-sources/commit/fd0971d2017a5a1c6b9fa0eb59f3808b447cd6c6). Please let me know if this doesn’t work out on your end.

---

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [November 22, 2021, 3:29pm UTC](https://community.freefem.org/t/rectangular-mat-directly-from-varf/1344/3 "2021-11-22T15:29:46Z")

</div>

Thanks, I just tested it and the fix works perfectly!
