VectorSpaceBasis
is just a container for GenericVector
s. I'd recommend using petsc4py
to manipulate these and create matrix; refer to PETSc/petsc4py documentation, please.
# Get petsc4py.PETSc.Vec objects
M = vector_space_basis.dim()
vecs = [vector_space_basis._sub(i).vec() for i in range(M)]
# Do some petsc4py manipulation with vecs and obtain PETSc.Mat object
from petsc4py import PETSc
...
mat = PETSc.Mat()
...
# Wrap PETSc.Mat as PETScMatrix
basis_matrix = PETScMatrix(mat)