oconaid
November 5, 2020, 11:58pm
1
Hi There,
Can I check with you, is there a function on Tigergraph which calculates the dotproduct of two vectors. I can do this in python, but I do not see how I can so this on Tigergraph.
Many thanks.
Kind regards,
Aiden
one way is using expression function with arrayAccum.
The expression function is dotProduct_ArrayAccum_ArrayAccum() in
/******************************************************************************
* Copyright (c) 2015-2016, TigerGraph Inc.
* All rights reserved.
* Project: TigerGraph Query Language
* udf.hpp: a library of user defined functions used in queries.
*
* - This library should only define functions that will be used in
* TigerGraph Query scripts. Other logics, such as structs and helper
* functions that will not be directly called in the GQuery scripts,
* must be put into "ExprUtil.hpp" under the same directory where
* this file is located.
*
* - Supported type of return value and parameters
* - int
* - float
* - double
* - bool
* - string (don't use std::string)
* - accumulators
*
This file has been truncated. show original
search dotProduct_ArrayAccum_ArrayAccum in this GSQL query.
CREATE QUERY training(DOUBLE alpha = 0.001, INT Iter=10) FOR GRAPH Recommender {
#ListAccum<DOUBLE> @theta;
ListAccum<DOUBLE> @tmp;
ArrayAccum<SumAccum<double>> @theta[10];
ArrayAccum<SumAccum<double>> @x[10];
ArrayAccum<SumAccum<double>> @Gradient[10];
SumAccum<DOUBLE> @@cost;
DOUBLE lambda = 10;
## pass x and theta to local accum
MOVIEs = {MOVIE.*};
# M1 = SELECT s FROM MOVIEs:s
# WHERE s.movie_id == "1";
MOVIEs = SELECT s FROM MOVIEs:s
ACCUM
FOREACH i IN RANGE[0,9] DO
This file has been truncated. show original
kwonder
December 10, 2021, 8:40am
3
I also wanted to implement matrix products in GSQL, but seemed to be able to do so only by modifying UDF
But I don’t know anything about C++
It’s so sad