File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,9 @@ cdef extern from "c_energy.h":
272
272
273
273
double * A
274
274
275
+ # cdef extern from "c_energy.cpp":
276
+ # pass
277
+
275
278
# -----------------------------------------------------------------------------
276
279
# Python definitions
277
280
@@ -283,17 +286,18 @@ cdef extern from "c_energy.h":
283
286
# once upon creation and deletion of the Python instance.
284
287
285
288
cdef class PyExchangeEnergy:
286
- cdef ExchangeEnergy thisptr
289
+ cdef ExchangeEnergy * thisptr
287
290
# Try cinit:
288
- def __init__ (self , double [:] A ):
291
+ def __cinit__ (self , double [:] A ):
292
+ # self.thisptr = new ExchangeEnergy()
289
293
self .thisptr.init(& A[0 ])
290
- # cdef ExchangeEnergy *thisptr
294
+
291
295
# We could use another constructor if we use this method:
292
296
# def __cinit__(self):
293
- # if type(self) is PyEnergy :
294
- # self.thisptr = new Energy ()
297
+ # if type(self) is PyExchangeEnergy :
298
+ # self.thisptr = new ExchangeEnergy ()
295
299
# def __dealloc__(self):
296
- # if type(self) is PyEnergy :
300
+ # if type(self) is PyExchangeEnergy :
297
301
# del self.thisptr
298
302
# Necessary?
299
303
def compute_field (self , t ):
Original file line number Diff line number Diff line change 1
1
#include < cmath>
2
+ #include < iostream>
2
3
3
4
class Energy {
4
5
public:
@@ -23,8 +24,9 @@ class ExchangeEnergy : public Energy {
23
24
public:
24
25
ExchangeEnergy () {};
25
26
void init (double *A) {
26
- set_up = false ;
27
- this ->A = A;
27
+ std::cout << " Here A[0] = " << A[0 ] << " \n " ;
28
+ this ->set_up = false ;
29
+ // this->A = A;
28
30
}
29
31
double *A;
30
32
void compute_field (double t);
Original file line number Diff line number Diff line change
1
+ from fidimag .extensions .c_clib import PyExchangeEnergy
2
+ import numpy as np
3
+
4
+ A = np .ones (9 , dtype = np .double )
5
+ print (A )
6
+ Exch = PyExchangeEnergy (A )
You can’t perform that action at this time.
0 commit comments