spirit-code / spirit

Atomistic Spin Simulation Framework
http://spirit-code.github.io
MIT License
117 stars 52 forks source link

Core API: replace float with scalar? #491

Open GPMueller opened 5 years ago

GPMueller commented 5 years ago

I believe the rationale behind using float was

However, several functions therefore return very imprecise values, even though they are known to higher precision in the core. The API should therefore return scalar values with the same precision as the core is working with.

This could be achieved by using the definition of scalar in the API, forcing the usage of float in the JS build and checking the precision in the Python API and using a c_scalar type, which is either ctypes.c_float or ctypes.c_double accordingly.

GPMueller commented 5 years ago

The main issue with using scalar for the API would be that even in cases where only the API has to use float (e.g. JS), the entire core library would have to use float. This could be avoided by using

#define SPIRIT_API_SCALAR float
typedef SPIRIT_API_SCALAR spirit_scalar;

in the API, while using the regular scalar inside the core library.

GPMueller commented 3 years ago

Note also the related issue #477