1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
//! The C bindings (CBLAS).

#![allow(non_camel_case_types)]

use libc::{c_char, c_double, c_float, c_int};

use {c_double_complex, c_float_complex};

pub type CBLAS_INDEX = c_int;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CBLAS_LAYOUT {
    CblasRowMajor = 101,
    CblasColMajor = 102,
}
pub use self::CBLAS_LAYOUT::*;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CBLAS_TRANSPOSE {
    CblasNoTrans = 111,
    CblasTrans = 112,
    CblasConjTrans = 113,
}
pub use self::CBLAS_TRANSPOSE::*;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CBLAS_UPLO {
    CblasUpper = 121,
    CblasLower = 122,
}
pub use self::CBLAS_UPLO::*;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CBLAS_DIAG {
    CblasNonUnit = 131,
    CblasUnit = 132,
}
pub use self::CBLAS_DIAG::*;

#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub enum CBLAS_SIDE {
    CblasLeft = 141,
    CblasRight = 142,
}
pub use self::CBLAS_SIDE::*;

pub type CBLAS_ORDER = CBLAS_LAYOUT;

// Level 1 (functions except for complex)
extern "C" {
    pub fn cblas_dcabs1(z: *const c_double_complex) -> c_double;
    pub fn cblas_scabs1(c: *const c_float_complex) -> c_float;

    pub fn cblas_sdsdot(n: c_int, alpha: c_float, x: *const c_float,
                        incx: c_int, y: *const c_float, incy: c_int)
                        -> c_float;
    pub fn cblas_dsdot(n: c_int, x: *const c_float, incx: c_int,
                       y: *const c_float, incy: c_int)
                       -> c_double;
    pub fn cblas_sdot(n: c_int, x: *const c_float, incx: c_int,
                      y: *const c_float, incy: c_int)
                      -> c_float;
    pub fn cblas_ddot(n: c_int, x: *const c_double, incx: c_int,
                      y: *const c_double, incy: c_int)
                      -> c_double;

    // Prefixes Z and C only
    pub fn cblas_cdotu_sub(n: c_int, x: *const c_float_complex,
                           incx: c_int, y: *const c_float_complex,
                           incy: c_int, dotu: *mut c_float_complex);
    pub fn cblas_cdotc_sub(n: c_int, x: *const c_float_complex,
                           incx: c_int, y: *const c_float_complex,
                           incy: c_int, dotc: *mut c_float_complex);

    pub fn cblas_zdotu_sub(n: c_int, x: *const c_double_complex,
                           incx: c_int, y: *const c_double_complex,
                           incy: c_int, dotu: *mut c_double_complex);
    pub fn cblas_zdotc_sub(n: c_int, x: *const c_double_complex,
                           incx: c_int, y: *const c_double_complex,
                           incy: c_int, dotc: *mut c_double_complex);

    // Prefixes S, D, SC, and DZ
    pub fn cblas_snrm2(n: c_int, x: *const c_float, incx: c_int) -> c_float;
    pub fn cblas_sasum(n: c_int, x: *const c_float, incx: c_int) -> c_float;

    pub fn cblas_dnrm2(n: c_int, x: *const c_double, incx: c_int) -> c_double;
    pub fn cblas_dasum(n: c_int, x: *const c_double, incx: c_int) -> c_double;

    pub fn cblas_scnrm2(n: c_int, x: *const c_float_complex, incx: c_int) -> c_float;
    pub fn cblas_scasum(n: c_int, x: *const c_float_complex, incx: c_int) -> c_float;

    pub fn cblas_dznrm2(n: c_int, x: *const c_double_complex, incx: c_int) -> c_double;
    pub fn cblas_dzasum(n: c_int, x: *const c_double_complex, incx: c_int) -> c_double;

    // Standard prefixes (S, D, C, and Z)
    pub fn cblas_isamax(n: c_int, x: *const c_float, incx: c_int) -> CBLAS_INDEX;
    pub fn cblas_idamax(n: c_int, x: *const c_double, incx: c_int) -> CBLAS_INDEX;
    pub fn cblas_icamax(n: c_int, x: *const c_float_complex, incx: c_int) -> CBLAS_INDEX;
    pub fn cblas_izamax(n: c_int, x: *const c_double_complex, incx: c_int) -> CBLAS_INDEX;
}

