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


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)"

apoliakov@scalpel:~/workspace/scidb_trunk$ iquery -aq "apply(bar, thirdpow, exp(log(val) * 3))"

Does this work?


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