Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mp++ types in armadillo (proof of concept) #207

Open
chatziko opened this issue Dec 4, 2019 · 5 comments
Open

Use mp++ types in armadillo (proof of concept) #207

chatziko opened this issue Dec 4, 2019 · 5 comments

Comments

@chatziko
Copy link

chatziko commented Dec 4, 2019

The following repo shows that armadillo can be monkey-patched to support mp++ types as elements (integer and rational, but others could be easily added).

https://github.com/chatziko/arma-mppp

A variety of basic operations are supported, and I'm sure others could be added.

Of course I wouldn't expect performance similar to BLAS, but using armadillo to do linear algebra with mp++'s exact arithmetic could be super useful. I'd love to see something like this included in mp++, I think it's a natural fit for armadillo!

@bluescarni
Copy link
Owner

Hi @chatziko, that is indeed a good suggestion. I would be willing to incorporate explicit support for armadillo's types directly within mp++, perhaps in the form of a header in the extra/ subdirectory.

I have never used armadillo myself however, so probably the best way to proceed would be if you could open a PR and then we could work on it together.

@chatziko
Copy link
Author

chatziko commented Dec 5, 2019

Ok, I'll try to open a PR when I find some time.

Quick question: one problem I found in supporting more armadillo operations is that it sometimes uses 0 as a default argument, assuming that its element type accepts it, like:

template<typename T>
void foo(T a = 0) {
	...
}

My understanding is that mp++ doesn't allow implicit conversions, so this will fail when T = int_t. Is that because they are error prone? Do you see any way to optionally/conditionally/... enable them or something?

@bluescarni
Copy link
Owner

Yes, disallowing implicit conversions was a conscious design decision from the very beginning. I find them complex to reason about and generally speaking I try not to rely on/use them in my code. It is unfortunate that initialization in the form T a = 0; is dependent upon the availability of implicit conversions, but there's nothing that can be done about it.

I don't see an easy way out of this situation, apart from some hacky preprocessor logic to shut off the explicit keyword in a few key places. The only sane option I can see at the moment is to change the armadillo source code to use void foo(T a = T(0)) instead, but I can see how this is a hard sell.

@chatziko
Copy link
Author

chatziko commented Dec 5, 2019

I made a PR to armadillo, let's see how this goes 😄

https://gitlab.com/conradsnicta/armadillo-code/merge_requests/93

@bluescarni
Copy link
Owner

Great, thanks! I'll follow the discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants