# Help - matrix multiplication by number complex

**URL:** <https://community.freefem.org/t/help-matrix-multiplication-by-number-complex/1805>\
**Category:** General Discussion\
**Created:** [June 9, 2022, 9:54pm UTC](https://community.freefem.org/t/help-matrix-multiplication-by-number-complex/1805 "2022-06-09T21:54:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andressa](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@andressa](https://community.freefem.org/u/andressa)\
**Post date:** [June 9, 2022, 9:54pm UTC](https://community.freefem.org/t/help-matrix-multiplication-by-number-complex/1805/1 "2022-06-09T21:54:23Z")

</div>

Dear,

I’m working on a 3d mesh. I created a gradient function of the mass of Dirac (gdirac) and my force function would be the multiplication of gdirac by a complex value (moment). However, I can’t do this multiplication. Can anybody help me?

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
// Geometry import  
load “medit”  
include “cube.idp”

int[int] Nxyz = [10, 10, 10]; //discretization axis  
real [int, int] Bxyz = [[0., 1.], [0., 1.], [0., .1]]; //block dimensions  
int [int, int] Lxyz = [[1, 1], [2, 2], [2, 2]];

// Parameters

real E = 210;  
real nu = 0.29;  
real rho = 1;  
real omega = 12;  
real mu = E/(2\*(1+nu));  
real lamb = E_nu/((1+nu)_(1-2_nu));  
real coef = 2.0_(mu + lamb);  
complex beta = 0.4 + 0.6i;

// Assemble mesh

mesh3 Th = Cube(Nxyz, Bxyz, Lxyz); // Th → domain triangulation and mesh3 → FEM mesh in 3d

// The finite element space (Vh) defined over Th

fespace Vh(Th, [P1, P1, P1]);  
Vh [u1, u2, u3], [v1, v2, v3];

// The gradient of the Dirac mass

func matrix gdirac (real X, real Y,real Z, real Xc, real Yc, real Zc){  
real xs = (X-Xc), ys = (Y-Yc), zs = (Z-Zc);  
real dif = -(xs_xs + ys_ys+ zs_zs)/(2);  
real coef = 1.0/(2.0_pi);  
real gx = coef \* exp(dif)\*xs;  
real gy = coef \* exp(dif)\*ys;  
real gz = coef \* exp(dif)\*zs;  
matrix G=[[gx,gy,gz]];  
return G;  
}

complex moment=beta_coef;  
real xc=0.5, yc=0.5, zc=0.05;  
complex M = moment_gdirac (x,y,z, xc, yc, zc);
