Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Vector Operation Function Interface

Updated on 2024-06-03 GMT+08:00

Functions implemented by the vector operation function include: vector size comparison, vector addition, vector subtraction, and vector bitwise multiplication.

inner_product

Function: Calculates the inner product of two vectors.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: float8

Code example:

gaussdb=# SELECT inner_product(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT inner_product('[1,2,3]', '[5,-1,3.5]');

vector_negative_inner_product

Function: Calculates the negative inner product of two vectors.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: float8

Code example:

gaussdb=# SELECT vector_negative_inner_product(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_negative_inner_product('[1,2,3]', '[5,-1,3.5]');

vector_dims

Function: Returns the dimension value of the floatvector vector.

Input parameter type: floatvector

Output parameter type: int4

Code example:

gaussdb=# SELECT vector_dims(floatvector('[1,2,3]'));
gaussdb=# SELECT vector_dims('[1,2,3]');

vector_norm

Function: Returns the L2 norm of a vector.

Input parameter type: floatvector

Output parameter type: float8

Code example:

gaussdb=# SELECT vector_norm(floatvector('[1,2,3]'));
gaussdb=# SELECT vector_norm('[1,2,3]');

vector_add

Function: Calculates the sum of two vectors.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: floatvector

Code example:

gaussdb=# SELECT vector_add(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_add('[1,2,3]', '[5,-1,3.5]');

vector_sub

Function: Calculates the subtraction between two vectors.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: floatvector

Code example:

gaussdb=# SELECT vector_sub(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_sub('[1,2,3]', '[5,-1,3.5]');

vector_lt

Function: Compares the vector size and checks whether vector 1 is less than vector 2.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_lt(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_lt('[1,2,3]', '[5,-1,3.5]');

vector_le

Function: Compares the vector size and checks whether vector 1 is less than or equal to vector 2.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_le(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_le('[1,2,3]', '[5,-1,3.5]');

vector_eq

Function: Compares whether vectors are equal.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_eq(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_eq('[1,2,3]', '[5,-1,3.5]');

vector_ne

Function: Compares whether vectors are unequal.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_ne(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_ne('[1,2,3]', '[5,-1,3.5]');

vector_ge

Function: Compares the vector size and checks whether vector 1 is greater than or equal to vector 2.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_ge(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_ge('[1,2,3]', '[5,-1,3.5]');

vector_gt

Function: Compares the vector size and checks whether vector 1 is greater than vector 2.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT vector_gt(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_gt('[1,2,3]', '[5,-1,3.5]');

vector_cmp

Function: Compares vector sizes.

Type of input parameter 1: floatvector

Type of input parameter 2: floatvector

Output parameter type: int4

Code example:

gaussdb=# SELECT vector_cmp(floatvector('[1,2,3]'), floatvector('[5,-1,3.5]'));
gaussdb=# SELECT vector_cmp('[1,2,3]', '[5,-1,3.5]');

vector_accum

Function: Returns the vector accumulation.

Type of input parameter 1: anyarray

Type of input parameter 2: floatvector

Output parameter type: anyarray

Code example:

-- This is a system function and is not recommended. If this function is required, the array element type must be float8.
gaussdb=# SELECT vector_accum(array[cast(3 as float8),1,2,3],  floatvector('[5,-1,3.5]'));

vector_combine

Function: Combines vectors.

Type of input parameter 1: anyarray

Type of input parameter 2: anyarray

Output parameter type: anyarray

Code example:

-- This is a system function and is not recommended. If this function is required, the array element type must be float8.
gaussdb=# SELECT vector_combine(array[cast(1 as float8),2,3], array[cast(1 as float8),2,3]);

vector_avg

Function: Averages vectors.

Input parameter type: anyarray

Output parameter type: floatvector

Code example:

-- This is a system function and is not recommended. If this function is required, the array element type must be float8.
gaussdb=# SELECT vector_avg(array[cast(1 as float8),2,3]);

bool_vector_dims

Function: Returns the dimension value of the boolvector vector.

Input parameter type: boolvector

Output parameter type: int4

Code example:

gaussdb=# SELECT bool_vector_dims(boolvector('[1,1,1]'));

bool_vector_eq

Function: Compares whether Boolean vectors are equal.

Type of input parameter 1: boolvector

Type of input parameter 2: boolvector

Output parameter type: Boolean

Code example:

gaussdb=# SELECT bool_vector_eq(boolvector('[1,1,1]'), boolvector('[1,1,1]'));
gaussdb=# SELECT bool_vector_eq('[1,1,1]', '[1,1,1]');

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback