Element-wise data access in SciDB


#1

Hi,
Any method to access an array element in expression.
Say,

create array A <val:float>[i=1:100000,10000,1, j=1:100000,10000,1];

Assign a value to a specific element:

A.val[34, 56] = 100

Thanks,

  • Bin

#2

@dbin:

Here is one solution. Note that I changed your query to provide the example at a specific index id [34, 56] instead of at [0,0] (just to make the example more instructive)

## Create the blank array
iquery -aq "create array A <val:float>[i=1:100,100,1, j=1:100,100,1]"
# Query was executed successfully

## Verify the created array
iquery -aq "show(A)"
# {i} schema
# {0} 'A<val:float> [i=1:100,100,1,j=1:100,100,1]'

## Here is how you create a 1 element array and initialize it with
##  your required value of 100
iquery -aq "build(<val:float>[i=34:34,100,1, j=56:56,100,1], 100)"
# {i,j} val
# {34,56} 100

## The trick is to redimension the built 1 element array to the schema of A
iquery -aq "redimension(build(<val:float>[i=34:34,100,1, j=56:56,100,1], 100), A)"
# {i,j} val
# {34,56} 100

## This is the only command you need to replicate `A.val[34, 56]=100`
iquery -aq "store(redimension(build(<val:float>[i=34:34,100,1, j=56:56,100,1], 100), A), A)"
# {i,j} val
# {34,56} 100

## Verify the loaded data
iquery -aq "scan(A)"
# {i,j} val
# {34,56} 100