# blaze / Scalar Multiplication

The scalar multiplication is the multiplication of vector or a matrix with a scalar value. Alternatively it is also possible to divide a vector or a matrix by a scalar value. In Blaze it is possible to use all built-in/fundamental data types except bool as scalar values. Additionally, it is possible to use `std::complex` values with the same built-in data types as element type.

```blaze::StaticVector<int,3UL> v1{ 1, 2, 3 };

blaze::DynamicVector<double>   v2 = v1 * 1.2;    // Scalar multiplication
blaze::CompressedVector<float> v3 = -0.3F * v1;  // Scalar multiplication
blaze::DynamicVector<double>   v4 = v1 / 1.2;    // Scalar division
blaze::CompressedVector<float> v5 = 12.0F / v1;  // Scalar division (only dense vectors)
```
```blaze::StaticMatrix<int,3UL,2UL> M1{ { 1, 2 }, { 3, 4 }, { 5, 6 } };

blaze::DynamicMatrix<double>   M2 = M1 * 1.2;    // Scalar multiplication
blaze::CompressedMatrix<float> M3 = -0.3F * M1;  // Scalar multiplication
blaze::DynamicMatrix<double>   M4 = M1 / 1.2;    // Scalar division
blaze::CompressedMatrix<float> M5 = 12.0F / M1;  // Scalar division (only dense matrices)
```

Vectors and matrices cannot be used for as scalar value for scalar multiplications or divisions (see the following example). However, each vector and matrix provides the `scale()` function, which can be used to scale a vector or matrix element-wise with arbitrary scalar data types:

```blaze::CompressedMatrix< blaze::StaticMatrix<int,3UL,3UL> > M1;
blaze::StaticMatrix<int,3UL,3UL> scalar;

M1 * scalar;  // No scalar multiplication, but matrix/matrix multiplication

M1.scale( scalar );  // Scalar multiplication
```

Previous: Subtraction ---- Next: Vector/Vector Multiplication

Updated