
vec:precision( $vector as vec:vector?, [$precision as xs:integer?] ) as vec:vector
Returns a new vector which is a copy of the input vector with reduced precision. The precision reduction is achieved by clearing the bottom (32 - precision) bits of the mantissa for each dimension's float value. This can be useful for reducing storage requirements or for creating approximate vector representations.
xquery version "1.0-ml"; let $vec := vec:vector((3.14159265, 2.71828182, 1.41421356)) return vec:precision($vec, 16) => [ 3.14062, 2.70312, 1.41406 ]
xquery version "1.0-ml"; let $vec := vec:vector((3.14159265, 2.71828182, 1.41421356)) let $reduced := vec:precision($vec) return ($vec, $reduced) [ 3.14159, 2.71828, 1.41421 ] [ 3.14062, 2.70312, 1.41406 ]
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.