hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.44k stars 310 forks source link

StdVisitor error with user-defined type #258

Closed DerryMellon closed 1 year ago

DerryMellon commented 1 year ago

I have defined a custom type that supports arithmetic operations by implementing the operator +, -, *, /. This ensures my type meets the supports_arithmetic requirement. However, I'm unsure how to define a global ::sqrt function specific to my type. Could you guide me on this?

hosseinmoein commented 1 year ago

This may give you some hints: https://stackoverflow.com/questions/33728107/extending-c-math-functions-to-non-fundamental-types

But I think your best option is to use the VarVisitor and then take the sqrt of the variance manually.

DerryMellon commented 1 year ago

I know ADL, but ADL is only valid for usage forms such as sqrt(x), which cannot be found using ::sqrt(x). StdVisitor is just an example. There are other visitors such as ZScoreVisitor. I don’t want to implement all similar functions by myself.

hosseinmoein commented 1 year ago

Another option I can think of is to implement the cast operator for double for your type

DerryMellon commented 1 year ago

I convert the data to double before putting it into the DataFrame now. thanks anyway