[linalg.algs.blas1.ssq]

# 29 Numerics library [[numerics]](./#numerics)

## 29.9 Basic linear algebra algorithms [[linalg]](linalg#algs.blas1.ssq)

### 29.9.13 BLAS 1 algorithms [[linalg.algs.blas1]](linalg.algs.blas1#ssq)

#### 29.9.13.8 Scaled sum of squares of a vector's elements [linalg.algs.blas1.ssq]

[ð](#lib:vector_sum_of_squares)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, class Scalar>
  sum_of_squares_result<Scalar> vector_sum_of_squares(InVec v, sum_of_squares_result<Scalar> init);
template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, class Scalar>
  sum_of_squares_result<Scalar> vector_sum_of_squares(ExecutionPolicy&& exec,
                                                      InVec v, sum_of_squares_result<Scalar> init);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13748)

[*Note [1](#note-1)*:

These functions correspond to the LAPACK function xLASSQ[[bib]](bibliography#bib:lapack "Bibliography")[.](#1.sentence-1)

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13753)

*Mandates*: decltype(*abs-if-needed*(declval<typename InVec​::​value_type>())) is convertible to Scalar[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13757)

*Effects*: Returns a value result such that

- [(3.1)](#3.1)

result.scaling_factor is the maximum of init.scaling_factor and*abs-if-needed*(x[i]) for all i in the domain of v; and

- [(3.2)](#3.2)

let s2init beinit.scaling_factor * init.scaling_factor * init.scaled_sum_of_squares then result.scaling_factor * result.scaling_factor * result.scaled_sum_of_squares equals the sum of s2init and
the squares of *abs-if-needed*(x[i]) for all i in the domain of v[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L13776)

*Remarks*: If InVec​::​value_type, and Scalar are all floating-point types or specializations of complex,
and if Scalar has higher precision
than InVec​::​value_type,
then intermediate terms in the sum use Scalar's precision or greater[.](#4.sentence-1)
