mdarray_linalg_blas/matmul/
scalar.rs

1// This file is auto-generated. Do not edit manually.
2//! Abstracting the BLAS scalar types
3use cblas_sys::{CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_SIDE, CBLAS_UPLO, CBLAS_DIAG};
4use num_complex::{Complex, ComplexFloat};
5
6#[allow(clippy::too_many_arguments, unused_variables)]
7pub trait BlasScalar: Sized + ComplexFloat {
8    
9    /// # Safety
10    /// Calls must respect BLAS conventions.
11    unsafe fn cblas_gemm(
12         layout: CBLAS_LAYOUT,
13         transa: CBLAS_TRANSPOSE,
14         transb: CBLAS_TRANSPOSE,
15         m: i32,
16         n: i32,
17         k: i32,
18         alpha: Self,
19         a: *const Self,
20         lda: i32,
21         b: *const Self,
22         ldb: i32,
23         beta: Self,
24         c: *mut Self,
25         ldc: i32
26         ) where Self: Sized {unimplemented!("")}
27    /// # Safety
28    /// Calls must respect BLAS conventions.
29    unsafe fn cblas_symm(
30         layout: CBLAS_LAYOUT,
31         side: CBLAS_SIDE,
32         uplo: CBLAS_UPLO,
33         m: i32,
34         n: i32,
35         alpha: Self,
36         a: *const Self,
37         lda: i32,
38         b: *const Self,
39         ldb: i32,
40         beta: Self,
41         c: *mut Self,
42         ldc: i32
43         ) where Self: Sized {unimplemented!("")}
44    /// # Safety
45    /// Calls must respect BLAS conventions.
46    unsafe fn cblas_trmm(
47         layout: CBLAS_LAYOUT,
48         side: CBLAS_SIDE,
49         uplo: CBLAS_UPLO,
50         transa: CBLAS_TRANSPOSE,
51         diag: CBLAS_DIAG,
52         m: i32,
53         n: i32,
54         alpha: Self,
55         a: *const Self,
56         lda: i32,
57         b: *mut Self,
58         ldb: i32
59         ) where Self: Sized {unimplemented!("")}
60    /// # Safety
61    /// Calls must respect BLAS conventions.
62    unsafe fn cblas_hemm(
63         layout: CBLAS_LAYOUT,
64         side: CBLAS_SIDE,
65         uplo: CBLAS_UPLO,
66         m: i32,
67         n: i32,
68         alpha: Self,
69         a: *const Self,
70         lda: i32,
71         b: *const Self,
72         ldb: i32,
73         beta: Self,
74         c: *mut Self,
75         ldc: i32
76         ) where Self: Sized {unimplemented!("")}
77}
78
79impl BlasScalar for f32 {
80    
81    unsafe fn cblas_gemm(
82	layout: CBLAS_LAYOUT,
83        transa: CBLAS_TRANSPOSE,
84        transb: CBLAS_TRANSPOSE,
85        m: i32,
86        n: i32,
87        k: i32,
88        alpha: f32,
89        a: *const f32,
90        lda: i32,
91        b: *const f32,
92        ldb: i32,
93        beta: f32,
94        c: *mut f32,
95        ldc: i32
96        ) {
97        unsafe {
98            cblas_sys::cblas_sgemm(
99		layout,
100                transa,
101                transb,
102                m,
103                n,
104                k,
105                alpha,
106                a as *const _,
107                lda,
108                b as *const _,
109                ldb,
110                beta,
111                c as *mut _,
112                ldc
113                )
114        }
115    }
116    
117    unsafe fn cblas_symm(
118	layout: CBLAS_LAYOUT,
119        side: CBLAS_SIDE,
120        uplo: CBLAS_UPLO,
121        m: i32,
122        n: i32,
123        alpha: f32,
124        a: *const f32,
125        lda: i32,
126        b: *const f32,
127        ldb: i32,
128        beta: f32,
129        c: *mut f32,
130        ldc: i32
131        ) {
132        unsafe {
133            cblas_sys::cblas_ssymm(
134		layout,
135                side,
136                uplo,
137                m,
138                n,
139                alpha,
140                a as *const _,
141                lda,
142                b as *const _,
143                ldb,
144                beta,
145                c as *mut _,
146                ldc
147                )
148        }
149    }
150    
151    unsafe fn cblas_trmm(
152	layout: CBLAS_LAYOUT,
153        side: CBLAS_SIDE,
154        uplo: CBLAS_UPLO,
155        transa: CBLAS_TRANSPOSE,
156        diag: CBLAS_DIAG,
157        m: i32,
158        n: i32,
159        alpha: f32,
160        a: *const f32,
161        lda: i32,
162        b: *mut f32,
163        ldb: i32
164        ) {
165        unsafe {
166            cblas_sys::cblas_strmm(
167		layout,
168                side,
169                uplo,
170                transa,
171                diag,
172                m,
173                n,
174                alpha,
175                a as *const _,
176                lda,
177                b as *mut _,
178                ldb
179                )
180        }
181    }
182    
183}
184
185impl BlasScalar for f64 {
186    
187    unsafe fn cblas_gemm(
188	layout: CBLAS_LAYOUT,
189        transa: CBLAS_TRANSPOSE,
190        transb: CBLAS_TRANSPOSE,
191        m: i32,
192        n: i32,
193        k: i32,
194        alpha: f64,
195        a: *const f64,
196        lda: i32,
197        b: *const f64,
198        ldb: i32,
199        beta: f64,
200        c: *mut f64,
201        ldc: i32
202        ) {
203        unsafe {
204            cblas_sys::cblas_dgemm(
205		layout,
206                transa,
207                transb,
208                m,
209                n,
210                k,
211                alpha,
212                a as *const _,
213                lda,
214                b as *const _,
215                ldb,
216                beta,
217                c as *mut _,
218                ldc
219                )
220        }
221    }
222    
223    unsafe fn cblas_symm(
224	layout: CBLAS_LAYOUT,
225        side: CBLAS_SIDE,
226        uplo: CBLAS_UPLO,
227        m: i32,
228        n: i32,
229        alpha: f64,
230        a: *const f64,
231        lda: i32,
232        b: *const f64,
233        ldb: i32,
234        beta: f64,
235        c: *mut f64,
236        ldc: i32
237        ) {
238        unsafe {
239            cblas_sys::cblas_dsymm(
240		layout,
241                side,
242                uplo,
243                m,
244                n,
245                alpha,
246                a as *const _,
247                lda,
248                b as *const _,
249                ldb,
250                beta,
251                c as *mut _,
252                ldc
253                )
254        }
255    }
256    
257    unsafe fn cblas_trmm(
258	layout: CBLAS_LAYOUT,
259        side: CBLAS_SIDE,
260        uplo: CBLAS_UPLO,
261        transa: CBLAS_TRANSPOSE,
262        diag: CBLAS_DIAG,
263        m: i32,
264        n: i32,
265        alpha: f64,
266        a: *const f64,
267        lda: i32,
268        b: *mut f64,
269        ldb: i32
270        ) {
271        unsafe {
272            cblas_sys::cblas_dtrmm(
273		layout,
274                side,
275                uplo,
276                transa,
277                diag,
278                m,
279                n,
280                alpha,
281                a as *const _,
282                lda,
283                b as *mut _,
284                ldb
285                )
286        }
287    }
288    
289}
290
291impl BlasScalar for Complex<f32> {
292    
293    unsafe fn cblas_gemm(
294	layout: CBLAS_LAYOUT,
295        transa: CBLAS_TRANSPOSE,
296        transb: CBLAS_TRANSPOSE,
297        m: i32,
298        n: i32,
299        k: i32,
300        alpha: Complex<f32>,
301        a: *const Complex<f32>,
302        lda: i32,
303        b: *const Complex<f32>,
304        ldb: i32,
305        beta: Complex<f32>,
306        c: *mut Complex<f32>,
307        ldc: i32
308        ) {
309        unsafe {
310            cblas_sys::cblas_cgemm(
311		layout,
312                transa,
313                transb,
314                m,
315                n,
316                k,
317                &alpha as *const _ as *const _,
318                a as *const _,
319                lda,
320                b as *const _,
321                ldb,
322                &beta as *const _ as *const _,
323                c as *mut _,
324                ldc
325                )
326        }
327    }
328    
329    unsafe fn cblas_symm(
330	layout: CBLAS_LAYOUT,
331        side: CBLAS_SIDE,
332        uplo: CBLAS_UPLO,
333        m: i32,
334        n: i32,
335        alpha: Complex<f32>,
336        a: *const Complex<f32>,
337        lda: i32,
338        b: *const Complex<f32>,
339        ldb: i32,
340        beta: Complex<f32>,
341        c: *mut Complex<f32>,
342        ldc: i32
343        ) {
344        unsafe {
345            cblas_sys::cblas_csymm(
346		layout,
347                side,
348                uplo,
349                m,
350                n,
351                &alpha as *const _ as *const _,
352                a as *const _,
353                lda,
354                b as *const _,
355                ldb,
356                &beta as *const _ as *const _,
357                c as *mut _,
358                ldc
359                )
360        }
361    }
362    
363    unsafe fn cblas_trmm(
364	layout: CBLAS_LAYOUT,
365        side: CBLAS_SIDE,
366        uplo: CBLAS_UPLO,
367        transa: CBLAS_TRANSPOSE,
368        diag: CBLAS_DIAG,
369        m: i32,
370        n: i32,
371        alpha: Complex<f32>,
372        a: *const Complex<f32>,
373        lda: i32,
374        b: *mut Complex<f32>,
375        ldb: i32
376        ) {
377        unsafe {
378            cblas_sys::cblas_ctrmm(
379		layout,
380                side,
381                uplo,
382                transa,
383                diag,
384                m,
385                n,
386                &alpha as *const _ as *const _,
387                a as *const _,
388                lda,
389                b as *mut _,
390                ldb
391                )
392        }
393    }
394    
395    unsafe fn cblas_hemm(
396	layout: CBLAS_LAYOUT,
397        side: CBLAS_SIDE,
398        uplo: CBLAS_UPLO,
399        m: i32,
400        n: i32,
401        alpha: Complex<f32>,
402        a: *const Complex<f32>,
403        lda: i32,
404        b: *const Complex<f32>,
405        ldb: i32,
406        beta: Complex<f32>,
407        c: *mut Complex<f32>,
408        ldc: i32
409        ) {
410        unsafe {
411            cblas_sys::cblas_chemm(
412		layout,
413                side,
414                uplo,
415                m,
416                n,
417                &alpha as *const _ as *const _,
418                a as *const _,
419                lda,
420                b as *const _,
421                ldb,
422                &beta as *const _ as *const _,
423                c as *mut _,
424                ldc
425                )
426        }
427    }
428    
429}
430
431impl BlasScalar for Complex<f64> {
432    
433    unsafe fn cblas_gemm(
434	layout: CBLAS_LAYOUT,
435        transa: CBLAS_TRANSPOSE,
436        transb: CBLAS_TRANSPOSE,
437        m: i32,
438        n: i32,
439        k: i32,
440        alpha: Complex<f64>,
441        a: *const Complex<f64>,
442        lda: i32,
443        b: *const Complex<f64>,
444        ldb: i32,
445        beta: Complex<f64>,
446        c: *mut Complex<f64>,
447        ldc: i32
448        ) {
449        unsafe {
450            cblas_sys::cblas_zgemm(
451		layout,
452                transa,
453                transb,
454                m,
455                n,
456                k,
457                &alpha as *const _ as *const _,
458                a as *const _,
459                lda,
460                b as *const _,
461                ldb,
462                &beta as *const _ as *const _,
463                c as *mut _,
464                ldc
465                )
466        }
467    }
468    
469    unsafe fn cblas_symm(
470	layout: CBLAS_LAYOUT,
471        side: CBLAS_SIDE,
472        uplo: CBLAS_UPLO,
473        m: i32,
474        n: i32,
475        alpha: Complex<f64>,
476        a: *const Complex<f64>,
477        lda: i32,
478        b: *const Complex<f64>,
479        ldb: i32,
480        beta: Complex<f64>,
481        c: *mut Complex<f64>,
482        ldc: i32
483        ) {
484        unsafe {
485            cblas_sys::cblas_zsymm(
486		layout,
487                side,
488                uplo,
489                m,
490                n,
491                &alpha as *const _ as *const _,
492                a as *const _,
493                lda,
494                b as *const _,
495                ldb,
496                &beta as *const _ as *const _,
497                c as *mut _,
498                ldc
499                )
500        }
501    }
502    
503    unsafe fn cblas_trmm(
504	layout: CBLAS_LAYOUT,
505        side: CBLAS_SIDE,
506        uplo: CBLAS_UPLO,
507        transa: CBLAS_TRANSPOSE,
508        diag: CBLAS_DIAG,
509        m: i32,
510        n: i32,
511        alpha: Complex<f64>,
512        a: *const Complex<f64>,
513        lda: i32,
514        b: *mut Complex<f64>,
515        ldb: i32
516        ) {
517        unsafe {
518            cblas_sys::cblas_ztrmm(
519		layout,
520                side,
521                uplo,
522                transa,
523                diag,
524                m,
525                n,
526                &alpha as *const _ as *const _,
527                a as *const _,
528                lda,
529                b as *mut _,
530                ldb
531                )
532        }
533    }
534    
535    unsafe fn cblas_hemm(
536	layout: CBLAS_LAYOUT,
537        side: CBLAS_SIDE,
538        uplo: CBLAS_UPLO,
539        m: i32,
540        n: i32,
541        alpha: Complex<f64>,
542        a: *const Complex<f64>,
543        lda: i32,
544        b: *const Complex<f64>,
545        ldb: i32,
546        beta: Complex<f64>,
547        c: *mut Complex<f64>,
548        ldc: i32
549        ) {
550        unsafe {
551            cblas_sys::cblas_zhemm(
552		layout,
553                side,
554                uplo,
555                m,
556                n,
557                &alpha as *const _ as *const _,
558                a as *const _,
559                lda,
560                b as *const _,
561                ldb,
562                &beta as *const _ as *const _,
563                c as *mut _,
564                ldc
565                )
566        }
567    }
568    
569}