Files
cppdraft_translate/cppdraft/linalg/algs/blas1/dot.md
2025-10-25 03:02:53 +03:00

6.8 KiB
Raw Blame History

[linalg.algs.blas1.dot]

29 Numerics library [numerics]

29.9 Basic linear algebra algorithms [linalg]

29.9.13 BLAS 1 algorithms [linalg.algs.blas1]

29.9.13.7 Dot product of two vectors [linalg.algs.blas1.dot]

1

#

[Note 1:

The functions in this section correspond to the BLAS functions xDOT, xDOTU, and xDOTC[bib].

— end note]

2

#

The following elements apply to all functions in [linalg.algs.blas1.dot].

3

#

Mandates: compatible-static-extents<InVec1, InVec2>(0, 0) is true.

4

#

Preconditions: v1.extent(0) equals v2.extent(0).

🔗

template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2, class Scalar> Scalar dot(InVec1 v1, InVec2 v2, Scalar init); template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2, class Scalar> Scalar dot(ExecutionPolicy&& exec, InVec1 v1, InVec2 v2, Scalar init);

5

#

These functions compute a non-conjugated dot product with an explicitly specified result type.

6

#

Returns: Let N be v1.extent(0).

init if N is zero;

otherwise,GENERALIZED_SUM(plus<>(), init, v1[0]*v2[0], …, v1[N-1]*v2[N-1]).

7

#

Remarks: If InVec1::value_type, InVec2::value_type, and Scalar are all floating-point types or specializations of complex, and if Scalar has higher precision than InVec1::value_type or InVec2::value_type, then intermediate terms in the sum use Scalar's precision or greater.

🔗

template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2> auto dot(InVec1 v1, InVec2 v2); template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2> auto dot(ExecutionPolicy&& exec, InVec1 v1, InVec2 v2);

8

#

These functions compute a non-conjugated dot product with a default result type.

9

#

Effects: Let T bedecltype(declval<typename InVec1::value_type>() * declval<typename InVec2::value_type>()).

Then,

the two-parameter overload is equivalent to:return dot(v1, v2, T{}); and

the three-parameter overload is equivalent to:return dot(std::forward(exec), v1, v2, T{});

🔗

template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2, class Scalar> Scalar dotc(InVec1 v1, InVec2 v2, Scalar init); template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2, class Scalar> Scalar dotc(ExecutionPolicy&& exec, InVec1 v1, InVec2 v2, Scalar init);

10

#

These functions compute a conjugated dot product with an explicitly specified result type.

11

#

Effects:

The three-parameter overload is equivalent to:return dot(conjugated(v1), v2, init); and

the four-parameter overload is equivalent to:return dot(std::forward(exec), conjugated(v1), v2, init);

🔗

template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2> auto dotc(InVec1 v1, InVec2 v2); template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5Argument concepts[linalg.helpers.concepts]") InVec2> auto dotc(ExecutionPolicy&& exec, InVec1 v1, InVec2 v2);

12

#

These functions compute a conjugated dot product with a default result type.

13

#

Effects: Let T be decltype(conj-if-needed(declval<typename InVec1::value_type>()) * declval<typename InVec2::value_type>()).

Then,

the two-parameter overload is equivalent to:return dotc(v1, v2, T{}); and

the three-parameter overload is equivalent toreturn dotc(std::forward(exec), v1, v2, T{});