Vectors: Difference between revisions

From MemCP
Jump to navigation Jump to search
No edit summary
(Refresh MemCP documentation: accuracy, operational guidance, performance profile and maintained API reference)
 
Line 1: Line 1:
<!-- Copyright (C) 2026 Carl-Philip Haensch -->
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
<span id="vectors"></span>
= Vectors =
= Vectors =


The '''Vectors''' module provides vector mathematics functionality for the SCM programming language. This module includes:
<!-- Generated from MemCP c42e19eba on 2026-08-27; do not edit manually. -->
 
<div class="mw-message-box mw-message-box-notice">Generated from MemCP commit <code>c42e19eba</code> on 27 August 2026. See [[Full SCM API documentation]].</div>
* '''Vector operations''': Functions to perform mathematical operations on vectors (dot)
* '''Distance calculations''': Support for different distance metrics including DOT, COSINE, and EUCLIDEAN


These functions provide essential tools for working with vectors in mathematical computations, enabling vector analysis and similarity calculations in SCM programs.
The '''Vectors''' module treats numeric lists as vectors. Its current public primitive, <code>dot</code>, supports a normal dot product plus modes named <code>COSINE</code> and <code>EUCLIDEAN</code>. Vector functions are useful for scoring and mathematical expressions but do not by themselves provide storage, dimensional validation, or an approximate-nearest-neighbor index.


← Back to [[Full SCM API documentation]]
The implementation processes only positions present in both input lists. Callers must therefore validate equal dimensions when that is part of the data contract. In commit <code>c42e19eba</code>, <code>EUCLIDEAN</code> returns the square root of the accumulated pairwise products; this is '''not''' the standard Euclidean distance <code>sqrt(sum((a-b)^2))</code>. Do not use that mode as a distance metric without accounting for this compatibility behavior.


== dot ==
== dot ==
Line 26: Line 28:
=== Returns ===
=== Returns ===


<code>number</code>
* '''value''' (<code>number</code>)

Latest revision as of 11:59, 28 August 2026


Vectors

Generated from MemCP commit c42e19eba on 27 August 2026. See Full SCM API documentation.

The Vectors module treats numeric lists as vectors. Its current public primitive, dot, supports a normal dot product plus modes named COSINE and EUCLIDEAN. Vector functions are useful for scoring and mathematical expressions but do not by themselves provide storage, dimensional validation, or an approximate-nearest-neighbor index.

The implementation processes only positions present in both input lists. Callers must therefore validate equal dimensions when that is part of the data contract. In commit c42e19eba, EUCLIDEAN returns the square root of the accumulated pairwise products; this is not the standard Euclidean distance sqrt(sum((a-b)^2)). Do not use that mode as a distance metric without accounting for this compatibility behavior.

dot

produced the dot product

Allowed number of parameters: 2–3

Parameters

  • v1 (list): vector1
  • v2 (list): vector2
  • mode (string): DOT, COSINE, EUCLIDEAN, default is DOT (optional)

Returns

  • value (number)