Exponentiation


#1

Suppose I’d like to square all elements of an array - is there an expression that can be used as an argument in an apply() query that will do so?

I tried pow() and ^, these did not show up as functions in SciDB. I see that there’s an exp() function, but I can’t get it to return the results I’m looking for.

I’m currently using SciDB 0.75, any suggestions appreciated!

Thanks, Patrick


#2

Hello, Patrick

The exp() function gives you e raised to some power. We also have the log function that gives you the natural logarithm.
So, with some math… here’s an example that raises everything in the array to the third power:

apoliakov@scalpel:~/workspace/scidb_trunk$ iquery -aq "show(bar)"
[("bar<val:int64 NOT NULL> [x=1:10,2,0]")]

apoliakov@scalpel:~/workspace/scidb_trunk$ iquery -aq "scan(bar)"
[(1),(2),(3),(4),(5),(6),(7),(8),(9),(10)]

apoliakov@scalpel:~/workspace/scidb_trunk$ iquery -aq "apply(bar, thirdpow, exp(log(val) * 3))"
[(1,1),(2,8),(3,27),(4,64),(5,125),(6,216),(7,343),(8,512),(9,729),(10,1000)]

Does this work?


#3

Yes, that’ll do, thanks for the prompt response!

Patrick