Vector
Vector computation on JSON arrays of numbers: add, scale, dot and cross products, norm, angle, cosine similarity, and search of the rows closest to a vector. Typical uses: geometry, similarity search on embeddings.
vector anglevector crossvector dotvector normvector unitvector addvector scalevector subvector cosinevector searchvector search
vector angle <json_vector> <json_vector2>
Description
Get the angle between two vectors (radians, in [0, pi])
Get the angle between two vectors (radians, in [0, pi])
Parameters
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
admin
vector angle "[1, 0, 0]" "[1, 1, 0]"
mentdb
0.7853981633974483
Orthogonal vectors: pi/2
admin
vector angle "[1, 2]" "[-2, 1]"
mentdb
1.5707963267948966
Perpendicular vectors: pi/2
admin
vector angle "[1, 0]" "[0, 1]"
mentdb
1.5707963267948966
Opposite vectors: pi
admin
vector angle "[1, 1]" "[-2, -2]"
mentdb
3.141592653589793
In degrees
admin
math rad_to_deg (vector angle "[1, 0, 0]" "[1, 1, 1]")
mentdb
54.735610317245346
Used in use cases (2 recipes)
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Often used with
math rad_to_deg · vector cross · vector dot · vector norm · vector scale · vector sub · vector unit · complex add
math rad_to_deg · vector cross · vector dot · vector norm · vector scale · vector sub · vector unit · complex add
vector cross <json_vector> <json_vector2>
Description
Get the cross product of two vectors of size 3
Get the cross product of two vectors of size 3
Parameters
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
admin
vector cross "[1, 0, 0]" "[0, 1, 0]"
mentdb
[0,0,1]
Torque r x F
admin
vector cross "[0.5, 0, 0]" "[0, 10, 0]"
mentdb
[0,0,5]
Parallel vectors: zero vector
admin
vector cross "[1, 2, 3]" "[2, 4, 6]"
mentdb
[0,0,0]
Area of the triangle (0,0,0), (1,0,0), (0,1,1): half of the norm
admin
-> "[n]" (vector norm (vector cross "[1, 0, 0]" "[0, 1, 1]")); math calc "[n]/2"
mentdb
0.7071067811865476
Not in 3 dimensions: error
admin
vector cross "[1, 2]" "[3, 4]"
mentdb
Sorry, an error appears (the cross product needs two vectors of size 3 (2 and 2)).
Used in use cases (3 recipes)
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Often used with
vector dot · vector norm · vector scale · math atan2 · math rad_to_deg · vector add · vector angle · vector sub
vector dot · vector norm · vector scale · math atan2 · math rad_to_deg · vector add · vector angle · vector sub
vector dot <json_vector> <json_vector2>
Description
Get the dot product of two vectors
Get the dot product of two vectors
Parameters
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector2: A vector: JSON array of numbers - String - required
admin
vector dot "[1, 2, 3]" "[4, 5, 6]"
mentdb
32
Work of a force W = F . d
admin
vector dot "[10, 0, 5]" "[3, 4, 0]"
mentdb
30
Perpendicular: 0
admin
vector dot "[1, 2]" "[-2, 1]"
mentdb
0
Different sizes: error
admin
vector dot "[1, 2]" "[1, 2, 3]"
mentdb
Sorry, an error appears (the vectors must have the same size (2 and 3)).
Used in use cases (13 recipes)
Acoustics engineer › Reverberation time of a classroom
Operations researcher › Availability of a machine with a Markov chain
Crystallographer & materials physicist › Miller indices, d-spacing and Bragg angle in a monoclinic cell
Materials scientist › Fatigue life: Basquin law, Goodman correction and Miner rule
Pharmacist & pharmacokinetics › Dissolution profile similarity: f1 and f2 factors
Space mission engineer › Orbital elements from a state vector
and 7 more in the Use cases
Acoustics engineer › Reverberation time of a classroom
Operations researcher › Availability of a machine with a Markov chain
Crystallographer & materials physicist › Miller indices, d-spacing and Bragg angle in a monoclinic cell
Materials scientist › Fatigue life: Basquin law, Goodman correction and Miner rule
Pharmacist & pharmacokinetics › Dissolution profile similarity: f1 and f2 factors
Space mission engineer › Orbital elements from a state vector
and 7 more in the Use cases
Often used with
matrix mul · vector norm · vector sub · matrix inverse · json load select · math abs · matrix det · matrix qr
matrix mul · vector norm · vector sub · matrix inverse · json load select · math abs · matrix det · matrix qr
vector norm <json_vector>
Description
Get the Euclidean norm of a vector
Get the Euclidean norm of a vector
Parameters
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
admin
vector norm "[3, 4]"
mentdb
5
3D vector
admin
vector norm "[1, 2, 2]"
mentdb
3
4 dimensions
admin
vector norm "[1, 1, 1, 1]"
mentdb
2
Speed from the components (m/s)
admin
vector norm "[3.2, -1.5, 0.8]"
mentdb
3.6235341863986883
Used in use cases (8 recipes)
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Chemist › Two dyes in one drink by least squares (QR)
Medical physicist › Linac bunker: primary barrier thickness (NCRP 147)
Space mission engineer › Orbital elements from a state vector
Climate & environment scientist › Acceleration of the sea level rise by QR least squares
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
and 2 more in the Use cases
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Chemist › Two dyes in one drink by least squares (QR)
Medical physicist › Linac bunker: primary barrier thickness (NCRP 147)
Space mission engineer › Orbital elements from a state vector
Climate & environment scientist › Acceleration of the sea level rise by QR least squares
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
and 2 more in the Use cases
Often used with
vector dot · vector sub · matrix mul · matrix qr · vector cross · vector scale · json load select · math atan2
vector dot · vector sub · matrix mul · matrix qr · vector cross · vector scale · json load select · math atan2
vector unit <json_vector>
Description
Get the unit vector (same direction, norm 1)
Get the unit vector (same direction, norm 1)
Parameters
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
json_vector: A vector: JSON array of numbers, ex: [1, 2, 3] - String - required
admin
vector unit "[3, 4]"
mentdb
[0.6,0.8]
3D unit vector
admin
vector unit "[1, 2, 2]"
mentdb
[0.3333333333333333,0.6666666666666666,0.6666666666666666]
Already of norm 1
admin
vector unit "[0, 1, 0]"
mentdb
[0,1,0]
Direction of a force
admin
vector unit "[10, -10, 5]"
mentdb
[0.6666666666666666,-0.6666666666666666,0.3333333333333333]
Used in use cases (2 recipes)
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Space mission engineer › Orbital elements from a state vector
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
Often used with
math rad_to_deg · vector angle · vector cross · vector dot · vector norm · vector scale · vector sub · complex add
math rad_to_deg · vector angle · vector cross · vector dot · vector norm · vector scale · vector sub · complex add
vector add <json_vector> <json_vector2>
Description
Add two vectors
Add two vectors
Parameters
json_vector: A vector: JSON array of numbers - String - required
json_vector2: A vector: JSON array of numbers - String - required
json_vector: A vector: JSON array of numbers - String - required
json_vector2: A vector: JSON array of numbers - String - required
admin
vector add "[1, 2, 3]" "[4, 5, 6]"
mentdb
[5,7,9]
Sum of two forces
admin
vector add "[3, 0]" "[0, 4]"
mentdb
[3,4]
Sum of forces
admin
vector add "[10, 0, 0]" "[0, -5, 2]"
mentdb
[10,-5,2]
Different sizes: error
admin
vector add "[1, 2]" "[1, 2, 3]"
mentdb
Sorry, an error appears (the vectors must have the same size (2 and 3)).
Used in use cases (6 recipes)
Acoustics engineer › Fan noise PSD: periodogram against Welch
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Corrosion researcher › Inhibitor efficiency statistics and Langmuir adsorption
Agronomist › Growing degree days and frost risk for maize
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
IoT & sensor engineer › Remove mains hum from a sensor by FFT
Acoustics engineer › Fan noise PSD: periodogram against Welch
Crystallographer & materials physicist › Twinning in titanium: the 10-12 twin
Corrosion researcher › Inhibitor efficiency statistics and Langmuir adsorption
Agronomist › Growing degree days and frost risk for maize
Robotics engineer › Inverse kinematics of a 2-link arm and static torque
IoT & sensor engineer › Remove mains hum from a sensor by FFT
Often used with
vector scale · json load select · matrix col · matrix row · num table · stat dist_random · stat mean · vector cross
vector scale · json load select · matrix col · matrix row · num table · stat dist_random · stat mean · vector cross
vector scale <json_vector> <k>
Description
Multiply a vector by a number
Multiply a vector by a number
Parameters
json_vector: A vector: JSON array of numbers - String - required
k: The number - Number - required
json_vector: A vector: JSON array of numbers - String - required
k: The number - Number - required
admin
vector scale "[1, 2, 3]" 2.5
mentdb
[2.5,5,7.5]
Opposite vector
admin
vector scale "[1, -2, 3]" -1
mentdb
[-1,2,-3]
By 0
admin
vector scale "[1, 2, 3]" 0
mentdb
[0,0,0]
Velocity x time = displacement
admin
vector scale "[2.5, 0, -1]" 4
mentdb
[10,0,-4]
Used in use cases (10 recipes)
Metrologist › Calibrating a psi gauge against a kPa reference
Crystallographer & materials physicist › Structure factors and powder pattern of NaCl
Corrosion researcher › EIS fit with a CPE and inhibition efficiency
Agronomist › Growing degree days and frost risk for maize
Space mission engineer › Orbital elements from a state vector
Climate & environment scientist › Temperature anomalies against a reference decade
and 4 more in the Use cases
Metrologist › Calibrating a psi gauge against a kPa reference
Crystallographer & materials physicist › Structure factors and powder pattern of NaCl
Corrosion researcher › EIS fit with a CPE and inhibition efficiency
Agronomist › Growing degree days and frost risk for maize
Space mission engineer › Orbital elements from a state vector
Climate & environment scientist › Temperature anomalies against a reference decade
and 4 more in the Use cases
Often used with
vector sub · vector add · complex add · stat max · vector cross · vector dot · vector norm · complex arg
vector sub · vector add · complex add · stat max · vector cross · vector dot · vector norm · complex arg
vector sub <json_vector> <json_vector2>
Description
Subtract two vectors
Subtract two vectors
Parameters
json_vector: A vector: JSON array of numbers - String - required
json_vector2: A vector: JSON array of numbers - String - required
json_vector: A vector: JSON array of numbers - String - required
json_vector2: A vector: JSON array of numbers - String - required
admin
vector sub "[1, 2, 3]" "[4, 5, 6]"
mentdb
[-3,-3,-3]
Displacement between two points
admin
vector sub "[5, 7, 2]" "[1, 2, 2]"
mentdb
[4,5,0]
Vector from point A to point B: B - A
admin
vector sub "[4, 6, 1]" "[1, 2, 1]"
mentdb
[3,4,0]
Same vector: zero
admin
vector sub "[1, 2]" "[1, 2]"
mentdb
[0,0]
Used in use cases (12 recipes)
Metrologist › Calibrating a psi gauge against a kPa reference
Pharmacist & pharmacokinetics › Dissolution profile similarity: f1 and f2 factors
Medical physicist › Linac bunker: primary barrier thickness (NCRP 147)
Agronomist › Growing degree days and frost risk for maize
Space mission engineer › Orbital elements from a state vector
Meteorologist › Verification of two temperature forecast models
and 6 more in the Use cases
Metrologist › Calibrating a psi gauge against a kPa reference
Pharmacist & pharmacokinetics › Dissolution profile similarity: f1 and f2 factors
Medical physicist › Linac bunker: primary barrier thickness (NCRP 147)
Agronomist › Growing degree days and frost risk for maize
Space mission engineer › Orbital elements from a state vector
Meteorologist › Verification of two temperature forecast models
and 6 more in the Use cases
Often used with
stat mean · vector dot · vector scale · math round_sig · vector norm · json load select · math abs · unit convert
stat mean · vector dot · vector scale · math round_sig · vector norm · json load select · math abs · unit convert
vector cosine <vector_a> <vector_b>
Description
The cosine similarity of two vectors (JSON arrays of numbers, same dimension), from -1 to 1. A zero vector is an error
The cosine similarity of two vectors (JSON arrays of numbers, same dimension), from -1 to 1. A zero vector is an error
Parameters
vector_a: The first vector - String - required
vector_b: The second vector - String - required
vector_a: The first vector - String - required
vector_b: The second vector - String - required
admin
vector cosine "[1, 2, 3]" "[4, 5, 6]"
mentdb
0.9746318461970763
Orthogonal vectors
admin
vector cosine "[1, 0]" "[0, 1]"
mentdb
0
vector search <query_vector> <rows_json>
Description
The rows closest to a vector, in memory: the 10 best rows, by descending cosine in a score field, ties in the order of the rows. The vector of a row is in its field embedding, a JSON array or the text of one. A row without vector or with another dimension is an error; a zero vector in a row scores 0. The field embedding is removed from the result
The rows closest to a vector, in memory: the 10 best rows, by descending cosine in a score field, ties in the order of the rows. The vector of a row is in its field embedding, a JSON array or the text of one. A row without vector or with another dimension is an error; a zero vector in a row scores 0. The field embedding is removed from the result
Parameters
query_vector: The vector of the question - String - required
rows_json: The rows: JSON array of objects - String - required
query_vector: The vector of the question - String - required
rows_json: The rows: JSON array of objects - String - required
admin
vector search "[1, 0, 0]" "[{\"id\": 1, \"title\": \"Refund policy\", \"embedding\": [0.9, 0.1, 0]}, {\"id\": 2, \"title\": \"Delivery times\", \"embedding\": [0.1, 0.9, 0]}, {\"id\": 3, \"title\": \"Returns\", \"embedding\": [0.8, 0.2, 0.1]}]"
mentdb
[{"id": 1, "title": "Refund policy", "score": 0.9938837346736189}, {"id": 3, "title": "Returns", "score": 0.9630868246861536}, {"id": 2, "title": "Delivery times", "score": 0.11043152607484655}]
vector search <query_vector> <rows_json> <json_params>
Description
Search with parameters: field (embedding), k (10), min_score (no limit), keep_vector (false)
Search with parameters: field (embedding), k (10), min_score (no limit), keep_vector (false)
Parameters
query_vector: The vector of the question - String - required
rows_json: The rows - String - required
json_params: The parameters: see the description of the page - String - required
query_vector: The vector of the question - String - required
rows_json: The rows - String - required
json_params: The parameters: see the description of the page - String - required
admin
vector search "[1, 0, 0]" "[{\"id\": 1, \"title\": \"Refund policy\", \"embedding\": [0.9, 0.1, 0]}, {\"id\": 2, \"title\": \"Delivery times\", \"embedding\": [0.1, 0.9, 0]}, {\"id\": 3, \"title\": \"Returns\", \"embedding\": [0.8, 0.2, 0.1]}]" "{\"k\": 1, \"min_score\": 0.5}"
mentdb
[{"id": 1, "title": "Refund policy", "score": 0.9938837346736189}]
Another field, vector kept
admin
vector search "[0, 1]" "[{\"id\": 1, \"v\": \"[1, 0]\"}, {\"id\": 2, \"v\": \"[0, 2]\"}]" "{\"field\": \"v\", \"k\": 1, \"keep_vector\": true}"
mentdb
[{"id": 2, "v": "[0, 2]", "score": 1}]
Used in use cases (1 recipe)
JSON & document store developer › Find the closest answer by meaning: cut, embed, search
JSON & document store developer › Find the closest answer by meaning: cut, embed, search
