I want to add one element to a vector which is geting:
import time
from numpy import *
from scipy.sparse.linalg import bicgstab,splu
from scipy.sparse import lil_matrix,identity
from scipy.linalg import lu_factor,lu_solve,cho_factor,cho_solve
from matplotlib.pyplot import *
#N,alfa and beta are introduced
M = lil_matrix((2*N,2*N), dtype='float64')
b=zeros(2*N)
M.setdiag(alfa*ones(2*N),0)
M.setdiag(beta*ones(2*N-1),1)
M.setdiag(beta*ones(2*N-1),-1)
M.setdiag(ones(2*N-2),2)
M.setdiag(ones(2*N-2),-2)
M=M.tocsc()
for i in range(0,2*N):
b[i]=2*dx*feval(fuente,x[i])/6.0
A=1.0/(3.0*dx)*M
u=bicgstab(A,b)
usol=u[0]
And now I want usol.insert(0,1) usol=[1,usol[0],usol[1],..] but I have an error 'numpy.ndarray' object has no attribute 'insert'
usol = insert(usol, 0, 1)usol=np.concatenate(([1], usol)). That's all thatnp.insertdoes.