I am using Google Analytics and processing the data with Bigquery, I need to do a matrix multiplication.
What is the most feasible way of implementing matrix multiplication in Google Cloud? Can it be done directly in Bigquery?
I am using Google Analytics and processing the data with Bigquery, I need to do a matrix multiplication.
What is the most feasible way of implementing matrix multiplication in Google Cloud? Can it be done directly in Bigquery?
Suppose a matrix with two columns, a path and a value column. You want to get the adjacency matrix
P P^t
. With 6 paths, you wanna get 36 values or 6x6 matrix that can be done with matrix multiplication.I refactor Mikhail example for a path adjacency matrix given some tuple
(Path, value)
. The demo contains 6 paths so the resulting adjacency matrix has dimensions 6x6. It is now in a straight format, but I would like to get it into a matrix formar or crosstab format with 6x6 form.where the shaping question is now here about shaping the straight table into more traditional matrix multiplication format.
Assuming MatrixA is a table with below columns:
and MatrixB - has schema as
and also assuming that range of k-values is the same in both tables:
This would mimic below matrices :
Below code for multiplication is for BigQuery Standard SQL
result will be as below
which represents MatrixA * MatrixB
as a note: you can use
instead of
just matter of your preferences