# What are the valid operations on an fespace?

**URL:** https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978
**Category:** General Discussion
**Created:** [February 20, 2024, 2:29am UTC](https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978 "2024-02-20T02:29:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![glenwheeler](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/glenwheeler/32/2113_2.png) [@glenwheeler](https://community.freefem.org/u/glenwheeler)
#### Post date: [February 20, 2024, 2:29am UTC](https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978/1 "2024-02-20T02:29:40Z")

</div>

Hi everyone!

I’m a total beginner at using FreeFEM++. I wanted to calculate the negative part of an fespace X by using

max(-X, 0.0);

but it didn’t work. Instead, I used a loop like this:

for(int i = 0; i \< Vh.ndof; ++i) {  
X[i] = max(-X[i], 0.0);  
}

which worked. I understand that max doesn’t apply to fespaces. But some operations do apply. I tried searching the documentation but I couldn’t find a list of what are valid operations. Can anyone help?

---

<div class="post-metadata">

### Author: ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)
#### Post date: [February 20, 2024, 4:33am UTC](https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978/2 "2024-02-20T04:33:25Z")

</div>

You can get max an min of the array of you degrees of freedom like this

> cout \<\< X.min\<\< " "\<\< X.max \<\<endl;

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [February 22, 2024, 9:13am UTC](https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978/3 "2024-02-22T09:13:01Z")

</div>

first X is not a fespace but a function in fespace.

if you call Vh the fespace, then X is defined by  
Vh X;  
then  
Vh X0 = max(-X,0.0); // work !

---

<div class="post-metadata">

### Author: ![glenwheeler](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/glenwheeler/32/2113_2.png) [@glenwheeler](https://community.freefem.org/u/glenwheeler)
#### Post date: [February 23, 2024, 1:37am UTC](https://community.freefem.org/t/what-are-the-valid-operations-on-an-fespace/2978/4 "2024-02-23T01:37:16Z")

</div>

Hi Frederic,

Yes, of course, the code looks like

fespace Vh(Th, P1);  
Vh X;

OH I see, so

X = max(-X,0);

does not work, but

X0 = max(-X,0);

does. I just wanted to replace X, but I need an intermediate point.

So “max” is a valid operation. Great! Do you know where the others are listed…?
