-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
find should return linear indices #117
Comments
Unfortunately, this is not easy to implement, because matlab does things differently based on the number of output arguments. We can use a different name like find1, findn etc, but would be nice to hear from Jeff on how to do this. That said, Julia does have ind2sub and sub2ind, but I agree that find/ind2sub/sub2ind need to all work coherently. |
It seems like the simplest thing is for find to return linear indices, and you can use ind2sub if you need something else. |
In most cases when I use find, I don't want the linear indices! Guess its a matter of taste. |
This is yet another of those nargout cases. |
… to other containers. findn() is the version that returns N indexes. fixes issue #117
* 'master' of github.com:JuliaLang/julia: making find() return linear indexes; nice because it generalizes well to other containers. findn() is the version that returns N indexes. fixes issue #117 improving initial value for reductions of arrays, allowing them to work on cell arrays (unless empty of course) fix to N-d array show(); all slices need to be 2d clearing up (I hope) reduction operators: - sum and prod are just for reducing + and *. + and * already accept any number of arguments, so we don't need the confusion over whether sum(x,y) is the same as x+y. - let min and max take any number of arguments like + and *. - whether min(array, int) is elementwise or specifying a dimension is ambiguous. for now use min(array, (), dim), though this is terrible and suggestions are hereby solicited. - the count() array reduction did not work also: - make reduce() avoid the 0-argument form of an operator unless the given collection is empty - make any(itr) and all(itr) early-out
Stdlib: SHA URL: https://github.com/JuliaCrypto/SHA.jl.git Stdlib branch: master Julia branch: master Old commit: aaf2df6 New commit: 8fa221d Julia version: 1.12.0-DEV SHA version: 0.7.0(Does not match) Bump invoked by: @inkydragon Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaCrypto/SHA.jl@aaf2df6...8fa221d ``` $ git log --oneline aaf2df6..8fa221d 8fa221d ci: update doctest config (#120) 346b359 ci: Update ci config (#115) aba9014 Fix type mismatch for `shake/digest!` and setup x86 ci (#117) 0b76d04 Merge pull request #114 from JuliaCrypto/dependabot/github_actions/codecov/codecov-action-5 5094d9d Update .github/workflows/CI.yml 45596b1 Bump codecov/codecov-action from 4 to 5 230ab51 test: remove outdate tests (#113) 7f25aa8 rm: Duplicated const alias (#111) aa72f73 [SHA3] Fix padding special-case (#108) 3a01401 Delete Manifest.toml (#109) da351bb Remvoe all getproperty funcs (#99) 4eee84f Bump codecov/codecov-action from 3 to 4 (#104) 15f7dbc Bump codecov/codecov-action from 1 to 3 (#102) 860e6b9 Bump actions/checkout from 2 to 4 (#103) 8e5f0ea Add dependabot to auto update github actions (#100) 4ab324c Merge pull request #98 from fork4jl/sha512-t a658829 SHA-512: add ref to NIST standard 11a4c73 Apply suggestions from code review 969f867 Merge pull request #97 from fingolfin/mh/Vector b1401fb SHA-512: add NIST test 4d7091b SHA-512: add to docs 09fef9a SHA-512: test SHA-512/224, SHA-512/256 7201b74 SHA-512: impl SHA-512/224, SHA-512/256 4ab85ad Array -> Vector 8ef91b6 fixed bug in padding for shake, addes testcases for full code coverage (#95) 88e1c83 Remove non-existent property (#75) 068f85d shake128,shake256: fixed typo in export declarations (#93) 176baaa SHA3 xof shake128 and shake256 (#92) e1af7dd Hardcode doc edit backlink ``` Co-authored-by: Dilum Aluthge <[email protected]>
Find works differently than in MATLAB, because if you find on a matrix, you get a bunch of index-pairs. But this is kind of annoying when you're dealing with nx1 or 1xn matrices, then you're often throwing in find(v)[1] and find(v)[2] to get things to work. To understand, type a = [1,0,1]; and then findnd(a), findnd(a'), findnd(a").
Furthermore, in MATLAB you're often doing A1(logical(A2)) or vec1(logical(vec2)), there should be canonical ways of doing these things in Julia.
These things should be considered along with whatever Julia's solution is to ind2sub and sub2ind (from MATLAB). If A is a matrix of 1's and 0's, [x,y] = ind2sub(size(A),find(A)) does in MATLAB what find currently does in Julia.
The text was updated successfully, but these errors were encountered: