I was wondering whether there is a way to refer data from many different arrays to one array, but without copying it.
Example:
import numpy as np
a = np.array([2,3,4,5,6])
b = np.array([5,6,7,8])
c = np.ndarray([len(a)+len(b)])
offset = 0
c[offset:offset+len(a)] = a
offset += len(a)
c[offset:offset+len(b)] = b
However, in the example above, c
is a new array, so that if you modify some element of a
or b
, it is not modified in c
at all.
I would like that each index of c
(i.e. c[0]
, c[1]
, etc.) refer to each element of both a
and b
, but like a pointer, without making a deepcopy
of the data.
a
andb
from a previously definedc
, so with some previous planning you may get what you want. But not after the fact. – Witchera
andb
"by the self definition of my problem". Thanks – Ilan