I would like to construct a PETScMatrix from a numpy.array and thus try something like
A, N = PETScMatrix(), 10
A.resize(N,N)
values = numpy.ones(2,dtype=numpy.float_)
rows = numpy.array([0],dtype=numpy.intc)
cols = numpy.array([1,2],dtype=numpy.intc)
A.set(values,rows,cols)
A.apply()
First question: how is resize used correctly?
Next, for a specific optimisation algorithm, the following expression B has to be evaluated
A, alpha = assemble(u*v*dx), 0.3
B = A*A-alpha*I
where I is the identity matrix. How can this be implemented?
Thanks for advice, Martin