Skip to content

Commit fc5c22c

Browse files
committed
Add basic user contributed Cython function as an example.
1 parent 4d0134d commit fc5c22c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fidimag/user/example.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from libc.math cimport sin, M_PI
2+
import numpy as np
3+
cimport numpy as np
4+
5+
6+
7+
def fast_sin_init(mesh, double[:] field, *params):
8+
t, axis, Bmax, fc = params
9+
for i in range(mesh.n):
10+
field[3*i+0] = Bmax * axis[0] * sin(fc*t)
11+
field[3*i+1] = Bmax * axis[1] * sin(fc*t)
12+
field[3*i+2] = Bmax * axis[2] * sin(fc*t)

0 commit comments

Comments
 (0)