pengowen123 / cmaes

A Rust implementation of the CMA-ES optimization algorithm.
Apache License 2.0
32 stars 5 forks source link

Support complex types? #1

Closed ethanhs closed 5 years ago

ethanhs commented 5 years ago

I have a requirement for using cma-es with Complex<f64> arrays. How hard do you think it would be to add support for this?

pengowen123 commented 5 years ago

Adding built-in support would complicate the API, so I would prefer such functionality to instead be constructed on top of the library.

Complex numbers are essentially two independent numbers, so you could simply double the number of dimensions and manually construct Complex<f64> out of adjacent elements in the parameter array. If this is a common enough use case, a helper function could be added to do this for you.