Postgres Flatten Array Numpy Matrix Product Formula Of Integration