transpose_and_dot


transpose_and_dot(array X, array Y) – Returns dot(X.T, Y) as array>, shape = (X.#cols, Y.#cols)

WITH input as (
select array(1.0, 2.0, 3.0, 4.0) as x, array(1, 2) as y
UNION ALL
select array(2.0, 3.0, 4.0, 5.0) as x, array(1, 2) as y
)
select
transpose_and_dot(x, y) as xy,
transpose_and_dot(y, x) as yx
from
input;

[[“3.0″,”6.0”],[“5.0″,”10.0”],[“7.0″,”14.0”],[“9.0″,”18.0”]] [[“3.0″,”5.0″,”7.0″,”9.0”],[“6.0″,”10.0″,”14.0″,”18.0”]]

Platforms: WhereOS, Spark, Hive
Class: hivemall.tools.matrix.TransposeAndDotUDAF

More functions can be added to WhereOS via Python or R bindings or as Java & Scala UDF (user-defined function), UDAF (user-defined aggregation function) and UDTF (user-defined table generating function) extensions. Custom libraries can be added on via Settings-page or installed from WhereOS Store.

Leave a Reply