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

[Lang] Add any()/all() functions for Matrix, move casting ops to common_ops #1064

Merged
merged 8 commits into from
May 26, 2020

Conversation

KLozes
Copy link
Collaborator

@KLozes KLozes commented May 26, 2020

I added any()/all() functions to Matrix to check if any/all matrix entries are non-zero. It works on float and int types. They can be called in using builtin syntax or as a method of a matrix.

any(mat) or mat.any() 
all(mat) or mat.all()

I also moved ti_int and ti_float to common ops, which allows casting of matrices with

int(mat)
float(mat)

Related issue = #1050

[Click here for the format server]

@KLozes KLozes requested review from archibate and yuanming-hu May 26, 2020 19:22
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Could you please add all(A) and any(A) to the list here https://taichi.readthedocs.io/en/latest/matrix.html#matrices? Feel free to merge once that's documented.

Meanwhile, seeing the confusing negative integer representations, I feel like we really need support for boolean types (u1) now...

@KLozes
Copy link
Collaborator Author

KLozes commented May 26, 2020

Thanks! I agree the the negative integers were confusing and unexpected.

@KLozes KLozes merged commit 222bc72 into taichi-dev:master May 26, 2020
@KLozes KLozes deleted the any_all branch May 26, 2020 22:35
@yuanming-hu yuanming-hu mentioned this pull request May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants