views:

32

answers:

1

I would like to perform a fairly simple divide operation in Microsoft Accelerator:

X = P / (1 + K * O')

where P, K and O are vectors, and K * O' performs a dot product operation.

I tried PA.Divide(P, 1 + PA.Sum(PA.Multiply(K, O))), however this does not work as it gives an error saying the matrices supplied to the divide command are of different dimensions, which makes sense as the second argument should just be a scalar.

I got around this by converting the second argument to an array then using its first element, but this slows down computation significantly.

How can I perform this operation without converting to an array first?

+1  A: 

I don't know how expensive multiplicative inversion is in Accelerator, but you can use scalar multiplication if you rewrite your expression this way:

X = P * (1 / (1 + K * O'))

Where 1 / (1 + K + O') is just the multiplicative inverse of the scalar you're already computing.

This is assuming that scalar multiplication is available to you (it should be - it's a fundamental operation). But of course I'm not familiar with Accelerator. I'm just speaking from a vector math point of view.

Welbog