[linalg.scaled.scaled]

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

## 29.9 Basic linear algebra algorithms [[linalg]](linalg#scaled.scaled)

### 29.9.8 Scaled in-place transformation [[linalg.scaled]](linalg.scaled#scaled)

#### 29.9.8.3 Function template scaled [linalg.scaled.scaled]

[1](#1)

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

The scaled function template takes
a scaling factor alpha and
an mdspan x, and
returns a new read-only mdspan with the same domain as x,
that represents the elementwise product of alpha with each element of x[.](#1.sentence-1)

[ð](#lib:scaled)

`  template<class ScalingFactor,
           class ElementType, class Extents, class Layout, class Accessor>
    constexpr auto scaled(ScalingFactor alpha, mdspan<ElementType, Extents, Layout, Accessor> x);
`

[2](#2)

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

Let SA be scaled_accessor<ScalingFactor, Accessor>[.](#2.sentence-1)

[3](#3)

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

*Returns*: mdspan<typename SA::element_type, Extents, Layout, SA>(x.data_handle(), x.mapping(),
 SA(alpha, x.accessor()))

[4](#4)

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

[*Example [1](#example-1)*: void test_scaled(mdspan<double, extents<int, 10>> x){auto x_scaled = scaled(5.0, x); for (int i = 0; i < x.extent(0); ++i) { assert(x_scaled[i] == 5.0 * x[i]); }} â *end example*]
