Closed mforets closed 6 years ago
I am not sure about the @compat
issue, but I would remove the type annotations (for A
and the function) altogether. The reasons to have type annotations are either to help Julia to do type inference or to have different versions of the same function for different input types. Neither is necessary here. A
just has to support a set of operations (norm
, full
, ...) otherwise a MethodError
exception will be thrown (that is basically the idea of duck typing). Specialisation is handled automatically. There should be no difference in performance either.
thank you for the feedback. indeed, i was keeping the type annotation in padm
for performance, as hinted in the 2nd item in the Types Declarations docs.
a little benchmark with size(A) = (1000, 1000)
and p=0.001
gives me this:
no type annotation | type annotation | expm(full(A)) |
---|---|---|
129.873 ms | 134.829 ms | 398.629 ms |
Type annotation can only help for performance when used for a variable inside the function body that would otherwise not be inferred correctly (and thus dynamic / Any
); though in most cases you're better of trying to fix the type instability.
In most cases, function arguments are always specialized upon, i.e. a specific function is compiled for every different type of input arguments, and type annotation in function arguments is only useful to restrict that particular method definition to only act on those types.
Great! Can you maybe squash the commits?
yes. let me apply your reviews from today and squash. also, you guys are not writing the real name on julia docstrings, so for consistency i'll remove mine as well.
Done! i don't know what is the problem reported by Travis, but it seems it coudn't install julia 0.6
Thanks! I think the error is unrelated.
thanks for reviewing.
It seems that
@compat
is not working properly: the different ways of writingfunction padm(...)
are all valid in v0.6 . Any suggestion?