rust_blas/vector/
ll.rs

1// Copyright 2014 Michael Yang. All rights reserved.
2// Use of this source code is governed by a MIT-style
3// license that can be found in the LICENSE file.
4
5//! Bindings for vector functions.
6
7pub mod cblas_s {
8    use libc::{c_float, c_void};
9
10    pub use self::cblas_sasum as asum;
11    pub use self::cblas_saxpy as axpy;
12    pub use self::cblas_scasum as casum;
13    pub use self::cblas_scnrm2 as cnrm2;
14    pub use self::cblas_scopy as copy;
15    pub use self::cblas_sdot as dot;
16    pub use self::cblas_sdsdot as dsdot;
17    pub use self::cblas_snrm2 as nrm2;
18    pub use self::cblas_srot as rot;
19    pub use self::cblas_srotg as rotg;
20    pub use self::cblas_srotm as rotm;
21    pub use self::cblas_srotmg as rotmg;
22    pub use self::cblas_sscal as scal;
23    pub use self::cblas_sswap as swap;
24
25    extern "C" {
26        pub fn cblas_scopy(n: u32, x: *const c_float, inc_x: u32, y: *mut c_float, inc_y: u32);
27        pub fn cblas_saxpy(
28            n: u32,
29            alpha: c_float,
30            x: *const c_float,
31            inc_x: u32,
32            y: *mut c_float,
33            inc_y: u32,
34        );
35        pub fn cblas_sscal(n: u32, alpha: c_float, x: *mut c_float, inc_x: u32);
36        pub fn cblas_sswap(n: u32, x: *mut c_float, inc_x: u32, y: *mut c_float, inc_y: u32);
37        pub fn cblas_sdsdot(
38            n: u32,
39            alpha: c_float,
40            x: *const c_float,
41            inc_x: u32,
42            y: *const c_float,
43            inc_y: u32,
44        ) -> c_float;
45        pub fn cblas_sdot(
46            n: u32,
47            x: *const c_float,
48            inc_x: u32,
49            y: *const c_float,
50            inc_y: u32,
51        ) -> c_float;
52        pub fn cblas_sasum(n: u32, x: *const c_float, inc_x: u32) -> c_float;
53        pub fn cblas_scasum(n: u32, x: *const c_void, inc_x: u32) -> c_float;
54        pub fn cblas_snrm2(n: u32, x: *const c_float, inc_x: u32) -> c_float;
55        pub fn cblas_scnrm2(n: u32, x: *const c_void, inc_x: u32) -> c_float;
56        pub fn cblas_srot(
57            n: u32,
58            x: *mut c_float,
59            inc_x: u32,
60            y: *mut c_float,
61            inc_y: u32,
62            c: c_float,
63            s: c_float,
64        );
65        pub fn cblas_srotm(
66            n: u32,
67            x: *mut c_float,
68            inc_x: u32,
69            y: *mut c_float,
70            inc_y: u32,
71            p: *const c_float,
72        );
73        pub fn cblas_srotg(a: *mut c_float, b: *mut c_float, c: *mut c_float, s: *mut c_float);
74        pub fn cblas_srotmg(
75            d1: *mut c_float,
76            d2: *mut c_float,
77            b1: *mut c_float,
78            b2: c_float,
79            p: *mut c_float,
80        );
81    }
82}
83
84pub mod cblas_d {
85    use libc::{c_double, c_float, c_void};
86
87    pub use self::cblas_dasum as asum;
88    pub use self::cblas_daxpy as axpy;
89    pub use self::cblas_dcopy as copy;
90    pub use self::cblas_ddot as dot;
91    pub use self::cblas_dnrm2 as nrm2;
92    pub use self::cblas_drot as rot;
93    pub use self::cblas_drotg as rotg;
94    pub use self::cblas_drotm as rotm;
95    pub use self::cblas_drotmg as rotmg;
96    pub use self::cblas_dscal as scal;
97    pub use self::cblas_dsdot as dsdot;
98    pub use self::cblas_dswap as swap;
99    pub use self::cblas_dzasum as zasum;
100    pub use self::cblas_dznrm2 as znrm2;
101
102    extern "C" {
103        pub fn cblas_dcopy(n: u32, x: *const c_double, inc_x: u32, y: *mut c_double, inc_y: u32);
104        pub fn cblas_daxpy(
105            n: u32,
106            alpha: c_double,
107            x: *const c_double,
108            inc_x: u32,
109            y: *mut c_double,
110            inc_y: u32,
111        );
112        pub fn cblas_dscal(n: u32, alpha: c_double, x: *mut c_double, inc_x: u32);
113        pub fn cblas_dswap(n: u32, x: *mut c_double, inc_x: u32, y: *mut c_double, inc_y: u32);
114        pub fn cblas_dsdot(
115            n: u32,
116            x: *const c_float,
117            inc_x: u32,
118            y: *const c_float,
119            inc_y: u32,
120        ) -> c_double;
121        pub fn cblas_ddot(
122            n: u32,
123            x: *const c_double,
124            inc_x: u32,
125            y: *const c_double,
126            inc_y: u32,
127        ) -> c_double;
128        pub fn cblas_dasum(n: u32, x: *const c_double, inc_x: u32) -> c_double;
129        pub fn cblas_dzasum(n: u32, x: *const c_void, inc_x: u32) -> c_double;
130        pub fn cblas_dnrm2(n: u32, x: *const c_double, inc_x: u32) -> c_double;
131        pub fn cblas_dznrm2(n: u32, x: *const c_void, inc_x: u32) -> c_double;
132        pub fn cblas_drot(
133            n: u32,
134            x: *mut c_double,
135            inc_x: u32,
136            y: *mut c_double,
137            inc_y: u32,
138            c: c_double,
139            s: c_double,
140        );
141        pub fn cblas_drotm(
142            n: u32,
143            x: *mut c_double,
144            inc_x: u32,
145            y: *mut c_double,
146            inc_y: u32,
147            p: *const c_double,
148        );
149        pub fn cblas_drotg(a: *mut c_double, b: *mut c_double, c: *mut c_double, s: *mut c_double);
150        pub fn cblas_drotmg(
151            d1: *mut c_double,
152            d2: *mut c_double,
153            b1: *mut c_double,
154            b2: c_double,
155            p: *mut c_double,
156        );
157    }
158}
159
160pub mod cblas_c {
161    use libc::{c_float, c_void};
162
163    pub use self::cblas_caxpy as axpy;
164    pub use self::cblas_ccopy as copy;
165    pub use self::cblas_cdotc_sub as dotc_sub;
166    pub use self::cblas_cdotu_sub as dotu_sub;
167    pub use self::cblas_cscal as scal;
168    pub use self::cblas_csscal as sscal;
169    pub use self::cblas_cswap as swap;
170
171    extern "C" {
172        pub fn cblas_ccopy(n: u32, x: *const c_void, inc_x: u32, y: *mut c_void, inc_y: u32);
173        pub fn cblas_caxpy(
174            n: u32,
175            alpha: *const c_void,
176            x: *const c_void,
177            inc_x: u32,
178            y: *mut c_void,
179            inc_y: u32,
180        );
181        pub fn cblas_cscal(n: u32, alpha: *const c_void, x: *mut c_void, inc_x: u32);
182        pub fn cblas_csscal(n: u32, alpha: c_float, x: *mut c_void, inc_x: u32);
183        pub fn cblas_cswap(n: u32, x: *mut c_void, inc_x: u32, y: *mut c_void, inc_y: u32);
184        pub fn cblas_cdotu_sub(
185            n: u32,
186            x: *const c_void,
187            inc_x: u32,
188            y: *const c_void,
189            inc_y: u32,
190            dotu: *mut c_void,
191        );
192        pub fn cblas_cdotc_sub(
193            n: u32,
194            x: *const c_void,
195            inc_x: u32,
196            y: *const c_void,
197            inc_y: u32,
198            dotc: *mut c_void,
199        );
200    }
201}
202
203pub mod cblas_z {
204    use libc::{c_double, c_void};
205
206    pub use self::cblas_zaxpy as axpy;
207    pub use self::cblas_zcopy as copy;
208    pub use self::cblas_zdotc_sub as dotc_sub;
209    pub use self::cblas_zdotu_sub as dotu_sub;
210    pub use self::cblas_zdscal as dscal;
211    pub use self::cblas_zscal as scal;
212    pub use self::cblas_zswap as swap;
213
214    extern "C" {
215        pub fn cblas_zcopy(n: u32, x: *const c_void, inc_x: u32, y: *mut c_void, inc_y: u32);
216        pub fn cblas_zaxpy(
217            n: u32,
218            alpha: *const c_void,
219            x: *const c_void,
220            inc_x: u32,
221            y: *mut c_void,
222            inc_y: u32,
223        );
224        pub fn cblas_zscal(n: u32, alpha: *const c_void, x: *mut c_void, inc_x: u32);
225        pub fn cblas_zdscal(n: u32, alpha: c_double, x: *mut c_void, inc_x: u32);
226        pub fn cblas_zswap(n: u32, x: *mut c_void, inc_x: u32, y: *mut c_void, inc_y: u32);
227        pub fn cblas_zdotu_sub(
228            n: u32,
229            x: *const c_void,
230            inc_x: u32,
231            y: *const c_void,
232            inc_y: u32,
233            dotu: *mut c_void,
234        );
235        pub fn cblas_zdotc_sub(
236            n: u32,
237            x: *const c_void,
238            inc_x: u32,
239            y: *const c_void,
240            inc_y: u32,
241            dotc: *mut c_void,
242        );
243    }
244}
245
246pub mod cblas_i {
247    use libc::{c_double, c_float, c_void, size_t};
248
249    pub use self::cblas_icamax as camax;
250    pub use self::cblas_idamax as damax;
251    pub use self::cblas_isamax as samax;
252    pub use self::cblas_izamax as zamax;
253
254    extern "C" {
255        pub fn cblas_isamax(n: u32, x: *const c_float, inc_x: u32) -> size_t;
256        pub fn cblas_idamax(n: u32, x: *const c_double, inc_x: u32) -> size_t;
257        pub fn cblas_icamax(n: u32, x: *const c_void, inc_x: u32) -> size_t;
258        pub fn cblas_izamax(n: u32, x: *const c_void, inc_x: u32) -> size_t;
259    }
260}