@Override
        public void cellByDirectIndex(long index, double value) {
            try {
                values[(int) index] = value;
            }
            catch (IndexOutOfBoundsException e) {
                throw new IllegalArgumentException("Can not set the cell at position " + index + " in a tensor " +
                                                   "of type " + type + ": Index is too large");
            }
        }
A bound builder can create the double array directly
vespajlib/src/main/java/com/yahoo/tensor/IndexedDoubleTensor.java