// Level 1 (routines)
extern "C" {
    // Standard prefixes (S, D, C, and Z)
    pub fn cblas_sswap(n: c_int, x: *mut c_float, incx: c_int,
                       y: *mut c_float, incy: c_int);
    pub fn cblas_scopy(n: c_int, x: *const c_float, incx: c_int,
                       y: *mut c_float, incy: c_int);
    pub fn cblas_saxpy(n: c_int, alpha: c_float, x: *const c_float,
                       incx: c_int, y: *mut c_float, incy: c_int);

    pub fn cblas_dswap(n: c_int, x: *mut c_double, incx: c_int,
                       y: *mut c_double, incy: c_int);
    pub fn cblas_dcopy(n: c_int, x: *const c_double, incx: c_int,
                       y: *mut c_double, incy: c_int);
    pub fn cblas_daxpy(n: c_int, alpha: c_double, x: *const c_double,
                       incx: c_int, y: *mut c_double, incy: c_int);

    pub fn cblas_cswap(n: c_int, x: *mut c_float_complex, incx: c_int,
                       y: *mut c_float_complex, incy: c_int);
    pub fn cblas_ccopy(n: c_int, x: *const c_float_complex, incx: c_int,
                       y: *mut c_float_complex, incy: c_int);
    pub fn cblas_caxpy(n: c_int, alpha: *const c_float_complex,
                       x: *const c_float_complex, incx: c_int,
                       y: *mut c_float_complex, incy: c_int);

    pub fn cblas_zswap(n: c_int, x: *mut c_double_complex, incx: c_int,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zcopy(n: c_int, x: *const c_double_complex, incx: c_int,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zaxpy(n: c_int, alpha: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       y: *mut c_double_complex, incy: c_int);

    // Prefixes S and D only
    pub fn cblas_srotg(a: *mut c_float, b: *mut c_float, c: *mut c_float,
                       s: *mut c_float);
    pub fn cblas_srotmg(d1: *mut c_float, d2: *mut c_float, b1: *mut c_float,
                        b2: c_float, p: *mut c_float);
    pub fn cblas_srot(n: c_int, x: *mut c_float, incx: c_int, y: *mut c_float,
                      incy: c_int, c: c_float, s: c_float);
    pub fn cblas_srotm(n: c_int, x: *mut c_float, incx: c_int,
                       y: *mut c_float, incy: c_int, p: *const c_float);

    pub fn cblas_drotg(a: *mut c_double, b: *mut c_double, c: *mut c_double,
                       s: *mut c_double);
    pub fn cblas_drotmg(d1: *mut c_double, d2: *mut c_double,
                        b1: *mut c_double, b2: c_double, p: *mut c_double);
    pub fn cblas_drot(n: c_int, x: *mut c_double, incx: c_int,
                      y: *mut c_double, incy: c_int, c: c_double, s: c_double);
    pub fn cblas_drotm(n: c_int, x: *mut c_double, incx: c_int,
                       y: *mut c_double, incy: c_int, p: *const c_double);

    // Prefixes S, D, C, Z, CS, and ZD
    pub fn cblas_sscal(n: c_int, alpha: c_float, x: *mut c_float, incx: c_int);
    pub fn cblas_dscal(n: c_int, alpha: c_double, x: *mut c_double,
                       incx: c_int);
    pub fn cblas_cscal(n: c_int, alpha: *const c_float_complex,
                       x: *mut c_float_complex, incx: c_int);
    pub fn cblas_zscal(n: c_int, alpha: *const c_double_complex,
                       x: *mut c_double_complex, incx: c_int);
    pub fn cblas_csscal(n: c_int, alpha: c_float, x: *mut c_float_complex,
                        incx: c_int);
    pub fn cblas_zdscal(n: c_int, alpha: c_double, x: *mut c_double_complex,
                        incx: c_int);
}

// Level 2
extern "C" {
    // Standard prefixes (S, D, C, and Z)
    pub fn cblas_sgemv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, alpha: c_float, a: *const c_float,
                       lda: c_int, x: *const c_float, incx: c_int,
                       beta: c_float, y: *mut c_float, incy: c_int);
    pub fn cblas_sgbmv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, kl: c_int, ku: c_int,
                       alpha: c_float, a: *const c_float, lda: c_int,
                       x: *const c_float, incx: c_int, beta: c_float,
                       y: *mut c_float, incy: c_int);
    pub fn cblas_strmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_float, lda: c_int, x: *mut c_float,
                       incx: c_int);
    pub fn cblas_stbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_float, lda: c_int,
                       x: *mut c_float, incx: c_int);
    pub fn cblas_stpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_float, x: *mut c_float, incx: c_int);
    pub fn cblas_strsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_float, lda: c_int, x: *mut c_float,
                       incx: c_int);
    pub fn cblas_stbsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_float, lda: c_int,
                       x: *mut c_float, incx: c_int);
    pub fn cblas_stpsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_float, x: *mut c_float, incx: c_int);

    pub fn cblas_dgemv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, alpha: c_double,
                       a: *const c_double, lda: c_int, x: *const c_double,
                       incx: c_int, beta: c_double, y: *mut c_double,
                       incy: c_int);
    pub fn cblas_dgbmv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, kl: c_int, ku: c_int,
                       alpha: c_double, a: *const c_double, lda: c_int,
                       x: *const c_double, incx: c_int, beta: c_double,
                       y: *mut c_double, incy: c_int);
    pub fn cblas_dtrmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_double, lda: c_int, x: *mut c_double,
                       incx: c_int);
    pub fn cblas_dtbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_double, lda: c_int,
                       x: *mut c_double, incx: c_int);
    pub fn cblas_dtpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_double, x: *mut c_double, incx: c_int);
    pub fn cblas_dtrsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_double, lda: c_int, x: *mut c_double,
                       incx: c_int);
    pub fn cblas_dtbsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_double, lda: c_int,
                       x: *mut c_double, incx: c_int);
    pub fn cblas_dtpsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_double, x: *mut c_double, incx: c_int);

    pub fn cblas_cgemv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       x: *const c_float_complex, incx: c_int,
                       beta: *const c_float_complex, y: *mut c_float_complex,
                       incy: c_int);
    pub fn cblas_cgbmv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, kl: c_int, ku: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       x: *const c_float_complex, incx: c_int,
                       beta: *const c_float_complex, y: *mut c_float_complex,
                       incy: c_int);
    pub fn cblas_ctrmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_float_complex, lda: c_int,
                       x: *mut c_float_complex, incx: c_int);
    pub fn cblas_ctbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_float_complex, lda: c_int,
                       x: *mut c_float_complex, incx: c_int);
    pub fn cblas_ctpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_float_complex, x: *mut c_float_complex,
                       incx: c_int);
    pub fn cblas_ctrsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_float_complex, lda: c_int,
                       x: *mut c_float_complex, incx: c_int);
    pub fn cblas_ctbsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_float_complex, lda: c_int,
                       x: *mut c_float_complex, incx: c_int);
    pub fn cblas_ctpsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_float_complex, x: *mut c_float_complex,
                       incx: c_int);

    pub fn cblas_zgemv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       x: *const c_double_complex, incx: c_int,
                       beta: *const c_double_complex,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zgbmv(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       m: c_int, n: c_int, kl: c_int, ku: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       x: *const c_double_complex, incx: c_int,
                       beta: *const c_double_complex,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_ztrmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_double_complex, lda: c_int,
                       x: *mut c_double_complex, incx: c_int);
    pub fn cblas_ztbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_double_complex, lda: c_int,
                       x: *mut c_double_complex, incx: c_int);
    pub fn cblas_ztpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_double_complex, x: *mut c_double_complex,
                       incx: c_int);
    pub fn cblas_ztrsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       a: *const c_double_complex, lda: c_int,
                       x: *mut c_double_complex, incx: c_int);
    pub fn cblas_ztbsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       k: c_int, a: *const c_double_complex, lda: c_int,
                       x: *mut c_double_complex, incx: c_int);
    pub fn cblas_ztpsv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       transa: CBLAS_TRANSPOSE, diag: CBLAS_DIAG, n: c_int,
                       ap: *const c_double_complex, x: *mut c_double_complex,
                       incx: c_int);

    // Prefixes S and D only
    pub fn cblas_ssymv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_float, a: *const c_float, lda: c_int,
                       x: *const c_float, incx: c_int, beta: c_float,
                       y: *mut c_float, incy: c_int);
    pub fn cblas_ssbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       k: c_int, alpha: c_float, a: *const c_float,
                       lda: c_int, x: *const c_float, incx: c_int,
                       beta: c_float, y: *mut c_float, incy: c_int);
    pub fn cblas_sspmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_float, ap: *const c_float, x: *const c_float,
                       incx: c_int, beta: c_float, y: *mut c_float,
                       incy: c_int);
    pub fn cblas_sger(layout: CBLAS_LAYOUT, m: c_int, n: c_int, alpha: c_float,
                      x: *const c_float, incx: c_int, y: *const c_float,
                      incy: c_int, a: *mut c_float, lda: c_int);
    pub fn cblas_ssyr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_float, x: *const c_float, incx: c_int,
                      a: *mut c_float, lda: c_int);
    pub fn cblas_sspr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_float, x: *const c_float, incx: c_int,
                      ap: *mut c_float);
    pub fn cblas_ssyr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_float, x: *const c_float, incx: c_int,
                       y: *const c_float, incy: c_int, a: *mut c_float,
                       lda: c_int);
    pub fn cblas_sspr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_float, x: *const c_float, incx: c_int,
                       y: *const c_float, incy: c_int, a: *mut c_float);

    pub fn cblas_dsymv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_double, a: *const c_double, lda: c_int,
                       x: *const c_double, incx: c_int, beta: c_double,
                       y: *mut c_double, incy: c_int);
    pub fn cblas_dsbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       k: c_int, alpha: c_double, a: *const c_double,
                       lda: c_int, x: *const c_double, incx: c_int,
                       beta: c_double, y: *mut c_double, incy: c_int);
    pub fn cblas_dspmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_double, ap: *const c_double,
                       x: *const c_double, incx: c_int, beta: c_double,
                       y: *mut c_double, incy: c_int);
    pub fn cblas_dger(layout: CBLAS_LAYOUT, m: c_int, n: c_int,
                      alpha: c_double, x: *const c_double, incx: c_int,
                      y: *const c_double, incy: c_int, a: *mut c_double,
                      lda: c_int);
    pub fn cblas_dsyr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_double, x: *const c_double, incx: c_int,
                      a: *mut c_double, lda: c_int);
    pub fn cblas_dspr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_double, x: *const c_double, incx: c_int,
                      ap: *mut c_double);
    pub fn cblas_dsyr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_double, x: *const c_double, incx: c_int,
                       y: *const c_double, incy: c_int, a: *mut c_double,
                       lda: c_int);
    pub fn cblas_dspr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: c_double, x: *const c_double, incx: c_int,
                       y: *const c_double, incy: c_int, a: *mut c_double);

    // Prefixes C and Z only
    pub fn cblas_chemv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       x: *const c_float_complex, incx: c_int,
                       beta: *const c_float_complex, y: *mut c_float_complex,
                       incy: c_int);
    pub fn cblas_chbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       k: c_int, alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       x: *const c_float_complex, incx: c_int,
                       beta: *const c_float_complex, y: *mut c_float_complex,
                       incy: c_int);
    pub fn cblas_chpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_float_complex,
                       ap: *const c_float_complex, x: *const c_float_complex,
                       incx: c_int, beta: *const c_float_complex,
                       y: *mut c_float_complex, incy: c_int);
    pub fn cblas_cgeru(layout: CBLAS_LAYOUT, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       x: *const c_float_complex, incx: c_int,
                       y: *const c_float_complex, incy: c_int,
                       a: *mut c_float_complex, lda: c_int);
    pub fn cblas_cgerc(layout: CBLAS_LAYOUT, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       x: *const c_float_complex, incx: c_int,
                       y: *const c_float_complex, incy: c_int,
                       a: *mut c_float_complex, lda: c_int);
    pub fn cblas_cher(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_float, x: *const c_float_complex, incx: c_int,
                      a: *mut c_float_complex, lda: c_int);
    pub fn cblas_chpr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_float, x: *const c_float_complex, incx: c_int,
                      a: *mut c_float_complex);
    pub fn cblas_cher2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_float_complex,
                       x: *const c_float_complex, incx: c_int,
                       y: *const c_float_complex, incy: c_int,
                       a: *mut c_float_complex, lda: c_int);
    pub fn cblas_chpr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_float_complex,
                       x: *const c_float_complex, incx: c_int,
                       y: *const c_float_complex, incy: c_int,
                       ap: *mut c_float_complex);

    pub fn cblas_zhemv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       x: *const c_double_complex, incx: c_int,
                       beta: *const c_double_complex,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zhbmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       k: c_int, alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       x: *const c_double_complex, incx: c_int,
                       beta: *const c_double_complex,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zhpmv(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_double_complex,
                       ap: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       beta: *const c_double_complex,
                       y: *mut c_double_complex, incy: c_int);
    pub fn cblas_zgeru(layout: CBLAS_LAYOUT, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       y: *const c_double_complex, incy: c_int,
                       a: *mut c_double_complex, lda: c_int);
    pub fn cblas_zgerc(layout: CBLAS_LAYOUT, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       y: *const c_double_complex, incy: c_int,
                       a: *mut c_double_complex, lda: c_int);
    pub fn cblas_zher(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_double, x: *const c_double_complex, incx: c_int,
                      a: *mut c_double_complex, lda: c_int);
    pub fn cblas_zhpr(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                      alpha: c_double, x: *const c_double_complex, incx: c_int,
                      a: *mut c_double_complex);
    pub fn cblas_zher2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       y: *const c_double_complex, incy: c_int,
                       a: *mut c_double_complex, lda: c_int);
    pub fn cblas_zhpr2(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO, n: c_int,
                       alpha: *const c_double_complex,
                       x: *const c_double_complex, incx: c_int,
                       y: *const c_double_complex, incy: c_int,
                       ap: *mut c_double_complex);
}

