MCPcopy Create free account
hub / github.com/VexDB-THU/VexDB-Lite / floatvector_sub

Function floatvector_sub

vexdb_pg/src/floatvector.cpp:632–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630
631PG_FUNCTION_INFO_V1(floatvector_sub);
632Datum floatvector_sub(PG_FUNCTION_ARGS)
633{
634 FloatVector *a = PG_GETARG_FLOATVECTOR_P(0);
635 FloatVector *b = PG_GETARG_FLOATVECTOR_P(1);
636 CheckDims(a, b);
637 const float *ax = a->x;
638 const float *bx = b->x;
639 FloatVector *result = InitFloatVector(a->dim);
640 float *rx = result->x;
641 for (int16 i = 0, imax = a->dim; i < imax; ++i) {
642 rx[i] = ax[i] - bx[i];
643 }
644 for (int16 i = 0, imax = a->dim; i < imax; ++i) {
645 if (isinf(rx[i])) {
646 float_overflow_error();
647 }
648 }
649
650 PG_RETURN_POINTER(result);
651}
652
653/*
654 * Subtract floatvectors without allocate new floatvector

Callers

nothing calls this directly

Calls 3

CheckDimsFunction · 0.85
InitFloatVectorFunction · 0.85
float_overflow_errorFunction · 0.85

Tested by

no test coverage detected