Postgres Flatten Array Numpy Matrix Product Calculator