Skip to content

Support for argmin, argmax? #183

@pitsianis

Description

@pitsianis

As the title says, is there a way to support ThreadsX.argmin and ThreadsX.argmax?
Sorry I am too new with Julia to be able to help.

The way I see it is to define the argmax reduction

oneargmax((mxi,mx),(i,ai)) = (mx<ai) ? (i,ai) : (mxi,mx)

# but I do not know how to define the generic initial value for the foldl/reduce  in ThreadsX
myargmax(f, itr; init=(nothing,-1)) = ThreadsX.mapreduce(identity, oneargmax, zip(itr,Iterators.map(f,itr)); simd = Val(true), init)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions