MarkLogic 12 EA 1 Product Documentation
vec:normalize

vec:normalize(
   $vector1 as vec:vector
) as vec:vector

Summary

Returns the vector passed in, normalized to a length of 1.

Parameters
vector1 The vector to normalize.

Example

  xquery version "1.0-ml";
  vec:normalize(vec:vector((3.14, 1.59, 2.65)))

  => [ 0.712713, 0.360896, 0.601493 ] (: the vector value normalized to length 1 :)
Powered by MarkLogic Server | Terms of Use | Privacy Policy