2012/11/19 denis <[email protected]>:
> Folks,
> from a python function with args that may be float or double
> I want to call a corresponding C functions f_f32 or f_f64.
> Is there a better way than cython like
>
> cdef extern from "...":
> int f_f32( float* A, float* B )
> int f_f64( double* A, double* B )
> ...
>
> def func_float_or_double( np.ndarray A, np.ndarray B ):
> assert A.dtype is B.dtype
> if A.dtype.name == 'float32':
> return f_f32( A, B )
> elif A.dtype.name == 'float64':
> return f_f64( A, B )
> ...
Try calling ``f_f64`` with the data buffers of ``A`` and ``B``::
def func_float_or_double( np.ndarray A, np.ndarray B ):
assert A.dtype is B.dtype
if A.dtype.name == 'float32':
return f_f64(<np.float32_t*>(A.data), <np.float32_t*>(B.data))
elif A.dtype.name == 'float64':
return f_f64(<np.float64_t*>(A.data), <np.float64_t*>(B.data))
> (This may be more of a cython question, but you sklearn people must do this
> often ?)
>
> thanks,
> cheers
> -- denis
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
--
Peter Prettenhofer
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general