C++ · Dot Products

Dot Products

#include <numkong/dot.hpp> 8.0.0-rc.1 · b1f866ab

Dot products are one of the broadest parts of the native SDK. They include real, complex, packed-binary, mini-float, and mixed-precision forms.

nk_f32c_t a[384];
nk_f32c_t b[384];
nk_f64c_t out = {0, 0};         // widened f32c → f64c output

nk_dot_f32c_best(a, b, 384, &out, capabilities, NULL);   // complex inner product
nk_vdot_f32c_best(a, b, 384, &out, capabilities, NULL);  // conjugated variant, like numpy.vdot

For quantized retrieval pipelines, the storage format often matters more than the nominal math family. The native SDK lets you keep the compact representation and still get a widened output.

API

Functions

dot⟨a,b⟩ over two runs of in_type_ with equal dimensions; unexpected_dimensions_k when they differ or either run is strided or ends mid-value.
dot.hpp:100 ↗
template <numeric_dtype in_type_, numeric_dtype result_type_ = typename in_type_::dot_result_t, vector_of<in_type_> a_type_, vector_of<in_type_> b_type_>
expected<result_type_> dot(
    a_type_ const & a,
    b_type_ const & b,
    nk_capability_t capabilities = default_capabilities()) noexcept;
vdotConjugated ⟨a,b⟩ over two complex runs, failing like the concept dot.
dot.hpp:116 ↗
template <numeric_dtype in_type_, numeric_dtype result_type_ = typename in_type_::dot_result_t, vector_of<in_type_> a_type_, vector_of<in_type_> b_type_>
expected<result_type_> vdot(
    a_type_ const & a,
    b_type_ const & b,
    nk_capability_t capabilities = default_capabilities()) noexcept;