I use two arrays of the same size like :

```
>>> a = [range(10)]
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> b = -a
>>> b
array([ 0, -1, -2, -3, -4, -5, -6, -7, -8, -9])

```

I want to create another array using a boolean "mask", for example :

```
>>> m = (a % 2 == 0)
>>> m
array([ True, False,  True, False,  True, False,  True, False,  True, False], dtype=bool)

```

Then I create a third array of the same size and change its values for the ones of a if m is True and for the ones of b if m is False :

```
>>> c = ones(10)
>>> c[m] = a[m]
>>> c[~m] = b[~m]
>>> c
array([ 0., -1.,  2., -3.,  4., -5.,  6., -7.,  8., -9.])

```

I wonder if there is a way to do the three last operations (the creation of c) within just one operation (especially for performance optimisation).

The problem of doing :

> 
> 
> > 
> > 
> > > 
> > > c = a \* m + b \* m
> > > 
> > > 
> > > 
> > 
> > 
> > 
> 
> 
> 

is when there are NaN in a or b, when it is multiplied by zero it still makes NaN.

PS : The example I gave would also work for n-dimensionnal arrays.