You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a = af.range(10) + 99
#b = afn.array(a) # a is copied to b
b = ndarray_(a) # a is linked to b
c = b.d_array
c[0] = af.log(c[0])
print(a)
print(b) # b is linked to c
print(c)
b *= 2
print(a)
print(b) # b is linked to c
print(c)
c[:] += 123
print(a)
print(b) # b is linked to c
print(c)
c += 123
print(a)
print(b) # b is linked to c
print(c)
The text was updated successfully, but these errors were encountered:
assume arrayfire array a is linked to asnumpy array b
and c = b.d_array
b*=2 will modify c
c+=123 will not modify b
but
c[:] += 123 will modify b
for details, you could refer to the code below.
import arrayfire as af
import afnumpy as afn
def ndarray_(s):
return afn.ndarray(s.shape, dtype=afn.pu.typemap(s.dtype()), af_array=s)
a = af.range(10) + 99
#b = afn.array(a) # a is copied to b
b = ndarray_(a) # a is linked to b
c = b.d_array
c[0] = af.log(c[0])
print(a)
print(b) # b is linked to c
print(c)
b *= 2
print(a)
print(b) # b is linked to c
print(c)
c[:] += 123
print(a)
print(b) # b is linked to c
print(c)
c += 123
print(a)
print(b) # b is linked to c
print(c)
The text was updated successfully, but these errors were encountered: