File: cblas_wrappers.cc

package info (click to toggle)
lapackpp 2024.10.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,500 kB
  • sloc: cpp: 80,181; ansic: 27,660; python: 4,838; xml: 182; perl: 99; makefile: 53; sh: 23
file content (117 lines) | stat: -rw-r--r-- 3,755 bytes parent folder | download
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
// Copyright (c) 2017-2023, University of Tennessee. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
// This program is free software: you can redistribute it and/or modify it under
// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.

// Function definitions moved from cblas_wrappers.hh for ESSL compatability.

#include "lapack/fortran.h"
#include "cblas_wrappers.hh"

#include <complex>

// -----------------------------------------------------------------------------
void
cblas_symv(
    CBLAS_LAYOUT layout,
    CBLAS_UPLO uplo,
    int n,
    std::complex<float> alpha,
    std::complex<float> const* A, int lda,
    std::complex<float> const* x, int incx,
    std::complex<float> beta,
    std::complex<float>* yref, int incy )
{
    lapack_int n_    = lapack_int( n );
    lapack_int incx_ = lapack_int( incx );
    lapack_int incy_ = lapack_int( incy );
    lapack_int lda_  = lapack_int( lda );
    char uplo_ = lapack_uplo_const( uplo );
    if (layout == CblasRowMajor) {
        uplo_ = (uplo == CblasUpper ? 'l' : 'u');  // switch upper <=> lower
    }
    LAPACK_csymv(
        &uplo_, &n_,
        (lapack_complex_float*) &alpha,
        (lapack_complex_float*) A, &lda_,
        (lapack_complex_float*) x, &incx_,
        (lapack_complex_float*) &beta,
        (lapack_complex_float*) yref, &incy_
    );
}

// -----------------------------------------------------------------------------
void
cblas_symv(
    CBLAS_LAYOUT layout,
    CBLAS_UPLO uplo,
    int n,
    std::complex<double> alpha,
    std::complex<double> const* A, int lda,
    std::complex<double> const* x, int incx,
    std::complex<double> beta,
    std::complex<double>* yref, int incy )
{
    lapack_int n_    = lapack_int( n );
    lapack_int incx_ = lapack_int( incx );
    lapack_int incy_ = lapack_int( incy );
    lapack_int lda_  = lapack_int( lda );
    char uplo_ = lapack_uplo_const( uplo );
    if (layout == CblasRowMajor) {
        uplo_ = (uplo == CblasUpper ? 'l' : 'u');  // switch upper <=> lower
    }
    LAPACK_zsymv(
        &uplo_, &n_,
        (lapack_complex_double*) &alpha,
        (lapack_complex_double*) A, &lda_,
        (lapack_complex_double*) x, &incx_,
        (lapack_complex_double*) &beta,
        (lapack_complex_double*) yref, &incy_
    );
}

// -----------------------------------------------------------------------------
void
cblas_syr(
    CBLAS_LAYOUT layout, CBLAS_UPLO uplo, int n,
    std::complex<float> alpha,
    std::complex<float> const *x, int incx,
    std::complex<float>* A, int lda )
{
    lapack_int n_    = lapack_int( n );
    lapack_int incx_ = lapack_int( incx );
    lapack_int lda_  = lapack_int( lda );
    char uplo_ = lapack_uplo_const( uplo );
    if (layout == CblasRowMajor) {
        uplo_ = (uplo == CblasUpper ? 'l' : 'u');  // switch upper <=> lower
    }
    LAPACK_csyr(
        &uplo_, &n_,
        (lapack_complex_float*) &alpha,
        (lapack_complex_float*) x, &incx_,
        (lapack_complex_float*) A, &lda_
    );
}

// -----------------------------------------------------------------------------
void
cblas_syr(
    CBLAS_LAYOUT layout, CBLAS_UPLO uplo, int n,
    std::complex<double> alpha,
    std::complex<double> const *x, int incx,
    std::complex<double>* A, int lda )
{
    lapack_int n_    = lapack_int( n );
    lapack_int incx_ = lapack_int( incx );
    lapack_int lda_  = lapack_int( lda );
    char uplo_ = lapack_uplo_const( uplo );
    if (layout == CblasRowMajor) {
        uplo_ = (uplo == CblasUpper ? 'l' : 'u');  // switch upper <=> lower
    }
    LAPACK_zsyr(
        &uplo_, &n_,
        (lapack_complex_double*) &alpha,
        (lapack_complex_double*) x, &incx_,
        (lapack_complex_double*) A, &lda_
    );
}