@stdlib/blas-base-cswap 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/blas/base/cswap.h"
20
+ #include "stdlib/blas/base/shared.h"
21
+
22
+ /**
23
+ * Interchanges two complex single-precision floating-point vectors.
24
+ *
25
+ * @param N number of indexed elements
26
+ * @param X first input array
27
+ * @param strideX X stride length
28
+ * @param offsetX starting index for X
29
+ * @param Y second input array
30
+ * @param strideY Y stride length
31
+ * @param offsetY starting index for Y
32
+ */
33
+ void API_SUFFIX(c_cswap_ndarray)( const CBLAS_INT N, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
34
+ float *x = (float *)X;
35
+ float *y = (float *)Y;
36
+ float tmp;
37
+ CBLAS_INT ix;
38
+ CBLAS_INT iy;
39
+ CBLAS_INT sx;
40
+ CBLAS_INT sy;
41
+ CBLAS_INT i;
42
+
43
+ if ( N <= 0 ) {
44
+ return;
45
+ }
46
+ ix = offsetX * 2;
47
+ iy = offsetY * 2;
48
+ sx = strideX * 2;
49
+ sy = strideY * 2;
50
+ for ( i = 0; i < N; i++ ) {
51
+ tmp = x[ ix ];
52
+ x[ ix ] = y[ iy ];
53
+ y[ iy ] = tmp;
54
+
55
+ tmp = x[ ix+1 ];
56
+ x[ ix+1 ] = y[ iy+1 ];
57
+ y[ iy+1 ] = tmp;
58
+
59
+ ix += sx;
60
+ iy += sy;
61
+ }
62
+ return;
63
+ }