- Thank you received: 0
Going to Scipy/numpy error message
3 years 5 months ago #3798
by ajf367
Going to Scipy/numpy error message was created by ajf367
Hello,
I have a matrix defined on a mesh as given below.
I want to make it into a larger system by placing my matrix a into a block matrix
My attempt is
however this results in the following error message:
blocks[0,:] has incompatible row dimensions. Got blocks[0,1].shape[0] == 358240, expected 1.
How to I get around this error
I have a matrix defined on a mesh as given below.
I want to make it into a larger system by placing my matrix a into a block matrix
My attempt is
Code:
a = BilinearForm(fes)
a += grad(u)*grad(v)*dx
length = a.mat.height
Z = sp.coo_matrix((length, length))
I = sp.identity(length)
B1a = sp.hstack([a.mat, Z])
B1b = sp.hstack([Z, I])
B1 = sp.vstack([B1a, B1b])
blocks[0,:] has incompatible row dimensions. Got blocks[0,1].shape[0] == 358240, expected 1.
How to I get around this error
3 years 5 months ago #3832
by ddrake
Replied by ddrake on topic Going to Scipy/numpy error message
In the code snippet you posted, it looks like you may not have assembled the BilinearForm before acessing its matrix property.
Also, the NGSolve sparse matrix can't be used directly in scipy sparse like this
You might want to take a look at this: docu.ngsolve.org/latest/how_to/howto_numpy.html
Best,
Dow
Code:
a = BilinearForm(fes)
a += grad(u)*grad(v)*dx
a.Assemble() # <-- need to do this before accessing the matrix
length = a.mat.height
Also, the NGSolve sparse matrix can't be used directly in scipy sparse like this
Code:
B1a = sp.hstack([a.mat, Z])
You might want to take a look at this: docu.ngsolve.org/latest/how_to/howto_numpy.html
Best,
Dow
Time to create page: 0.095 seconds