// Level 3
extern "C" {
    // Standard prefixes (S, D, C, and Z)
    pub fn cblas_sgemm(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       transb: CBLAS_TRANSPOSE, m: c_int, n: c_int, k: c_int,
                       alpha: c_float, a: *const c_float, lda: c_int,
                       b: *const c_float, ldb: c_int, beta: c_float,
                       c: *mut c_float, ldc: c_int);
    pub fn cblas_ssymm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int, alpha: c_float,
                       a: *const c_float, lda: c_int, b: *const c_float,
                       ldb: c_int, beta: c_float, c: *mut c_float, ldc: c_int);
    pub fn cblas_ssyrk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: c_float, a: *const c_float, lda: c_int,
                       beta: c_float, c: *mut c_float, ldc: c_int);
    pub fn cblas_ssyr2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: c_float, a: *const c_float, lda: c_int,
                        b: *const c_float, ldb: c_int, beta: c_float,
                        c: *mut c_float, ldc: c_int);
    pub fn cblas_strmm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int, alpha: c_float,
                       a: *const c_float, lda: c_int, b: *mut c_float,
                       ldb: c_int);
    pub fn cblas_strsm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int, alpha: c_float,
                       a: *const c_float, lda: c_int, b: *mut c_float,
                       ldb: c_int);

    pub fn cblas_dgemm(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       transb: CBLAS_TRANSPOSE, m: c_int, n: c_int, k: c_int,
                       alpha: c_double, a: *const c_double, lda: c_int,
                       b: *const c_double, ldb: c_int, beta: c_double,
                       c: *mut c_double, ldc: c_int);
    pub fn cblas_dsymm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int, alpha: c_double,
                       a: *const c_double, lda: c_int, b: *const c_double,
                       ldb: c_int, beta: c_double, c: *mut c_double,
                       ldc: c_int);
    pub fn cblas_dsyrk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: c_double, a: *const c_double, lda: c_int,
                       beta: c_double, c: *mut c_double, ldc: c_int);
    pub fn cblas_dsyr2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: c_double, a: *const c_double, lda: c_int,
                        b: *const c_double, ldb: c_int, beta: c_double,
                        c: *mut c_double, ldc: c_int);
    pub fn cblas_dtrmm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int, alpha: c_double,
                       a: *const c_double, lda: c_int, b: *mut c_double,
                       ldb: c_int);
    pub fn cblas_dtrsm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int, alpha: c_double,
                       a: *const c_double, lda: c_int, b: *mut c_double,
                       ldb: c_int);

    pub fn cblas_cgemm(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       transb: CBLAS_TRANSPOSE, m: c_int, n: c_int, k: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       b: *const c_float_complex, ldb: c_int,
                       beta: *const c_float_complex, c: *mut c_float_complex,
                       ldc: c_int);
    pub fn cblas_csymm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       b: *const c_float_complex, ldb: c_int,
                       beta: *const c_float_complex, c: *mut c_float_complex,
                       ldc: c_int);
    pub fn cblas_csyrk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       beta: *const c_float_complex, c: *mut c_float_complex,
                       ldc: c_int);
    pub fn cblas_csyr2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: *const c_float_complex,
                        a: *const c_float_complex, lda: c_int,
                        b: *const c_float_complex, ldb: c_int,
                        beta: *const c_float_complex,
                        c: *mut c_float_complex, ldc: c_int);
    pub fn cblas_ctrmm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       b: *mut c_float_complex, ldb: c_int);
    pub fn cblas_ctrsm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       b: *mut c_float_complex, ldb: c_int);

    pub fn cblas_zgemm(layout: CBLAS_LAYOUT, transa: CBLAS_TRANSPOSE,
                       transb: CBLAS_TRANSPOSE, m: c_int, n: c_int, k: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       b: *const c_double_complex, ldb: c_int,
                       beta: *const c_double_complex,
                       c: *mut c_double_complex, ldc: c_int);
    pub fn cblas_zsymm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       b: *const c_double_complex, ldb: c_int,
                       beta: *const c_double_complex,
                       c: *mut c_double_complex, ldc: c_int);
    pub fn cblas_zsyrk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       beta: *const c_double_complex,
                       c: *mut c_double_complex, ldc: c_int);
    pub fn cblas_zsyr2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: *const c_double_complex,
                        a: *const c_double_complex, lda: c_int,
                        b: *const c_double_complex, ldb: c_int,
                        beta: *const c_double_complex,
                        c: *mut c_double_complex, ldc: c_int);
    pub fn cblas_ztrmm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       b: *mut c_double_complex, ldb: c_int);
    pub fn cblas_ztrsm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, transa: CBLAS_TRANSPOSE,
                       diag: CBLAS_DIAG, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       b: *mut c_double_complex, ldb: c_int);

    // Prefixes C and Z only
    pub fn cblas_chemm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int,
                       alpha: *const c_float_complex,
                       a: *const c_float_complex, lda: c_int,
                       b: *const c_float_complex, ldb: c_int,
                       beta: *const c_float_complex, c: *mut c_float_complex,
                       ldc: c_int);
    pub fn cblas_cherk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: c_float, a: *const c_float_complex, lda: c_int,
                       beta: c_float, c: *mut c_float_complex, ldc: c_int);
    pub fn cblas_cher2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: *const c_float_complex,
                        a: *const c_float_complex, lda: c_int,
                        b: *const c_float_complex, ldb: c_int, beta: c_float,
                        c: *mut c_float_complex, ldc: c_int);

    pub fn cblas_zhemm(layout: CBLAS_LAYOUT, side: CBLAS_SIDE,
                       uplo: CBLAS_UPLO, m: c_int, n: c_int,
                       alpha: *const c_double_complex,
                       a: *const c_double_complex, lda: c_int,
                       b: *const c_double_complex, ldb: c_int,
                       beta: *const c_double_complex,
                       c: *mut c_double_complex, ldc: c_int);
    pub fn cblas_zherk(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                       trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                       alpha: c_double, a: *const c_double_complex,
                       lda: c_int, beta: c_double, c: *mut c_double_complex,
                       ldc: c_int);
    pub fn cblas_zher2k(layout: CBLAS_LAYOUT, uplo: CBLAS_UPLO,
                        trans: CBLAS_TRANSPOSE, n: c_int, k: c_int,
                        alpha: *const c_double_complex,
                        a: *const c_double_complex, lda: c_int,
                        b: *const c_double_complex, ldb: c_int,
                        beta: c_double, c: *mut c_double_complex, ldc: c_int);
}

extern "C" {
    pub fn cblas_xerbla(p: c_int, rout: *const c_char, form: *const c_char,
                        ...);
}