rusoda/blas/dscal.rs
1/// Scalar vector multiplication
2#[no_mangle]
3#[inline(always)]
4pub fn dscal(dx: &mut [f64], n: usize, incx: usize, da: &f64) {
5 /*
6 Purpose : scalar vector multiplication
7
8 dx = da * dx
9
10
11 --- Input ---
12
13 n : number of elements in input vector
14 da : double scale factor
15 dx : double vector with n+1 elements, dx[0] is not used
16 incx : storage spacing between elements of dx
17
18
19 --- Output ---
20
21 dx = da * dx, unchanged if n <= 0
22
23
24 For i = 0 to n-1, replace dx[1+i*incx] with
25 da * dx[1+i*incx].
26
27 */
28 /* Code for increments not equal to 1. */
29 if incx != 0 {
30 for i in (1..n * incx + 1).step_by(incx) {
31 dx[i] *= da;
32 }
33 return;
34 }
35 /* Code for increments not equal to 1. */
36 let m = n % 4;
37 if m != 0 {
38 for i in 1..m + 1 {
39 dx[i] *= da;
40 }
41 if n < 4 {
42 return;
43 }
44 }
45 for i in (m + 1..n + 1).step_by(4) {
46 dx[i] *= da;
47 dx[i + 1] *= da;
48 dx[i + 2] *= da;
49 dx[i + 3] *= da;
50 }
51}