0

I am investigating using iOS Accelerate to perform some fast math on a mobile device. I would need the equivalent of np.maximum in numpy. This is an element wise maximum between 2 ndarray.

I have been searching documentations related to Apple Accelerate Framework, and I found nothing within it that can directly perform this.

Note: The Q was answered correctly below and tested with:

let a: [Float] = [2, 4, 3, 8, 1, 10]

let b: [Float] = [1, 5, 2, 1, 9, 1]

var c: [Float] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

vDSP_vmax(a, 1, b, 1, &c, 1, 6)

c

in a Xcode Playground.

kawingkelvin
  • 3,649
  • 2
  • 30
  • 50

1 Answers1

1

Check vDSP_vmaxD(). It's what you want.

E.Coms
  • 11,065
  • 2
  • 23
  • 35
  • This looks like what I wanted. I noticed this isn't under Accelerate Framework documentation, it is actually under Kernel. I wonder why they organized it this way. Let me give this a try, and will upvote if i get to work. – kawingkelvin Nov 16 '18 at 01:45
  • Yes, this is exactly what i wanted. I tried: let a: [Float] = [2, 4, 3, 8, 1, 10] let b: [Float] = [1, 5, 2, 1, 9, 1] var c: [Float] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] vDSP_vmax(a, 1, b, 1, &c, 1, 6) – kawingkelvin Nov 16 '18 at 01:50