# Unexpected array behaviour

**URL:** <https://community.freefem.org/t/unexpected-array-behaviour/1166>\
**Category:** General Discussion\
**Created:** [August 20, 2021, 8:45am UTC](https://community.freefem.org/t/unexpected-array-behaviour/1166 "2021-08-20T08:45:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![distractor](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@distractor](https://community.freefem.org/u/distractor)\
**Post date:** [August 20, 2021, 8:45am UTC](https://community.freefem.org/t/unexpected-array-behaviour/1166/1 "2021-08-20T08:45:49Z")

</div>

My mesh is defined as follows

```auto
int[int] Nxyz=[20,5,5];
real [int,int] Bxyz=[[0.,5.],[0.,1.],[0.,1.]];
int [int,int] Lxyz=[[1,2],[2,2],[2,2]];
mesh3 Th=Cube(Nxyz,Bxyz,Lxyz);

```

and my `fespace`

```auto
fespace Vh(Th,[P1,P1,P1]);
Vh [u1,u2,u3], [v1,v2,v3];

```

I then do some computations to obtain a vector of displacements **U**

```auto
Vh [uu1, uu2, uu3];
real[int] U(A.n);
U = A^-1*b;

```

before I finally try to get the x, y and z coordinates of the displacements

```auto
real[int] U1(A.m/3),U2(A.m/3),U3(A.m/3);

for(int e=0; e<A.m/3; e++){
U1(e) = U(3*e);
U2(e) = U(3*e+1);
U3(e) = U(3*e+2);
}
Vh [uu,vv,ww];
uu[] = U1;
vv[] = U2;
ww[] = U3;

```

# The issue.

The issue is that

```auto
real dmax= uu[].max;
cout << " max deplacement = " << dmax << endl;
cout << " max deplacement = " << U1.max << endl;

```

does not return the same result, which I would expect. So what exactly does `uu[] = U1` do? I guess not what I expected it to do.

The rest of the code is just a plot

```auto
real coef= 0.1/dmax;
int[int] ref2=[1,0,2,0];
mesh3 Thm=movemesh3(Th,transfo=[x+uu*coef,y+vv*coef,z+ww*coef],label=ref2);
Thm=change(Thm,label=ref2);
plot(Th,Thm, wait=1,cmm="coef amplification = "+coef );

```

Which obviously does not work since the computation of `dmax` is not correct.
