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

Best way to get min or max element, is tensor finite ? #90

Closed
ghost opened this issue May 25, 2020 · 5 comments
Closed

Best way to get min or max element, is tensor finite ? #90

ghost opened this issue May 25, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented May 25, 2020

Thank you for this excellent library, very useful and powerful. I'm working on a portage of old armadillo based project to fastor and need a little help (maybe a enhancement request) from you.

  1. I need to get the max absolute value of a tensor. The element-wise abs expression is already implemented, but I can't see equivalent for getting min or max in the same elegant way, something like:
    Tensor<double,2,3,4> a;
    double max_abs_value = max(abs(a));
  1. Fastor implement some compile time boolean operations like isuniform, how can I get runtime equivalent of isfinite over a tensor ?
    Tensor<double,2,3,4> a;
    bool ok = isfinite(a);

Sorry if it's not pertinent or if it's not the best place to ask help, let me known.
Thank you very much.
Max

@romeric
Copy link
Owner

romeric commented May 25, 2020

Thank you for submitting this issue. Yes, element-wise max/min and isfinite is not yet implemented. I will add these as soon as possible. Hopefully will be available later today or early tomorrow.

@romeric
Copy link
Owner

romeric commented May 26, 2020

min and max functions have now been implemented. You need the latest commit/clone of Fastor for this. So now you can do

Tensor<T,....> a;
T max_value = max(a);
T max_abs_value = max(abs(a));

The isfinite function will be available soon

@ghost
Copy link
Author

ghost commented May 26, 2020

Wonderfull, you make my day !

@ghost
Copy link
Author

ghost commented May 26, 2020

Roman, if you want to see why your work is so usefull, take a look at this issue : HSU-ANT/ACME.jl#28

Your library is incredible !!!

@romeric
Copy link
Owner

romeric commented May 26, 2020

That is absolutely awesome Maxime 👍! I am glad that you are finding a solid scientific application that you can use Fastor for.

People typically come and explore Fastor and when they realise that it is only for fixed sized arrays they leave it at that. So I am happy that your usecase is suited for this kind heavy compile time computations that Fastor is designed for.

On other news, I have now implemented isnan, isinf and isfinite for Fastor expressions with proper unittests. However note, similar to numpy and matlab these operations are element-wise.

Tensor<T,....> a;
Tensor<bool,....> result_array = isfinite(a);

If you want to know that all of the elements are finite you can do

bool ok = all_of(isfinite(a));

or use any_of or none_of depending on the use case. You need the latest clone of Fastor for this.

Please ask if you have any questions.

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

1 participant