Skip to content

Most reductions in ArrayFire.Algorithms should return array, not scalar #36

@gilgamec

Description

@gilgamec

The functions which take a dimension to reduce along should return a full matrix, with only that dimension flattened, rather than a single scalar. These are (at least) sum, sumNaN, product, productNaN, min, max, allTrue, anyTrue, and count. The correct array is being computed by the FFI, but the getScalar function is being applied and just extracts the first element, rather than returning the entire array. The current behaviour of (for instance) sum is

λ> A.mkArray @Int [2,3] [1..]
ArrayFire Array
[2 3 1 1]
         1          3          5 
         2          4          6 
λ> A.sum it 0
3
λ> A.sum it 1
9

as opposed to the expected output,

ArrayFire Array
[1 3 1 1]
         3          7         11 

and

ArrayFire Array
[2 1 1 1]
         9 
        12 

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions