-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathdimension_count.gsql
37 lines (29 loc) · 1.18 KB
/
dimension_count.gsql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
CREATE OR REPLACE FUNCTION gds.vector.dimension_count(list<double> list1) RETURNS(int) {
/*
First Author: Jue Yuan
First Commit Date: Nov 27, 2024
Recent Author: Jue Yuan
Recent Commit Date: Nov 27, 2024
Maturity:
alpha
Description:
Returns the number of dimensions (elements) in a given vector, represented as a list of double values.
This function is useful for determining the size or dimensionality of input vectors in mathematical
and data processing operations.
Parameters:
list<double> list1:
The input vector as a list of double values.
Returns:
int:
The number of elements (dimensions) in the input vector.
Logic Overview:
Accepts a list of double values as input.
Calculates the size of the list, which corresponds to the number of dimensions.
Returns the size as an integer.
Use Case:
This function is valuable in vector-based computations, such as machine learning or data analysis tasks,
where understanding the dimensionality of vectors is crucial for validation, preprocessing, or compatibility checks.
*/
ListAccum<double> @@myList1 = list1;
RETURN @@myList1.size();
}