import numpy as np
a=np.arange(12).reshape(3,4)print(a)print("\n")for x in np.nditer(a):print(x,end=", ")print("")
import numpy as np
a=np.arange(12).reshape(3,4)print(a)print("\n")for x in np.nditer(a):print(x,end=", ")print("\n")print(a.T,"\n")for x in np.nditer(a.T):print(x,end=", ")print("\n")
b = a.T.copy(order ="C")print(b)print("\n")for i in np.nditer(b,order ="C"):print(i,end=", ")print("\n")for i in np.nditer(b,order ="F"):print(i,end=", ")print("\n")
b = a.T.copy(order ="C")print(b)print("\n")for i in np.nditer(b,order ="C",op_flags =["readwrite"]):
i*=2print(b)for i in np.nditer(a,order ="F",op_flags =["readwrite"]):
i[...]=i*2print("\n",b)
import numpy as np
arr = np.arange(12).reshape(4,3)print(arr,"\n")for x in np.nditer(arr,flags =["external_loop"],order ="F"):print(x,end=", ")print("\n")for x in np.nditer(arr,flags =["external_loop"]):print(x,end=", ")print("\n")for x in np.nditer(arr,flags =["f_index"]):print(x,end=", ")print("\n")for x in np.nditer(arr,flags =["c_index"]):print(x,end=", ")print("\n")