How should I understand this: My 16G RAM machine can generate a matrix of size 10^12, which is 1000G, and then do assignment on its elements?
Below, I let N be 10^6 and can generate a matrix of size 10^12. I can then assign values to the matrix element as we usually do. But there will be a memory issue if I want to do an arithmetic operation (shown below).
In [103]: N=int(10**6)
In [104]: A=np.zeros((N,N))
In [105]: A
Out[105]:
array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]])
In [106]: A[0,0]=3.14
In [107]: A
Out[107]:
array([[3.14, 0. , 0. , ..., 0. , 0. , 0. ],
[0. , 0. , 0. , ..., 0. , 0. , 0. ],
[0. , 0. , 0. , ..., 0. , 0. , 0. ],
...,
[0. , 0. , 0. , ..., 0. , 0. , 0. ],
[0. , 0. , 0. , ..., 0. , 0. , 0. ],
[0. , 0. , 0. , ..., 0. , 0. , 0. ]])
In [108]: A = A+1
zsh: killed ipython