-
| I would like to write Python bindings for the single, double, long double floating versions of fma. I started out with #include <cmath>
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
double fma_wrap(double x, double y, double z) {
  return fma(x, y, z);
}
float fmaf_wrap(float x, float y, float z) {
  return fmaf(x, y, z);
}
long double fmal_wrap(long double x, long double y, long double z) {
  return fmal(x, y, z);
}
PYBIND11_MODULE(_pyfma, m) {
  m.def("fma", py::vectorize(fma_wrap));
  m.def("fmaf", py::vectorize(fmaf_wrap));
  m.def("fmal", py::vectorize(fmal_wrap));
}but when using it from Python like out = fmaf(a, b, c)it will always return a np.float32 array, even if the input values  | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            nschloe
          
      
      
        Sep 6, 2021 
      
    
    Replies: 1 comment
-
| Ah,  | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
      Answer selected by
        nschloe
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Ah,
floatin C is float32 in Python.