mdarray_linalg_blas/matvec/
scalar.rs

1//! Abstracting the BLAS scalar types
2use cblas_sys::{CBLAS_DIAG, CBLAS_INDEX, CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_UPLO};
3use num_complex::{Complex, ComplexFloat};
4
5#[allow(clippy::too_many_arguments, unused_variables)]
6pub trait BlasScalar: Sized + ComplexFloat {
7    /// # Safety
8    /// Calls must respect BLAS conventions.
9    unsafe fn cblas_amax(n: i32, x: *const Self, incx: i32) -> CBLAS_INDEX
10    where
11        Self: Sized,
12    {
13        unimplemented!("")
14    }
15
16    /// # Safety
17    /// Calls must respect BLAS conventions.
18    unsafe fn cblas_dot(n: i32, x: *const Self, incx: i32, y: *const Self, incy: i32) -> Self
19    where
20        Self: Sized,
21    {
22        unimplemented!("")
23    }
24    /// # Safety
25    /// Calls must respect BLAS conventions.
26    unsafe fn cblas_dotu_sub(
27        n: i32,
28        x: *const Self,
29        incx: i32,
30        y: *const Self,
31        incy: i32,
32        dotu: *mut Self,
33    ) where
34        Self: Sized,
35    {
36        unimplemented!("")
37    }
38    /// # Safety
39    /// Calls must respect BLAS conventions.
40    unsafe fn cblas_dotc_sub(
41        n: i32,
42        x: *const Self,
43        incx: i32,
44        y: *const Self,
45        incy: i32,
46        dotc: *mut Self,
47    ) where
48        Self: Sized,
49    {
50        unimplemented!("")
51    }
52    /// # Safety
53    /// Calls must respect BLAS conventions.
54    unsafe fn cblas_nrm2(n: i32, x: *const Self, incx: i32) -> Self::Real
55    where
56        Self: Sized,
57    {
58        unimplemented!("")
59    }
60    /// # Safety
61    /// Calls must respect BLAS conventions.
62    unsafe fn cblas_asum(n: i32, x: *const Self, incx: i32) -> Self::Real
63    where
64        Self: Sized,
65    {
66        unimplemented!("")
67    }
68    /// # Safety
69    /// Calls must respect BLAS conventions.
70    unsafe fn cblas_swap(n: i32, x: *mut Self, incx: i32, y: *mut Self, incy: i32)
71    where
72        Self: Sized,
73    {
74        unimplemented!("")
75    }
76    /// # Safety
77    /// Calls must respect BLAS conventions.
78    unsafe fn cblas_copy(n: i32, x: *const Self, incx: i32, y: *mut Self, incy: i32)
79    where
80        Self: Sized,
81    {
82        unimplemented!("")
83    }
84    /// # Safety
85    /// Calls must respect BLAS conventions.
86    unsafe fn cblas_axpy(n: i32, alpha: Self, x: *const Self, incx: i32, y: *mut Self, incy: i32)
87    where
88        Self: Sized,
89    {
90        unimplemented!("")
91    }
92    /// # Safety
93    /// Calls must respect BLAS conventions.
94    unsafe fn cblas_scal(n: i32, alpha: Self, x: *mut Self, incx: i32)
95    where
96        Self: Sized,
97    {
98        unimplemented!("")
99    }
100    /// # Safety
101    /// Calls must respect BLAS conventions.
102    unsafe fn cblas_rscal(n: i32, alpha: Self::Real, x: *mut Self, incx: i32)
103    where
104        Self: Sized,
105    {
106        unimplemented!("")
107    }
108    /// # Safety
109    /// Calls must respect BLAS conventions.
110    unsafe fn cblas_gemv(
111        layout: CBLAS_LAYOUT,
112        transa: CBLAS_TRANSPOSE,
113        m: i32,
114        n: i32,
115        alpha: Self,
116        a: *const Self,
117        lda: i32,
118        x: *const Self,
119        incx: i32,
120        beta: Self,
121        y: *mut Self,
122        incy: i32,
123    ) where
124        Self: Sized,
125    {
126        unimplemented!("")
127    }
128    /// # Safety
129    /// Calls must respect BLAS conventions.
130    unsafe fn cblas_trmv(
131        layout: CBLAS_LAYOUT,
132        uplo: CBLAS_UPLO,
133        transa: CBLAS_TRANSPOSE,
134        diag: CBLAS_DIAG,
135        n: i32,
136        a: *const Self,
137        lda: i32,
138        x: *mut Self,
139        incx: i32,
140    ) where
141        Self: Sized,
142    {
143        unimplemented!("")
144    }
145    /// # Safety
146    /// Calls must respect BLAS conventions.
147    unsafe fn cblas_symv(
148        layout: CBLAS_LAYOUT,
149        uplo: CBLAS_UPLO,
150        n: i32,
151        alpha: Self,
152        a: *const Self,
153        lda: i32,
154        x: *const Self,
155        incx: i32,
156        beta: Self,
157        y: *mut Self,
158        incy: i32,
159    ) where
160        Self: Sized,
161    {
162        unimplemented!("")
163    }
164    /// # Safety
165    /// Calls must respect BLAS conventions.
166    unsafe fn cblas_ger(
167        layout: CBLAS_LAYOUT,
168        m: i32,
169        n: i32,
170        alpha: Self,
171        x: *const Self,
172        incx: i32,
173        y: *const Self,
174        incy: i32,
175        a: *mut Self,
176        lda: i32,
177    ) where
178        Self: Sized,
179    {
180        unimplemented!("")
181    }
182    /// # Safety
183    /// Calls must respect BLAS conventions.
184    unsafe fn cblas_syr(
185        layout: CBLAS_LAYOUT,
186        uplo: CBLAS_UPLO,
187        n: i32,
188        alpha: Self,
189        x: *const Self,
190        incx: i32,
191        a: *mut Self,
192        lda: i32,
193    ) where
194        Self: Sized,
195    {
196        unimplemented!("")
197    }
198    /// # Safety
199    /// Calls must respect BLAS conventions.
200    unsafe fn cblas_syr2(
201        layout: CBLAS_LAYOUT,
202        uplo: CBLAS_UPLO,
203        n: i32,
204        alpha: Self,
205        x: *const Self,
206        incx: i32,
207        y: *const Self,
208        incy: i32,
209        a: *mut Self,
210        lda: i32,
211    ) where
212        Self: Sized,
213    {
214        unimplemented!("")
215    }
216    /// # Safety
217    /// Calls must respect BLAS conventions.
218    unsafe fn cblas_geru(
219        layout: CBLAS_LAYOUT,
220        m: i32,
221        n: i32,
222        alpha: Self,
223        x: *const Self,
224        incx: i32,
225        y: *const Self,
226        incy: i32,
227        a: *mut Self,
228        lda: i32,
229    ) where
230        Self: Sized,
231    {
232        unimplemented!("")
233    }
234    /// # Safety
235    /// Calls must respect BLAS conventions.
236    unsafe fn cblas_gerc(
237        layout: CBLAS_LAYOUT,
238        m: i32,
239        n: i32,
240        alpha: Self,
241        x: *const Self,
242        incx: i32,
243        y: *const Self,
244        incy: i32,
245        a: *mut Self,
246        lda: i32,
247    ) where
248        Self: Sized,
249    {
250        unimplemented!("")
251    }
252    /// # Safety
253    /// Calls must respect BLAS conventions.
254    unsafe fn cblas_her(
255        layout: CBLAS_LAYOUT,
256        uplo: CBLAS_UPLO,
257        n: i32,
258        alpha: Self::Real,
259        x: *const Self,
260        incx: i32,
261        a: *mut Self,
262        lda: i32,
263    ) where
264        Self: Sized,
265    {
266        unimplemented!("")
267    }
268    /// # Safety
269    /// Calls must respect BLAS conventions.
270    unsafe fn cblas_her2(
271        layout: CBLAS_LAYOUT,
272        uplo: CBLAS_UPLO,
273        n: i32,
274        alpha: Self,
275        x: *const Self,
276        incx: i32,
277        y: *const Self,
278        incy: i32,
279        a: *mut Self,
280        lda: i32,
281    ) where
282        Self: Sized,
283    {
284        unimplemented!("")
285    }
286    /// # Safety
287    /// Calls must respect BLAS conventions.
288    unsafe fn cblas_syrk(
289        layout: CBLAS_LAYOUT,
290        uplo: CBLAS_UPLO,
291        trans: CBLAS_TRANSPOSE,
292        n: i32,
293        k: i32,
294        alpha: Self,
295        a: *const Self,
296        lda: i32,
297        beta: Self,
298        c: *mut Self,
299        ldc: i32,
300    ) where
301        Self: Sized,
302    {
303        unimplemented!("")
304    }
305    /// # Safety
306    /// Calls must respect BLAS conventions.
307    unsafe fn cblas_syr2k(
308        layout: CBLAS_LAYOUT,
309        uplo: CBLAS_UPLO,
310        trans: CBLAS_TRANSPOSE,
311        n: i32,
312        k: i32,
313        alpha: Self,
314        a: *const Self,
315        lda: i32,
316        b: *const Self,
317        ldb: i32,
318        beta: Self,
319        c: *mut Self,
320        ldc: i32,
321    ) where
322        Self: Sized,
323    {
324        unimplemented!("")
325    }
326    /// # Safety
327    /// Calls must respect BLAS conventions.
328    unsafe fn cblas_herk(
329        layout: CBLAS_LAYOUT,
330        uplo: CBLAS_UPLO,
331        trans: CBLAS_TRANSPOSE,
332        n: i32,
333        k: i32,
334        alpha: Self::Real,
335        a: *const Self,
336        lda: i32,
337        beta: Self::Real,
338        c: *mut Self,
339        ldc: i32,
340    ) where
341        Self: Sized,
342    {
343        unimplemented!("")
344    }
345    /// # Safety
346    /// Calls must respect BLAS conventions.
347    unsafe fn cblas_her2k(
348        layout: CBLAS_LAYOUT,
349        uplo: CBLAS_UPLO,
350        trans: CBLAS_TRANSPOSE,
351        n: i32,
352        k: i32,
353        alpha: Self,
354        a: *const Self,
355        lda: i32,
356        b: *const Self,
357        ldb: i32,
358        beta: Self::Real,
359        c: *mut Self,
360        ldc: i32,
361    ) where
362        Self: Sized,
363    {
364        unimplemented!("")
365    }
366}
367
368impl BlasScalar for f32 {
369    unsafe fn cblas_amax(n: i32, x: *const f32, incx: i32) -> CBLAS_INDEX {
370        unsafe { cblas_sys::cblas_isamax(n, x as *const _, incx) }
371    }
372
373    unsafe fn cblas_dot(n: i32, x: *const f32, incx: i32, y: *const f32, incy: i32) -> f32 {
374        unsafe { cblas_sys::cblas_sdot(n, x as *const _, incx, y as *const _, incy) }
375    }
376
377    unsafe fn cblas_nrm2(n: i32, x: *const f32, incx: i32) -> f32 {
378        unsafe { cblas_sys::cblas_snrm2(n, x as *const _, incx) }
379    }
380
381    unsafe fn cblas_asum(n: i32, x: *const f32, incx: i32) -> f32 {
382        unsafe { cblas_sys::cblas_sasum(n, x as *const _, incx) }
383    }
384
385    unsafe fn cblas_swap(n: i32, x: *mut f32, incx: i32, y: *mut f32, incy: i32) {
386        unsafe { cblas_sys::cblas_sswap(n, x as *mut _, incx, y as *mut _, incy) }
387    }
388
389    unsafe fn cblas_copy(n: i32, x: *const f32, incx: i32, y: *mut f32, incy: i32) {
390        unsafe { cblas_sys::cblas_scopy(n, x as *const _, incx, y as *mut _, incy) }
391    }
392
393    unsafe fn cblas_axpy(n: i32, alpha: f32, x: *const f32, incx: i32, y: *mut f32, incy: i32) {
394        unsafe { cblas_sys::cblas_saxpy(n, alpha, x as *const _, incx, y as *mut _, incy) }
395    }
396
397    unsafe fn cblas_scal(n: i32, alpha: f32, x: *mut f32, incx: i32) {
398        unsafe { cblas_sys::cblas_sscal(n, alpha, x as *mut _, incx) }
399    }
400
401    unsafe fn cblas_gemv(
402        layout: CBLAS_LAYOUT,
403        transa: CBLAS_TRANSPOSE,
404        m: i32,
405        n: i32,
406        alpha: f32,
407        a: *const f32,
408        lda: i32,
409        x: *const f32,
410        incx: i32,
411        beta: f32,
412        y: *mut f32,
413        incy: i32,
414    ) {
415        unsafe {
416            cblas_sys::cblas_sgemv(
417                layout,
418                transa,
419                m,
420                n,
421                alpha,
422                a as *const _,
423                lda,
424                x as *const _,
425                incx,
426                beta,
427                y as *mut _,
428                incy,
429            )
430        }
431    }
432
433    unsafe fn cblas_trmv(
434        layout: CBLAS_LAYOUT,
435        uplo: CBLAS_UPLO,
436        transa: CBLAS_TRANSPOSE,
437        diag: CBLAS_DIAG,
438        n: i32,
439        a: *const f32,
440        lda: i32,
441        x: *mut f32,
442        incx: i32,
443    ) {
444        unsafe {
445            cblas_sys::cblas_strmv(
446                layout,
447                uplo,
448                transa,
449                diag,
450                n,
451                a as *const _,
452                lda,
453                x as *mut _,
454                incx,
455            )
456        }
457    }
458
459    unsafe fn cblas_symv(
460        layout: CBLAS_LAYOUT,
461        uplo: CBLAS_UPLO,
462        n: i32,
463        alpha: f32,
464        a: *const f32,
465        lda: i32,
466        x: *const f32,
467        incx: i32,
468        beta: f32,
469        y: *mut f32,
470        incy: i32,
471    ) {
472        unsafe {
473            cblas_sys::cblas_ssymv(
474                layout,
475                uplo,
476                n,
477                alpha,
478                a as *const _,
479                lda,
480                x as *const _,
481                incx,
482                beta,
483                y as *mut _,
484                incy,
485            )
486        }
487    }
488
489    unsafe fn cblas_ger(
490        layout: CBLAS_LAYOUT,
491        m: i32,
492        n: i32,
493        alpha: f32,
494        x: *const f32,
495        incx: i32,
496        y: *const f32,
497        incy: i32,
498        a: *mut f32,
499        lda: i32,
500    ) {
501        unsafe {
502            cblas_sys::cblas_sger(
503                layout,
504                m,
505                n,
506                alpha,
507                x as *const _,
508                incx,
509                y as *const _,
510                incy,
511                a as *mut _,
512                lda,
513            )
514        }
515    }
516
517    unsafe fn cblas_syr(
518        layout: CBLAS_LAYOUT,
519        uplo: CBLAS_UPLO,
520        n: i32,
521        alpha: f32,
522        x: *const f32,
523        incx: i32,
524        a: *mut f32,
525        lda: i32,
526    ) {
527        unsafe {
528            cblas_sys::cblas_ssyr(
529                layout,
530                uplo,
531                n,
532                alpha,
533                x as *const _,
534                incx,
535                a as *mut _,
536                lda,
537            )
538        }
539    }
540
541    unsafe fn cblas_syr2(
542        layout: CBLAS_LAYOUT,
543        uplo: CBLAS_UPLO,
544        n: i32,
545        alpha: f32,
546        x: *const f32,
547        incx: i32,
548        y: *const f32,
549        incy: i32,
550        a: *mut f32,
551        lda: i32,
552    ) {
553        unsafe {
554            cblas_sys::cblas_ssyr2(
555                layout,
556                uplo,
557                n,
558                alpha,
559                x as *const _,
560                incx,
561                y as *const _,
562                incy,
563                a as *mut _,
564                lda,
565            )
566        }
567    }
568
569    unsafe fn cblas_syrk(
570        layout: CBLAS_LAYOUT,
571        uplo: CBLAS_UPLO,
572        trans: CBLAS_TRANSPOSE,
573        n: i32,
574        k: i32,
575        alpha: f32,
576        a: *const f32,
577        lda: i32,
578        beta: f32,
579        c: *mut f32,
580        ldc: i32,
581    ) {
582        unsafe {
583            cblas_sys::cblas_ssyrk(
584                layout,
585                uplo,
586                trans,
587                n,
588                k,
589                alpha,
590                a as *const _,
591                lda,
592                beta,
593                c as *mut _,
594                ldc,
595            )
596        }
597    }
598
599    unsafe fn cblas_syr2k(
600        layout: CBLAS_LAYOUT,
601        uplo: CBLAS_UPLO,
602        trans: CBLAS_TRANSPOSE,
603        n: i32,
604        k: i32,
605        alpha: f32,
606        a: *const f32,
607        lda: i32,
608        b: *const f32,
609        ldb: i32,
610        beta: f32,
611        c: *mut f32,
612        ldc: i32,
613    ) {
614        unsafe {
615            cblas_sys::cblas_ssyr2k(
616                layout,
617                uplo,
618                trans,
619                n,
620                k,
621                alpha,
622                a as *const _,
623                lda,
624                b as *const _,
625                ldb,
626                beta,
627                c as *mut _,
628                ldc,
629            )
630        }
631    }
632}
633
634impl BlasScalar for f64 {
635    unsafe fn cblas_amax(n: i32, x: *const f64, incx: i32) -> CBLAS_INDEX {
636        unsafe { cblas_sys::cblas_idamax(n, x as *const _, incx) }
637    }
638
639    unsafe fn cblas_dot(n: i32, x: *const f64, incx: i32, y: *const f64, incy: i32) -> f64 {
640        unsafe { cblas_sys::cblas_ddot(n, x as *const _, incx, y as *const _, incy) }
641    }
642
643    unsafe fn cblas_nrm2(n: i32, x: *const f64, incx: i32) -> f64 {
644        unsafe { cblas_sys::cblas_dnrm2(n, x as *const _, incx) }
645    }
646
647    unsafe fn cblas_asum(n: i32, x: *const f64, incx: i32) -> f64 {
648        unsafe { cblas_sys::cblas_dasum(n, x as *const _, incx) }
649    }
650
651    unsafe fn cblas_swap(n: i32, x: *mut f64, incx: i32, y: *mut f64, incy: i32) {
652        unsafe { cblas_sys::cblas_dswap(n, x as *mut _, incx, y as *mut _, incy) }
653    }
654
655    unsafe fn cblas_copy(n: i32, x: *const f64, incx: i32, y: *mut f64, incy: i32) {
656        unsafe { cblas_sys::cblas_dcopy(n, x as *const _, incx, y as *mut _, incy) }
657    }
658
659    unsafe fn cblas_axpy(n: i32, alpha: f64, x: *const f64, incx: i32, y: *mut f64, incy: i32) {
660        unsafe { cblas_sys::cblas_daxpy(n, alpha, x as *const _, incx, y as *mut _, incy) }
661    }
662
663    unsafe fn cblas_scal(n: i32, alpha: f64, x: *mut f64, incx: i32) {
664        unsafe { cblas_sys::cblas_dscal(n, alpha, x as *mut _, incx) }
665    }
666
667    unsafe fn cblas_gemv(
668        layout: CBLAS_LAYOUT,
669        transa: CBLAS_TRANSPOSE,
670        m: i32,
671        n: i32,
672        alpha: f64,
673        a: *const f64,
674        lda: i32,
675        x: *const f64,
676        incx: i32,
677        beta: f64,
678        y: *mut f64,
679        incy: i32,
680    ) {
681        unsafe {
682            cblas_sys::cblas_dgemv(
683                layout,
684                transa,
685                m,
686                n,
687                alpha,
688                a as *const _,
689                lda,
690                x as *const _,
691                incx,
692                beta,
693                y as *mut _,
694                incy,
695            )
696        }
697    }
698
699    unsafe fn cblas_trmv(
700        layout: CBLAS_LAYOUT,
701        uplo: CBLAS_UPLO,
702        transa: CBLAS_TRANSPOSE,
703        diag: CBLAS_DIAG,
704        n: i32,
705        a: *const f64,
706        lda: i32,
707        x: *mut f64,
708        incx: i32,
709    ) {
710        unsafe {
711            cblas_sys::cblas_dtrmv(
712                layout,
713                uplo,
714                transa,
715                diag,
716                n,
717                a as *const _,
718                lda,
719                x as *mut _,
720                incx,
721            )
722        }
723    }
724
725    unsafe fn cblas_symv(
726        layout: CBLAS_LAYOUT,
727        uplo: CBLAS_UPLO,
728        n: i32,
729        alpha: f64,
730        a: *const f64,
731        lda: i32,
732        x: *const f64,
733        incx: i32,
734        beta: f64,
735        y: *mut f64,
736        incy: i32,
737    ) {
738        unsafe {
739            cblas_sys::cblas_dsymv(
740                layout,
741                uplo,
742                n,
743                alpha,
744                a as *const _,
745                lda,
746                x as *const _,
747                incx,
748                beta,
749                y as *mut _,
750                incy,
751            )
752        }
753    }
754
755    unsafe fn cblas_ger(
756        layout: CBLAS_LAYOUT,
757        m: i32,
758        n: i32,
759        alpha: f64,
760        x: *const f64,
761        incx: i32,
762        y: *const f64,
763        incy: i32,
764        a: *mut f64,
765        lda: i32,
766    ) {
767        unsafe {
768            cblas_sys::cblas_dger(
769                layout,
770                m,
771                n,
772                alpha,
773                x as *const _,
774                incx,
775                y as *const _,
776                incy,
777                a as *mut _,
778                lda,
779            )
780        }
781    }
782
783    unsafe fn cblas_syr(
784        layout: CBLAS_LAYOUT,
785        uplo: CBLAS_UPLO,
786        n: i32,
787        alpha: f64,
788        x: *const f64,
789        incx: i32,
790        a: *mut f64,
791        lda: i32,
792    ) {
793        unsafe {
794            cblas_sys::cblas_dsyr(
795                layout,
796                uplo,
797                n,
798                alpha,
799                x as *const _,
800                incx,
801                a as *mut _,
802                lda,
803            )
804        }
805    }
806
807    unsafe fn cblas_syr2(
808        layout: CBLAS_LAYOUT,
809        uplo: CBLAS_UPLO,
810        n: i32,
811        alpha: f64,
812        x: *const f64,
813        incx: i32,
814        y: *const f64,
815        incy: i32,
816        a: *mut f64,
817        lda: i32,
818    ) {
819        unsafe {
820            cblas_sys::cblas_dsyr2(
821                layout,
822                uplo,
823                n,
824                alpha,
825                x as *const _,
826                incx,
827                y as *const _,
828                incy,
829                a as *mut _,
830                lda,
831            )
832        }
833    }
834
835    unsafe fn cblas_syrk(
836        layout: CBLAS_LAYOUT,
837        uplo: CBLAS_UPLO,
838        trans: CBLAS_TRANSPOSE,
839        n: i32,
840        k: i32,
841        alpha: f64,
842        a: *const f64,
843        lda: i32,
844        beta: f64,
845        c: *mut f64,
846        ldc: i32,
847    ) {
848        unsafe {
849            cblas_sys::cblas_dsyrk(
850                layout,
851                uplo,
852                trans,
853                n,
854                k,
855                alpha,
856                a as *const _,
857                lda,
858                beta,
859                c as *mut _,
860                ldc,
861            )
862        }
863    }
864
865    unsafe fn cblas_syr2k(
866        layout: CBLAS_LAYOUT,
867        uplo: CBLAS_UPLO,
868        trans: CBLAS_TRANSPOSE,
869        n: i32,
870        k: i32,
871        alpha: f64,
872        a: *const f64,
873        lda: i32,
874        b: *const f64,
875        ldb: i32,
876        beta: f64,
877        c: *mut f64,
878        ldc: i32,
879    ) {
880        unsafe {
881            cblas_sys::cblas_dsyr2k(
882                layout,
883                uplo,
884                trans,
885                n,
886                k,
887                alpha,
888                a as *const _,
889                lda,
890                b as *const _,
891                ldb,
892                beta,
893                c as *mut _,
894                ldc,
895            )
896        }
897    }
898}
899
900impl BlasScalar for Complex<f32> {
901    unsafe fn cblas_amax(n: i32, x: *const Complex<f32>, incx: i32) -> CBLAS_INDEX {
902        unsafe { cblas_sys::cblas_icamax(n, x as *const _, incx) }
903    }
904
905    unsafe fn cblas_dotu_sub(
906        n: i32,
907        x: *const Complex<f32>,
908        incx: i32,
909        y: *const Complex<f32>,
910        incy: i32,
911        dotu: *mut Complex<f32>,
912    ) {
913        unsafe {
914            cblas_sys::cblas_cdotu_sub(n, x as *const _, incx, y as *const _, incy, dotu as *mut _)
915        }
916    }
917
918    unsafe fn cblas_dotc_sub(
919        n: i32,
920        x: *const Complex<f32>,
921        incx: i32,
922        y: *const Complex<f32>,
923        incy: i32,
924        dotc: *mut Complex<f32>,
925    ) {
926        unsafe {
927            cblas_sys::cblas_cdotc_sub(n, x as *const _, incx, y as *const _, incy, dotc as *mut _)
928        }
929    }
930
931    unsafe fn cblas_nrm2(n: i32, x: *const Complex<f32>, incx: i32) -> f32 {
932        unsafe { cblas_sys::cblas_scnrm2(n, x as *const _, incx) }
933    }
934
935    unsafe fn cblas_asum(n: i32, x: *const Complex<f32>, incx: i32) -> f32 {
936        unsafe { cblas_sys::cblas_scasum(n, x as *const _, incx) }
937    }
938
939    unsafe fn cblas_swap(n: i32, x: *mut Complex<f32>, incx: i32, y: *mut Complex<f32>, incy: i32) {
940        unsafe { cblas_sys::cblas_cswap(n, x as *mut _, incx, y as *mut _, incy) }
941    }
942
943    unsafe fn cblas_copy(
944        n: i32,
945        x: *const Complex<f32>,
946        incx: i32,
947        y: *mut Complex<f32>,
948        incy: i32,
949    ) {
950        unsafe { cblas_sys::cblas_ccopy(n, x as *const _, incx, y as *mut _, incy) }
951    }
952
953    unsafe fn cblas_axpy(
954        n: i32,
955        alpha: Complex<f32>,
956        x: *const Complex<f32>,
957        incx: i32,
958        y: *mut Complex<f32>,
959        incy: i32,
960    ) {
961        unsafe {
962            cblas_sys::cblas_caxpy(
963                n,
964                &alpha as *const _ as *const _,
965                x as *const _,
966                incx,
967                y as *mut _,
968                incy,
969            )
970        }
971    }
972
973    unsafe fn cblas_scal(n: i32, alpha: Complex<f32>, x: *mut Complex<f32>, incx: i32) {
974        unsafe { cblas_sys::cblas_cscal(n, &alpha as *const _ as *const _, x as *mut _, incx) }
975    }
976
977    unsafe fn cblas_rscal(n: i32, alpha: f32, x: *mut Complex<f32>, incx: i32) {
978        unsafe { cblas_sys::cblas_csscal(n, alpha, x as *mut _, incx) }
979    }
980
981    unsafe fn cblas_gemv(
982        layout: CBLAS_LAYOUT,
983        transa: CBLAS_TRANSPOSE,
984        m: i32,
985        n: i32,
986        alpha: Complex<f32>,
987        a: *const Complex<f32>,
988        lda: i32,
989        x: *const Complex<f32>,
990        incx: i32,
991        beta: Complex<f32>,
992        y: *mut Complex<f32>,
993        incy: i32,
994    ) {
995        unsafe {
996            cblas_sys::cblas_cgemv(
997                layout,
998                transa,
999                m,
1000                n,
1001                &alpha as *const _ as *const _,
1002                a as *const _,
1003                lda,
1004                x as *const _,
1005                incx,
1006                &beta as *const _ as *const _,
1007                y as *mut _,
1008                incy,
1009            )
1010        }
1011    }
1012
1013    unsafe fn cblas_trmv(
1014        layout: CBLAS_LAYOUT,
1015        uplo: CBLAS_UPLO,
1016        transa: CBLAS_TRANSPOSE,
1017        diag: CBLAS_DIAG,
1018        n: i32,
1019        a: *const Complex<f32>,
1020        lda: i32,
1021        x: *mut Complex<f32>,
1022        incx: i32,
1023    ) {
1024        unsafe {
1025            cblas_sys::cblas_ctrmv(
1026                layout,
1027                uplo,
1028                transa,
1029                diag,
1030                n,
1031                a as *const _,
1032                lda,
1033                x as *mut _,
1034                incx,
1035            )
1036        }
1037    }
1038
1039    unsafe fn cblas_geru(
1040        layout: CBLAS_LAYOUT,
1041        m: i32,
1042        n: i32,
1043        alpha: Complex<f32>,
1044        x: *const Complex<f32>,
1045        incx: i32,
1046        y: *const Complex<f32>,
1047        incy: i32,
1048        a: *mut Complex<f32>,
1049        lda: i32,
1050    ) {
1051        unsafe {
1052            cblas_sys::cblas_cgeru(
1053                layout,
1054                m,
1055                n,
1056                &alpha as *const _ as *const _,
1057                x as *const _,
1058                incx,
1059                y as *const _,
1060                incy,
1061                a as *mut _,
1062                lda,
1063            )
1064        }
1065    }
1066
1067    unsafe fn cblas_gerc(
1068        layout: CBLAS_LAYOUT,
1069        m: i32,
1070        n: i32,
1071        alpha: Complex<f32>,
1072        x: *const Complex<f32>,
1073        incx: i32,
1074        y: *const Complex<f32>,
1075        incy: i32,
1076        a: *mut Complex<f32>,
1077        lda: i32,
1078    ) {
1079        unsafe {
1080            cblas_sys::cblas_cgerc(
1081                layout,
1082                m,
1083                n,
1084                &alpha as *const _ as *const _,
1085                x as *const _,
1086                incx,
1087                y as *const _,
1088                incy,
1089                a as *mut _,
1090                lda,
1091            )
1092        }
1093    }
1094
1095    unsafe fn cblas_her(
1096        layout: CBLAS_LAYOUT,
1097        uplo: CBLAS_UPLO,
1098        n: i32,
1099        alpha: f32,
1100        x: *const Complex<f32>,
1101        incx: i32,
1102        a: *mut Complex<f32>,
1103        lda: i32,
1104    ) {
1105        unsafe {
1106            cblas_sys::cblas_cher(
1107                layout,
1108                uplo,
1109                n,
1110                alpha,
1111                x as *const _,
1112                incx,
1113                a as *mut _,
1114                lda,
1115            )
1116        }
1117    }
1118
1119    unsafe fn cblas_her2(
1120        layout: CBLAS_LAYOUT,
1121        uplo: CBLAS_UPLO,
1122        n: i32,
1123        alpha: Complex<f32>,
1124        x: *const Complex<f32>,
1125        incx: i32,
1126        y: *const Complex<f32>,
1127        incy: i32,
1128        a: *mut Complex<f32>,
1129        lda: i32,
1130    ) {
1131        unsafe {
1132            cblas_sys::cblas_cher2(
1133                layout,
1134                uplo,
1135                n,
1136                &alpha as *const _ as *const _,
1137                x as *const _,
1138                incx,
1139                y as *const _,
1140                incy,
1141                a as *mut _,
1142                lda,
1143            )
1144        }
1145    }
1146
1147    unsafe fn cblas_syrk(
1148        layout: CBLAS_LAYOUT,
1149        uplo: CBLAS_UPLO,
1150        trans: CBLAS_TRANSPOSE,
1151        n: i32,
1152        k: i32,
1153        alpha: Complex<f32>,
1154        a: *const Complex<f32>,
1155        lda: i32,
1156        beta: Complex<f32>,
1157        c: *mut Complex<f32>,
1158        ldc: i32,
1159    ) {
1160        unsafe {
1161            cblas_sys::cblas_csyrk(
1162                layout,
1163                uplo,
1164                trans,
1165                n,
1166                k,
1167                &alpha as *const _ as *const _,
1168                a as *const _,
1169                lda,
1170                &beta as *const _ as *const _,
1171                c as *mut _,
1172                ldc,
1173            )
1174        }
1175    }
1176
1177    unsafe fn cblas_syr2k(
1178        layout: CBLAS_LAYOUT,
1179        uplo: CBLAS_UPLO,
1180        trans: CBLAS_TRANSPOSE,
1181        n: i32,
1182        k: i32,
1183        alpha: Complex<f32>,
1184        a: *const Complex<f32>,
1185        lda: i32,
1186        b: *const Complex<f32>,
1187        ldb: i32,
1188        beta: Complex<f32>,
1189        c: *mut Complex<f32>,
1190        ldc: i32,
1191    ) {
1192        unsafe {
1193            cblas_sys::cblas_csyr2k(
1194                layout,
1195                uplo,
1196                trans,
1197                n,
1198                k,
1199                &alpha as *const _ as *const _,
1200                a as *const _,
1201                lda,
1202                b as *const _,
1203                ldb,
1204                &beta as *const _ as *const _,
1205                c as *mut _,
1206                ldc,
1207            )
1208        }
1209    }
1210
1211    unsafe fn cblas_herk(
1212        layout: CBLAS_LAYOUT,
1213        uplo: CBLAS_UPLO,
1214        trans: CBLAS_TRANSPOSE,
1215        n: i32,
1216        k: i32,
1217        alpha: f32,
1218        a: *const Complex<f32>,
1219        lda: i32,
1220        beta: f32,
1221        c: *mut Complex<f32>,
1222        ldc: i32,
1223    ) {
1224        unsafe {
1225            cblas_sys::cblas_cherk(
1226                layout,
1227                uplo,
1228                trans,
1229                n,
1230                k,
1231                alpha,
1232                a as *const _,
1233                lda,
1234                beta,
1235                c as *mut _,
1236                ldc,
1237            )
1238        }
1239    }
1240
1241    unsafe fn cblas_her2k(
1242        layout: CBLAS_LAYOUT,
1243        uplo: CBLAS_UPLO,
1244        trans: CBLAS_TRANSPOSE,
1245        n: i32,
1246        k: i32,
1247        alpha: Complex<f32>,
1248        a: *const Complex<f32>,
1249        lda: i32,
1250        b: *const Complex<f32>,
1251        ldb: i32,
1252        beta: f32,
1253        c: *mut Complex<f32>,
1254        ldc: i32,
1255    ) {
1256        unsafe {
1257            cblas_sys::cblas_cher2k(
1258                layout,
1259                uplo,
1260                trans,
1261                n,
1262                k,
1263                &alpha as *const _ as *const _,
1264                a as *const _,
1265                lda,
1266                b as *const _,
1267                ldb,
1268                beta,
1269                c as *mut _,
1270                ldc,
1271            )
1272        }
1273    }
1274}
1275
1276impl BlasScalar for Complex<f64> {
1277    unsafe fn cblas_amax(n: i32, x: *const Complex<f64>, incx: i32) -> CBLAS_INDEX {
1278        unsafe { cblas_sys::cblas_izamax(n, x as *const _, incx) }
1279    }
1280
1281    unsafe fn cblas_dotu_sub(
1282        n: i32,
1283        x: *const Complex<f64>,
1284        incx: i32,
1285        y: *const Complex<f64>,
1286        incy: i32,
1287        dotu: *mut Complex<f64>,
1288    ) {
1289        unsafe {
1290            cblas_sys::cblas_zdotu_sub(n, x as *const _, incx, y as *const _, incy, dotu as *mut _)
1291        }
1292    }
1293
1294    unsafe fn cblas_dotc_sub(
1295        n: i32,
1296        x: *const Complex<f64>,
1297        incx: i32,
1298        y: *const Complex<f64>,
1299        incy: i32,
1300        dotc: *mut Complex<f64>,
1301    ) {
1302        unsafe {
1303            cblas_sys::cblas_zdotc_sub(n, x as *const _, incx, y as *const _, incy, dotc as *mut _)
1304        }
1305    }
1306
1307    unsafe fn cblas_nrm2(n: i32, x: *const Complex<f64>, incx: i32) -> f64 {
1308        unsafe { cblas_sys::cblas_dznrm2(n, x as *const _, incx) }
1309    }
1310
1311    unsafe fn cblas_asum(n: i32, x: *const Complex<f64>, incx: i32) -> f64 {
1312        unsafe { cblas_sys::cblas_dzasum(n, x as *const _, incx) }
1313    }
1314
1315    unsafe fn cblas_swap(n: i32, x: *mut Complex<f64>, incx: i32, y: *mut Complex<f64>, incy: i32) {
1316        unsafe { cblas_sys::cblas_zswap(n, x as *mut _, incx, y as *mut _, incy) }
1317    }
1318
1319    unsafe fn cblas_copy(
1320        n: i32,
1321        x: *const Complex<f64>,
1322        incx: i32,
1323        y: *mut Complex<f64>,
1324        incy: i32,
1325    ) {
1326        unsafe { cblas_sys::cblas_zcopy(n, x as *const _, incx, y as *mut _, incy) }
1327    }
1328
1329    unsafe fn cblas_axpy(
1330        n: i32,
1331        alpha: Complex<f64>,
1332        x: *const Complex<f64>,
1333        incx: i32,
1334        y: *mut Complex<f64>,
1335        incy: i32,
1336    ) {
1337        unsafe {
1338            cblas_sys::cblas_zaxpy(
1339                n,
1340                &alpha as *const _ as *const _,
1341                x as *const _,
1342                incx,
1343                y as *mut _,
1344                incy,
1345            )
1346        }
1347    }
1348
1349    unsafe fn cblas_scal(n: i32, alpha: Complex<f64>, x: *mut Complex<f64>, incx: i32) {
1350        unsafe { cblas_sys::cblas_zscal(n, &alpha as *const _ as *const _, x as *mut _, incx) }
1351    }
1352
1353    unsafe fn cblas_rscal(n: i32, alpha: f64, x: *mut Complex<f64>, incx: i32) {
1354        unsafe { cblas_sys::cblas_zdscal(n, alpha, x as *mut _, incx) }
1355    }
1356
1357    unsafe fn cblas_gemv(
1358        layout: CBLAS_LAYOUT,
1359        transa: CBLAS_TRANSPOSE,
1360        m: i32,
1361        n: i32,
1362        alpha: Complex<f64>,
1363        a: *const Complex<f64>,
1364        lda: i32,
1365        x: *const Complex<f64>,
1366        incx: i32,
1367        beta: Complex<f64>,
1368        y: *mut Complex<f64>,
1369        incy: i32,
1370    ) {
1371        unsafe {
1372            cblas_sys::cblas_zgemv(
1373                layout,
1374                transa,
1375                m,
1376                n,
1377                &alpha as *const _ as *const _,
1378                a as *const _,
1379                lda,
1380                x as *const _,
1381                incx,
1382                &beta as *const _ as *const _,
1383                y as *mut _,
1384                incy,
1385            )
1386        }
1387    }
1388
1389    unsafe fn cblas_trmv(
1390        layout: CBLAS_LAYOUT,
1391        uplo: CBLAS_UPLO,
1392        transa: CBLAS_TRANSPOSE,
1393        diag: CBLAS_DIAG,
1394        n: i32,
1395        a: *const Complex<f64>,
1396        lda: i32,
1397        x: *mut Complex<f64>,
1398        incx: i32,
1399    ) {
1400        unsafe {
1401            cblas_sys::cblas_ztrmv(
1402                layout,
1403                uplo,
1404                transa,
1405                diag,
1406                n,
1407                a as *const _,
1408                lda,
1409                x as *mut _,
1410                incx,
1411            )
1412        }
1413    }
1414
1415    unsafe fn cblas_geru(
1416        layout: CBLAS_LAYOUT,
1417        m: i32,
1418        n: i32,
1419        alpha: Complex<f64>,
1420        x: *const Complex<f64>,
1421        incx: i32,
1422        y: *const Complex<f64>,
1423        incy: i32,
1424        a: *mut Complex<f64>,
1425        lda: i32,
1426    ) {
1427        unsafe {
1428            cblas_sys::cblas_zgeru(
1429                layout,
1430                m,
1431                n,
1432                &alpha as *const _ as *const _,
1433                x as *const _,
1434                incx,
1435                y as *const _,
1436                incy,
1437                a as *mut _,
1438                lda,
1439            )
1440        }
1441    }
1442
1443    unsafe fn cblas_gerc(
1444        layout: CBLAS_LAYOUT,
1445        m: i32,
1446        n: i32,
1447        alpha: Complex<f64>,
1448        x: *const Complex<f64>,
1449        incx: i32,
1450        y: *const Complex<f64>,
1451        incy: i32,
1452        a: *mut Complex<f64>,
1453        lda: i32,
1454    ) {
1455        unsafe {
1456            cblas_sys::cblas_zgerc(
1457                layout,
1458                m,
1459                n,
1460                &alpha as *const _ as *const _,
1461                x as *const _,
1462                incx,
1463                y as *const _,
1464                incy,
1465                a as *mut _,
1466                lda,
1467            )
1468        }
1469    }
1470
1471    unsafe fn cblas_her(
1472        layout: CBLAS_LAYOUT,
1473        uplo: CBLAS_UPLO,
1474        n: i32,
1475        alpha: f64,
1476        x: *const Complex<f64>,
1477        incx: i32,
1478        a: *mut Complex<f64>,
1479        lda: i32,
1480    ) {
1481        unsafe {
1482            cblas_sys::cblas_zher(
1483                layout,
1484                uplo,
1485                n,
1486                alpha,
1487                x as *const _,
1488                incx,
1489                a as *mut _,
1490                lda,
1491            )
1492        }
1493    }
1494
1495    unsafe fn cblas_her2(
1496        layout: CBLAS_LAYOUT,
1497        uplo: CBLAS_UPLO,
1498        n: i32,
1499        alpha: Complex<f64>,
1500        x: *const Complex<f64>,
1501        incx: i32,
1502        y: *const Complex<f64>,
1503        incy: i32,
1504        a: *mut Complex<f64>,
1505        lda: i32,
1506    ) {
1507        unsafe {
1508            cblas_sys::cblas_zher2(
1509                layout,
1510                uplo,
1511                n,
1512                &alpha as *const _ as *const _,
1513                x as *const _,
1514                incx,
1515                y as *const _,
1516                incy,
1517                a as *mut _,
1518                lda,
1519            )
1520        }
1521    }
1522
1523    unsafe fn cblas_syrk(
1524        layout: CBLAS_LAYOUT,
1525        uplo: CBLAS_UPLO,
1526        trans: CBLAS_TRANSPOSE,
1527        n: i32,
1528        k: i32,
1529        alpha: Complex<f64>,
1530        a: *const Complex<f64>,
1531        lda: i32,
1532        beta: Complex<f64>,
1533        c: *mut Complex<f64>,
1534        ldc: i32,
1535    ) {
1536        unsafe {
1537            cblas_sys::cblas_zsyrk(
1538                layout,
1539                uplo,
1540                trans,
1541                n,
1542                k,
1543                &alpha as *const _ as *const _,
1544                a as *const _,
1545                lda,
1546                &beta as *const _ as *const _,
1547                c as *mut _,
1548                ldc,
1549            )
1550        }
1551    }
1552
1553    unsafe fn cblas_syr2k(
1554        layout: CBLAS_LAYOUT,
1555        uplo: CBLAS_UPLO,
1556        trans: CBLAS_TRANSPOSE,
1557        n: i32,
1558        k: i32,
1559        alpha: Complex<f64>,
1560        a: *const Complex<f64>,
1561        lda: i32,
1562        b: *const Complex<f64>,
1563        ldb: i32,
1564        beta: Complex<f64>,
1565        c: *mut Complex<f64>,
1566        ldc: i32,
1567    ) {
1568        unsafe {
1569            cblas_sys::cblas_zsyr2k(
1570                layout,
1571                uplo,
1572                trans,
1573                n,
1574                k,
1575                &alpha as *const _ as *const _,
1576                a as *const _,
1577                lda,
1578                b as *const _,
1579                ldb,
1580                &beta as *const _ as *const _,
1581                c as *mut _,
1582                ldc,
1583            )
1584        }
1585    }
1586
1587    unsafe fn cblas_herk(
1588        layout: CBLAS_LAYOUT,
1589        uplo: CBLAS_UPLO,
1590        trans: CBLAS_TRANSPOSE,
1591        n: i32,
1592        k: i32,
1593        alpha: f64,
1594        a: *const Complex<f64>,
1595        lda: i32,
1596        beta: f64,
1597        c: *mut Complex<f64>,
1598        ldc: i32,
1599    ) {
1600        unsafe {
1601            cblas_sys::cblas_zherk(
1602                layout,
1603                uplo,
1604                trans,
1605                n,
1606                k,
1607                alpha,
1608                a as *const _,
1609                lda,
1610                beta,
1611                c as *mut _,
1612                ldc,
1613            )
1614        }
1615    }
1616
1617    unsafe fn cblas_her2k(
1618        layout: CBLAS_LAYOUT,
1619        uplo: CBLAS_UPLO,
1620        trans: CBLAS_TRANSPOSE,
1621        n: i32,
1622        k: i32,
1623        alpha: Complex<f64>,
1624        a: *const Complex<f64>,
1625        lda: i32,
1626        b: *const Complex<f64>,
1627        ldb: i32,
1628        beta: f64,
1629        c: *mut Complex<f64>,
1630        ldc: i32,
1631    ) {
1632        unsafe {
1633            cblas_sys::cblas_zher2k(
1634                layout,
1635                uplo,
1636                trans,
1637                n,
1638                k,
1639                &alpha as *const _ as *const _,
1640                a as *const _,
1641                lda,
1642                b as *const _,
1643                ldb,
1644                beta,
1645                c as *mut _,
1646                ldc,
1647            )
1648        }
1649    }
1650}