Can I initialize a constant row vector?
I have tried Constant((1,1)), and Expression(('1.','1.')). They both return a column vector. When I tried to transpose it, it gives an error that, transpose is only defined for the Matrix.
Thanks!
Can you give more details? E.g. code?
just normal setup.
from dolfin import * mesh = UnitSquareMesh(2,2) TFS = TensorFunctionSpace(mesh, 'CG', 1) F = Function(TFS) N = Constant((1.,1.)) N*F
this won't work
Is this what you're looking for? As you said, a transpose operation could only be done on a matrix.
from dolfin import * mesh = UnitSquareMesh(2,2) TFS = TensorFunctionSpace(mesh, 'CG', 1) F = Function(TFS) # as tensor K = as_tensor([\ [1.0, 0.0],\ [0.0, 1.0]\ ]) K.T K*F # as vector K = Constant((1.,1.)) dot(K, F)
thanks, chao!
it is not what I am looking for. I want to left multiply a row vector to a matrix. I have to initialize row vector first to achieve that.
But your answer inspired me to do the following. And it works!! The trick is to use as_vector
from dolfin import * mesh = UnitSquareMesh(2,2) TFS = TensorFunctionSpace(mesh, 'CG', 1) F = Function(TFS) # row vector N = as_vector([[1. , 1.]) N.shape() # output (1,2) NF = N*F NF.shape() # output (1,2)