├── .gitignore ├── LICENSE ├── README.md ├── _config.yml ├── changelog.org ├── nimblas.nim ├── nimblas.nimble ├── nimblas ├── cblas.nim └── private │ └── common.nim └── tests └── test.nim /.gitignore: -------------------------------------------------------------------------------- 1 | tests/test 2 | nimcache -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BLAS for Nim 2 | 3 | This is a Nim wrapper for the [BLAS](http://www.netlib.org/blas/) routines. 4 | 5 | You can `import nimblas/cblas` to use the standard BLAS interface, or just 6 | `import nimblas` for a version that is more Nim-friendly. 7 | 8 | The Nim version removes the prefixes and uses dispatch based on types instead. 9 | This means that, for instance, both `cblas_saxpy` and `cblas_daxpy` become 10 | simply `axpy`, and the correct version is chosen by checking the size of 11 | parameters at the usage site. 12 | 13 | Only a subset of BLAS is available under `nimblas`, with more operations added 14 | on necessity. 15 | 16 | For a higher-level linear algebra library based on this, check out 17 | - [neo](https://andreaferretti.github.io/neo/) 18 | - [arraymancer](https://github.com/mratsim/Arraymancer). 19 | 20 | ## Linking BLAS implementations 21 | 22 | The library requires to link some BLAS implementation to perform the actual 23 | linear algebra operations. By default, it tries to link whatever is the default 24 | system-wide BLAS implementation. 25 | 26 | You can link against a different BLAS implementation by a combination of: 27 | 28 | * changing the path for linked libraries (use 29 | [`--clibdir`](https://nim-lang.org/docs/nimc.html#compiler-usage-command-line-switches) 30 | for this). 31 | * using the `--define:blas` flag. By default (i.e. if you don't set this flag), the system 32 | tries to load a BLAS library by looking for the most common blas library file names according 33 | to the underling operating system (e.g. `blas.dll`, `openblas.dll`, `libopenblas.dll`, 34 | `mkl_intel_lp64.dll` in Windows, `libblas.so`, `libcblas.so` or `libopenblas.so` on Linux, etc). 35 | However, if you want to link to one specific library, skipping the automatic search, you can 36 | specify it with this flag. For instance, the Linux Arch distribution and its derivatives (such 37 | as Manjaro) expose the C API for BLAS inside a library called `libcblas.so` (unlike most other 38 | distributions that put it into `libblas.so`). To explicitly link with that library, you can set 39 | `--define:blas=cblas`. Note the missing `lib` prefix and `.so` suffix, which nimblas adds automatically 40 | (similarly on windows you should not include the `.dll` extension when setting this flag). 41 | 42 | For more examples, see the tasks inside [nimblas.nimble](https://github.com/SciNim/nimblas/blob/master/nimblas.nimble). 43 | 44 | (Previously there was a more ad hoc mechanism using flags called `-d:atlas`, 45 | `-d:openblas` or `-d:mkl`, which is deprecated as of NimBLAS 0.2.) 46 | 47 | Packages for various BLAS implementations are available from the package 48 | managers of many Linux distributions. On OSX one can add the brew formulas 49 | from [Homebrew Science](https://github.com/Homebrew/homebrew-science), such 50 | as `brew install homebrew/science/openblas`. On Windows you can download pre-built 51 | binaries from the [OpenBLAS github repository](https://github.com/OpenMathLib/OpenBLAS/releases) 52 | and add the library folder to your PATH or copy it into your executable folder. 53 | 54 | You may also need to add suitable paths for the includes and library dirs. 55 | On OSX, this should do the trick 56 | 57 | ```nim 58 | switch("clibdir", "/usr/local/opt/openblas/lib") 59 | switch("cincludes", "/usr/local/opt/openblas/include") 60 | ``` 61 | 62 | If you have problems with MKL, you may want to link it statically. Just pass 63 | the options 64 | 65 | ```nim 66 | --dynlibOverride:mkl_intel_lp64 67 | --passL:${PATH_TO_MKL}/libmkl_intel_lp64.a 68 | ``` 69 | 70 | to enable static linking. -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: Nimblas 2 | description: BLAS for Nim 3 | google_analytics: 4 | show_downloads: true 5 | theme: jekyll-theme-cayman 6 | 7 | gems: 8 | - jekyll-mentions 9 | -------------------------------------------------------------------------------- /changelog.org: -------------------------------------------------------------------------------- 1 | * v0.3.1 2 | - improve message for BLAS library usage (#11) 3 | * v0.3.0 4 | - smarter library detection (PR #9) 5 | -------------------------------------------------------------------------------- /nimblas.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2015-2017 UniCredit S.p.A. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include nimblas/private/common 16 | import complex 17 | 18 | type 19 | IndexType* = csize 20 | TransposeType* {.size: sizeof(int).} = enum 21 | noTranspose = 111, transpose = 112, conjTranspose = 113 22 | OrderType* {.size: sizeof(int).} = enum 23 | rowMajor = 101, colMajor = 102 24 | UploType* {.size: sizeof(int).} = enum 25 | upper = 121, lower = 122 26 | DiagType* {.size: sizeof(int).} = enum 27 | nonUnit = 131, unit = 132 28 | SideType* {.size: sizeof(int).} = enum 29 | left = 141, right = 142 30 | 31 | 32 | # 33 | # =========================================================================== 34 | # Prototypes for level 1 BLAS functions (complex are recast as routines) 35 | # =========================================================================== 36 | # 37 | 38 | proc dot*(N: int; alpha: float32; X: ptr float32; incX: int; Y: ptr float32; incY: int): float32 {. 39 | importc: "cblas_sdsdot", dynlib: libName.} 40 | # TODO: fix ambiguous between dsdot(f32,f32)->f64 and sdot(f32,f32)->f32 41 | # proc dot*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int): float64 {. 42 | # importc: "cblas_dsdot", dynlib: libName.} 43 | proc dot*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int): float32 {. 44 | importc: "cblas_sdot", dynlib: libName.} 45 | proc dot*(N: int; X: ptr float64; incX: int; Y: ptr float64; incY: int): float64 {. 46 | importc: "cblas_ddot", dynlib: libName.} 47 | # 48 | # Functions having prefixes Z and C only 49 | # 50 | 51 | proc dotu*(N: int; X: ptr Complex32; incX: int; Y: ptr Complex32; incY: int; dotu: ptr Complex32) {. 52 | importc: "cblas_cdotu_sub", dynlib: libName.} 53 | proc dotu*(N: int; X: ptr Complex64; incX: int; Y: ptr Complex64; incY: int; dotu: ptr Complex64) {. 54 | importc: "cblas_zdotu_sub", dynlib: libName.} 55 | proc dotc*(N: int; X: ptr Complex32; incX: int; Y: ptr Complex32; incY: int; dotc: ptr Complex32) {. 56 | importc: "cblas_cdotc_sub", dynlib: libName.} 57 | proc dotc*(N: int; X: ptr Complex64; incX: int; Y: ptr Complex64; incY: int; dotc: ptr Complex64) {. 58 | importc: "cblas_zdotc_sub", dynlib: libName.} 59 | # 60 | # Functions having prefixes S D SC DZ 61 | # 62 | 63 | proc nrm2*(N: int; X: ptr float32; incX: int): float32 {.importc: "cblas_snrm2", 64 | dynlib: libName.} 65 | proc nrm2*(N: int; X: ptr float64; incX: int): float64 {.importc: "cblas_dnrm2", 66 | dynlib: libName.} 67 | proc nrm2*(N: int; X: ptr Complex32; incX: int): float32 {.importc: "cblas_scnrm2", 68 | dynlib: libName.} 69 | proc nrm2*(N: int; X: ptr Complex64; incX: int): float64 {.importc: "cblas_dznrm2", 70 | dynlib: libName.} 71 | 72 | proc asum*(N: int; X: ptr float32; incX: int): float32 {.importc: "cblas_sasum", 73 | dynlib: libName.} 74 | proc asum*(N: int; X: ptr float64; incX: int): float64 {.importc: "cblas_dasum", 75 | dynlib: libName.} 76 | proc asum*(N: int; X: ptr Complex32; incX: int): float32 {.importc: "cblas_scasum", 77 | dynlib: libName.} 78 | proc asum*(N: int; X: ptr Complex64; incX: int): float64 {.importc: "cblas_dzasum", 79 | dynlib: libName.} 80 | # 81 | # Functions having standard 4 prefixes (S D C Z) 82 | # 83 | 84 | proc iamax*(N: int; X: ptr float32; incX: int): IndexType {.importc: "cblas_isamax", 85 | dynlib: libName.} 86 | proc iamax*(N: int; X: ptr float64; incX: int): IndexType {.importc: "cblas_idamax", 87 | dynlib: libName.} 88 | proc iamax*(N: int; X: ptr Complex32; incX: int): IndexType {.importc: "cblas_icamax", 89 | dynlib: libName.} 90 | proc iamax*(N: int; X: ptr Complex64; incX: int): IndexType {.importc: "cblas_izamax", 91 | dynlib: libName.} 92 | # 93 | # =========================================================================== 94 | # Prototypes for level 1 BLAS routines 95 | # =========================================================================== 96 | # 97 | # 98 | # Routines with standard 4 prefixes (s, d, c, z) 99 | # 100 | 101 | proc swap*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int) {. 102 | importc: "cblas_sswap", dynlib: libName.} 103 | proc swap*(N: int; X: ptr float64; incX: int; Y: ptr float64; incY: int) {. 104 | importc: "cblas_dswap", dynlib: libName.} 105 | proc swap*(N: int; X: ptr Complex32; incX: int; Y: ptr Complex32; incY: int) {. 106 | importc: "cblas_cswap", dynlib: libName.} 107 | proc swap*(N: int; X: ptr Complex64; incX: int; Y: ptr Complex64; incY: int) {. 108 | importc: "cblas_zswap", dynlib: libName.} 109 | 110 | proc copy*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int) {. 111 | importc: "cblas_scopy", dynlib: libName.} 112 | proc copy*(N: int; X: ptr float64; incX: int; Y: ptr float64; incY: int) {. 113 | importc: "cblas_dcopy", dynlib: libName.} 114 | proc copy*(N: int; X: ptr Complex32; incX: int; Y: ptr Complex32; incY: int) {. 115 | importc: "cblas_ccopy", dynlib: libName.} 116 | proc copy*(N: int; X: ptr Complex64; incX: int; Y: ptr Complex64; incY: int) {. 117 | importc: "cblas_zcopy", dynlib: libName.} 118 | 119 | proc axpy*(N: int; alpha: float32; X: ptr float32; incX: int; Y: ptr float32; incY: int) {. 120 | importc: "cblas_saxpy", dynlib: libName.} 121 | proc axpy*(N: int; alpha: float64; X: ptr float64; incX: int; Y: ptr float64; incY: int) {. 122 | importc: "cblas_daxpy", dynlib: libName.} 123 | proc axpy*(N: int; alpha: ptr Complex32; X: ptr Complex32; incX: int; Y: ptr Complex32; incY: int) {. 124 | importc: "cblas_caxpy", dynlib: libName.} 125 | proc axpy*(N: int; alpha: ptr Complex64; X: ptr Complex64; incX: int; Y: ptr Complex64; incY: int) {. 126 | importc: "cblas_zaxpy", dynlib: libName.} 127 | 128 | # 129 | # Routines with S and D prefix only 130 | # 131 | 132 | proc rotg*(a: ptr float32; b: ptr float32; c: ptr float32; s: ptr float32) {. 133 | importc: "cblas_srotg", dynlib: libName.} 134 | proc rotg*(a: ptr float64; b: ptr float64; c: ptr float64; s: ptr float64) {. 135 | importc: "cblas_drotg", dynlib: libName.} 136 | 137 | proc rotmg*(d1: ptr float32; d2: ptr float32; b1: ptr float32; b2: float32; P: ptr float32) {. 138 | importc: "cblas_srotmg", dynlib: libName.} 139 | proc rotmg*(d1: ptr float64; d2: ptr float64; b1: ptr float64; b2: float64; P: ptr float64) {. 140 | importc: "cblas_drotmg", dynlib: libName.} 141 | 142 | proc rot*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int; c: float32; s: float32) {. 143 | importc: "cblas_srot", dynlib: libName.} 144 | proc rot*(N: int; X: ptr float64; incX: int; Y: ptr float64; incY: int; c: float64; 145 | s: float64) {.importc: "cblas_drot", dynlib: libName.} 146 | proc rotm*(N: int; X: ptr float32; incX: int; Y: ptr float32; incY: int; P: ptr float32) {. 147 | importc: "cblas_srotm", dynlib: libName.} 148 | proc rotm*(N: int; X: ptr float64; incX: int; Y: ptr float64; incY: int; P: ptr float64) {. 149 | importc: "cblas_drotm", dynlib: libName.} 150 | # 151 | # Routines with S D C Z CS and ZD prefixes 152 | # 153 | 154 | proc scal*(N: int; alpha: float32; X: ptr float32; incX: int) {.importc: "cblas_sscal", 155 | dynlib: libName.} 156 | proc scal*(N: int; alpha: float64; X: ptr float64; incX: int) {.importc: "cblas_dscal", 157 | dynlib: libName.} 158 | proc scal*(N: int; alpha: ptr Complex32; X: ptr Complex32; incX: int) {.importc: "cblas_cscal", 159 | dynlib: libName.} 160 | proc scal*(N: int; alpha: ptr Complex64; X: ptr Complex64; incX: int) {.importc: "cblas_zscal", 161 | dynlib: libName.} 162 | proc scal*(N: int; alpha: float32; X: ptr Complex32; incX: int) {.importc: "cblas_csscal", 163 | dynlib: libName.} 164 | proc scal*(N: int; alpha: float64; X: ptr Complex64; incX: int) {.importc: "cblas_zdscal", 165 | dynlib: libName.} 166 | # 167 | # =========================================================================== 168 | # Prototypes for level 2 BLAS 169 | # =========================================================================== 170 | # 171 | # 172 | # Routines with standard 4 prefixes (S, D, C, Z) 173 | # 174 | 175 | proc gemv*(order: OrderType; TransA: TransposeType; M: int; N: int; alpha: float32; 176 | A: ptr float32; lda: int; X: ptr float32; incX: int; beta: float32; Y: ptr float32; 177 | incY: int) {.importc: "cblas_sgemv", dynlib: libName.} 178 | proc gemv*(order: OrderType; TransA: TransposeType; M: int; N: int; 179 | alpha: float64; A: ptr float64; lda: int; X: ptr float64; incX: int; 180 | beta: float64; Y: ptr float64; incY: int) {.importc: "cblas_dgemv", 181 | dynlib: libName.} 182 | proc gemv*(order: OrderType; TransA: TransposeType; M: int; N: int; 183 | alpha: ptr Complex32; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int; beta: ptr Complex32; 184 | Y: ptr Complex32; incY: int) {.importc: "cblas_cgemv", dynlib: libName.} 185 | proc gemv*(order: OrderType; TransA: TransposeType; M: int; N: int; 186 | alpha: ptr Complex64; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int; beta: ptr Complex64; 187 | Y: ptr Complex64; incY: int) {.importc: "cblas_zgemv", dynlib: libName.} 188 | 189 | 190 | proc trmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 191 | Diag: DiagType; N: int; A: ptr float32; lda: int; X: ptr float32; incX: int) {. 192 | importc: "cblas_strmv", dynlib: libName.} 193 | proc trmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 194 | Diag: DiagType; N: int; A: ptr float64; lda: int; X: ptr float64; incX: int) {. 195 | importc: "cblas_dtrmv", dynlib: libName.} 196 | proc trmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 197 | Diag: DiagType; N: int; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int) {. 198 | importc: "cblas_ctrmv", dynlib: libName.} 199 | proc trmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 200 | Diag: DiagType; N: int; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int) {. 201 | importc: "cblas_ztrmv", dynlib: libName.} 202 | 203 | 204 | proc trsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 205 | Diag: DiagType; N: int; A: ptr float32; lda: int; X: ptr float32; incX: int) {. 206 | importc: "cblas_strsv", dynlib: libName.} 207 | proc trsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 208 | Diag: DiagType; N: int; A: ptr float64; lda: int; X: ptr float64; incX: int) {. 209 | importc: "cblas_dtrsv", dynlib: libName.} 210 | proc trsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 211 | Diag: DiagType; N: int; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int) {. 212 | importc: "cblas_ctrsv", dynlib: libName.} 213 | proc trsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 214 | Diag: DiagType; N: int; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int) {. 215 | importc: "cblas_ztrsv", dynlib: libName.} 216 | 217 | proc gbmv*(order: OrderType; TransA: TransposeType; M: int; N: int; KL: int; 218 | KU: int; alpha: float32; A: ptr float32; lda: int; X: ptr float32; incX: int; 219 | beta: float32; Y: ptr float32; incY: int) {.importc: "cblas_sgbmv", 220 | dynlib: libName.} 221 | proc gbmv*(order: OrderType; TransA: TransposeType; M: int; N: int; KL: int; 222 | KU: int; alpha: float64; A: ptr float64; lda: int; X: ptr float64; incX: int; 223 | beta: float64; Y: ptr float64; incY: int) {.importc: "cblas_dgbmv", 224 | dynlib: libName.} 225 | proc gbmv*(order: OrderType; TransA: TransposeType; M: int; N: int; KL: int; 226 | KU: int; alpha: ptr Complex32; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int; 227 | beta: ptr Complex32; Y: ptr Complex32; incY: int) {.importc: "cblas_cgbmv", 228 | dynlib: libName.} 229 | proc gbmv*(order: OrderType; TransA: TransposeType; M: int; N: int; KL: int; 230 | KU: int; alpha: ptr Complex64; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int; 231 | beta: ptr Complex64; Y: ptr Complex64; incY: int) {.importc: "cblas_zgbmv", 232 | dynlib: libName.} 233 | 234 | 235 | proc tbmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 236 | Diag: DiagType; N: int; K: int; A: ptr float32; lda: int; X: ptr float32; 237 | incX: int) {.importc: "cblas_stbmv", dynlib: libName.} 238 | proc tbmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 239 | Diag: DiagType; N: int; K: int; A: ptr float64; lda: int; X: ptr float64; 240 | incX: int) {.importc: "cblas_dtbmv", dynlib: libName.} 241 | proc tbmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 242 | Diag: DiagType; N: int; K: int; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int) {. 243 | importc: "cblas_ctbmv", dynlib: libName.} 244 | proc tbmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 245 | Diag: DiagType; N: int; K: int; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int) {. 246 | importc: "cblas_ztbmv", dynlib: libName.} 247 | 248 | 249 | proc tpmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 250 | Diag: DiagType; N: int; Ap: ptr float32; X: ptr float32; incX: int) {. 251 | importc: "cblas_stpmv", dynlib: libName.} 252 | proc tpmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 253 | Diag: DiagType; N: int; Ap: ptr float64; X: ptr float64; incX: int) {. 254 | importc: "cblas_dtpmv", dynlib: libName.} 255 | proc tpmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 256 | Diag: DiagType; N: int; Ap: ptr Complex32; X: ptr Complex32; incX: int) {. 257 | importc: "cblas_ctpmv", dynlib: libName.} 258 | proc tpmv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 259 | Diag: DiagType; N: int; Ap: ptr Complex64; X: ptr Complex64; incX: int) {. 260 | importc: "cblas_ztpmv", dynlib: libName.} 261 | 262 | proc tbsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 263 | Diag: DiagType; N: int; K: int; A: ptr float32; lda: int; X: ptr float32; 264 | incX: int) {.importc: "cblas_stbsv", dynlib: libName.} 265 | proc tbsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 266 | Diag: DiagType; N: int; K: int; A: ptr float64; lda: int; X: ptr float64; 267 | incX: int) {.importc: "cblas_dtbsv", dynlib: libName.} 268 | proc tbsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 269 | Diag: DiagType; N: int; K: int; A: ptr Complex32; lda: int; X: ptr Complex32; incX: int) {. 270 | importc: "cblas_ctbsv", dynlib: libName.} 271 | proc tbsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 272 | Diag: DiagType; N: int; K: int; A: ptr Complex64; lda: int; X: ptr Complex64; incX: int) {. 273 | importc: "cblas_ztbsv", dynlib: libName.} 274 | 275 | 276 | proc tpsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 277 | Diag: DiagType; N: int; Ap: ptr float32; X: ptr float32; incX: int) {. 278 | importc: "cblas_stpsv", dynlib: libName.} 279 | proc tpsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 280 | Diag: DiagType; N: int; Ap: ptr float64; X: ptr float64; incX: int) {. 281 | importc: "cblas_dtpsv", dynlib: libName.} 282 | proc tpsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 283 | Diag: DiagType; N: int; Ap: ptr Complex32; X: ptr Complex32; incX: int) {. 284 | importc: "cblas_ctpsv", dynlib: libName.} 285 | proc tpsv*(order: OrderType; Uplo: UploType; TransA: TransposeType; 286 | Diag: DiagType; N: int; Ap: ptr Complex64; X: ptr Complex64; incX: int) {. 287 | importc: "cblas_ztpsv", dynlib: libName.} 288 | # 289 | # Routines with S and D prefixes only 290 | # 291 | 292 | proc symv*(order: OrderType; Uplo: UploType; N: int; alpha: float32; A: ptr float32; 293 | lda: int; X: ptr float32; incX: int; beta: float32; Y: ptr float32; incY: int) {. 294 | importc: "cblas_ssymv", dynlib: libName.} 295 | proc symv*(order: OrderType; Uplo: UploType; N: int; alpha: float64; 296 | A: ptr float64; lda: int; X: ptr float64; incX: int; beta: float64; 297 | Y: ptr float64; incY: int) {.importc: "cblas_dsymv", dynlib: libName.} 298 | 299 | 300 | proc sbmv*(order: OrderType; Uplo: UploType; N: int; K: int; alpha: float32; 301 | A: ptr float32; lda: int; X: ptr float32; incX: int; beta: float32; Y: ptr float32; 302 | incY: int) {.importc: "cblas_ssbmv", dynlib: libName.} 303 | proc sbmv*(order: OrderType; Uplo: UploType; N: int; K: int; alpha: float64; 304 | A: ptr float64; lda: int; X: ptr float64; incX: int; beta: float64; 305 | Y: ptr float64; incY: int) {.importc: "cblas_dsbmv", dynlib: libName.} 306 | 307 | 308 | proc spmv*(order: OrderType; Uplo: UploType; N: int; alpha: float32; Ap: ptr float32; 309 | X: ptr float32; incX: int; beta: float32; Y: ptr float32; incY: int) {. 310 | importc: "cblas_sspmv", dynlib: libName.} 311 | proc spmv*(order: OrderType; Uplo: UploType; N: int; alpha: float64; 312 | Ap: ptr float64; X: ptr float64; incX: int; beta: float64; Y: ptr float64; 313 | incY: int) {.importc: "cblas_dspmv", dynlib: libName.} 314 | 315 | 316 | proc ger*(order: OrderType; M: int; N: int; alpha: float32; X: ptr float32; incX: int; 317 | Y: ptr float32; incY: int; A: ptr float32; lda: int) {.importc: "cblas_sger", 318 | dynlib: libName.} 319 | proc ger*(order: OrderType; M: int; N: int; alpha: float64; X: ptr float64; incX: int; 320 | Y: ptr float64; incY: int; A: ptr float64; lda: int) {.importc: "cblas_dger", 321 | dynlib: libName.} 322 | 323 | 324 | proc syr*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr float32; 325 | incX: int; A: ptr float32; lda: int) {.importc: "cblas_ssyr", dynlib: libName.} 326 | proc syr*(order: OrderType; Uplo: UploType; N: int; alpha: float64; X: ptr float64; 327 | incX: int; A: ptr float64; lda: int) {.importc: "cblas_dsyr", dynlib: libName.} 328 | 329 | 330 | proc spr*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr float32; 331 | incX: int; Ap: ptr float32) {.importc: "cblas_sspr", dynlib: libName.} 332 | proc spr*(order: OrderType; Uplo: UploType; N: int; alpha: float64; X: ptr float64; 333 | incX: int; Ap: ptr float64) {.importc: "cblas_dspr", dynlib: libName.} 334 | 335 | 336 | proc syr2*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr float32; 337 | incX: int; Y: ptr float32; incY: int; A: ptr float32; lda: int) {. 338 | importc: "cblas_ssyr2", dynlib: libName.} 339 | proc syr2*(order: OrderType; Uplo: UploType; N: int; alpha: float64; 340 | X: ptr float64; incX: int; Y: ptr float64; incY: int; A: ptr float64; lda: int) {. 341 | importc: "cblas_dsyr2", dynlib: libName.} 342 | 343 | 344 | proc spr2*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr float32; 345 | incX: int; Y: ptr float32; incY: int; A: ptr float32) {.importc: "cblas_sspr2", 346 | dynlib: libName.} 347 | proc spr2*(order: OrderType; Uplo: UploType; N: int; alpha: float64; 348 | X: ptr float64; incX: int; Y: ptr float64; incY: int; A: ptr float64) {. 349 | importc: "cblas_dspr2", dynlib: libName.} 350 | # 351 | # Routines with C and Z prefixes only 352 | # 353 | 354 | proc chemv*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex32; A: ptr Complex32; 355 | lda: int; X: ptr Complex32; incX: int; beta: ptr Complex32; Y: ptr Complex32; incY: int) {. 356 | importc: "cblas_chemv", dynlib: libName.} 357 | proc zhemv*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex64; A: ptr Complex64; 358 | lda: int; X: ptr Complex64; incX: int; beta: ptr Complex64; Y: ptr Complex64; incY: int) {. 359 | importc: "cblas_zhemv", dynlib: libName.} 360 | 361 | 362 | proc chbmv*(order: OrderType; Uplo: UploType; N: int; K: int; alpha: ptr Complex32; 363 | A: ptr Complex32; lda: int; X: ptr Complex32; incX: int; beta: ptr Complex32; Y: ptr Complex32; 364 | incY: int) {.importc: "cblas_chbmv", dynlib: libName.} 365 | proc zhbmv*(order: OrderType; Uplo: UploType; N: int; K: int; alpha: ptr Complex64; 366 | A: ptr Complex64; lda: int; X: ptr Complex64; incX: int; beta: ptr Complex64; Y: ptr Complex64; 367 | incY: int) {.importc: "cblas_zhbmv", dynlib: libName.} 368 | 369 | 370 | proc chpmv*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex32; Ap: ptr Complex32; 371 | X: ptr Complex32; incX: int; beta: ptr Complex32; Y: ptr Complex32; incY: int) {. 372 | importc: "cblas_chpmv", dynlib: libName.} 373 | proc zhpmv*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex64; Ap: ptr Complex64; 374 | X: ptr Complex64; incX: int; beta: ptr Complex64; Y: ptr Complex64; incY: int) {. 375 | importc: "cblas_zhpmv", dynlib: libName.} 376 | 377 | 378 | proc cgeru*(order: OrderType; M: int; N: int; alpha: ptr Complex32; X: ptr Complex32; incX: int; 379 | Y: ptr Complex32; incY: int; A: ptr Complex32; lda: int) {.importc: "cblas_cgeru", 380 | dynlib: libName.} 381 | proc zgeru*(order: OrderType; M: int; N: int; alpha: ptr Complex64; X: ptr Complex64; incX: int; 382 | Y: ptr Complex64; incY: int; A: ptr Complex64; lda: int) {.importc: "cblas_zgeru", 383 | dynlib: libName.} 384 | 385 | 386 | proc cgerc*(order: OrderType; M: int; N: int; alpha: ptr Complex32; X: ptr Complex32; incX: int; 387 | Y: ptr Complex32; incY: int; A: ptr Complex32; lda: int) {.importc: "cblas_cgerc", 388 | dynlib: libName.} 389 | proc zgerc*(order: OrderType; M: int; N: int; alpha: ptr Complex64; X: ptr Complex64; incX: int; 390 | Y: ptr Complex64; incY: int; A: ptr Complex64; lda: int) {.importc: "cblas_zgerc", 391 | dynlib: libName.} 392 | 393 | 394 | proc cher*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr Complex32; 395 | incX: int; A: ptr Complex32; lda: int) {.importc: "cblas_cher", dynlib: libName.} 396 | proc zher*(order: OrderType; Uplo: UploType; N: int; alpha: float64; X: ptr Complex64; 397 | incX: int; A: ptr Complex64; lda: int) {.importc: "cblas_zher", dynlib: libName.} 398 | 399 | 400 | proc chpr*(order: OrderType; Uplo: UploType; N: int; alpha: float32; X: ptr Complex32; 401 | incX: int; A: ptr Complex32) {.importc: "cblas_chpr", dynlib: libName.} 402 | proc zhpr*(order: OrderType; Uplo: UploType; N: int; alpha: float64; X: ptr Complex64; 403 | incX: int; A: ptr Complex64) {.importc: "cblas_zhpr", dynlib: libName.} 404 | 405 | 406 | proc cher2*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex32; X: ptr Complex32; 407 | incX: int; Y: ptr Complex32; incY: int; A: ptr Complex32; lda: int) {. 408 | importc: "cblas_cher2", dynlib: libName.} 409 | proc zher2*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex64; X: ptr Complex64; 410 | incX: int; Y: ptr Complex64; incY: int; A: ptr Complex64; lda: int) {. 411 | importc: "cblas_zher2", dynlib: libName.} 412 | 413 | 414 | proc chpr2*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex32; X: ptr Complex32; 415 | incX: int; Y: ptr Complex32; incY: int; Ap: ptr Complex32) {.importc: "cblas_chpr2", 416 | dynlib: libName.} 417 | proc zhpr2*(order: OrderType; Uplo: UploType; N: int; alpha: ptr Complex64; X: ptr Complex64; 418 | incX: int; Y: ptr Complex64; incY: int; Ap: ptr Complex64) {.importc: "cblas_zhpr2", 419 | dynlib: libName.} 420 | # 421 | # =========================================================================== 422 | # Prototypes for level 3 BLAS 423 | # =========================================================================== 424 | # 425 | # 426 | # Routines with standard 4 prefixes (S, D, C, Z) 427 | # 428 | 429 | proc gemm*(Order: OrderType; TransA: TransposeType; TransB: TransposeType; 430 | M: int; N: int; K: int; alpha: float32; A: ptr float32; lda: int; B: ptr float32; 431 | ldb: int; beta: float32; C: ptr float32; ldc: int) {.importc: "cblas_sgemm", 432 | dynlib: libName.} 433 | proc gemm*(Order: OrderType; TransA: TransposeType; TransB: TransposeType; 434 | M: int; N: int; K: int; alpha: float64; A: ptr float64; lda: int; 435 | B: ptr float64; ldb: int; beta: float64; C: ptr float64; ldc: int) {. 436 | importc: "cblas_dgemm", dynlib: libName.} 437 | proc gemm*(Order: OrderType; TransA: TransposeType; TransB: TransposeType; 438 | M: int; N: int; K: int; alpha: ptr Complex32; A: ptr Complex32; lda: int; B: ptr Complex32; 439 | ldb: int; beta: ptr Complex32; C: ptr Complex32; ldc: int) {.importc: "cblas_cgemm", 440 | dynlib: libName.} 441 | proc gemm*(Order: OrderType; TransA: TransposeType; TransB: TransposeType; 442 | M: int; N: int; K: int; alpha: ptr Complex64; A: ptr Complex64; lda: int; B: ptr Complex64; 443 | ldb: int; beta: ptr Complex64; C: ptr Complex64; ldc: int) {.importc: "cblas_zgemm", 444 | dynlib: libName.} 445 | 446 | 447 | proc symm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 448 | alpha: float32; A: ptr float32; lda: int; B: ptr float32; ldb: int; beta: float32; 449 | C: ptr float32; ldc: int) {.importc: "cblas_ssymm", dynlib: libName.} 450 | proc symm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 451 | alpha: float64; A: ptr float64; lda: int; B: ptr float64; ldb: int; 452 | beta: float64; C: ptr float64; ldc: int) {.importc: "cblas_dsymm", 453 | dynlib: libName.} 454 | proc symm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 455 | alpha: ptr Complex32; A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int; beta: ptr Complex32; 456 | C: ptr Complex32; ldc: int) {.importc: "cblas_csymm", dynlib: libName.} 457 | proc symm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 458 | alpha: ptr Complex64; A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int; beta: ptr Complex64; 459 | C: ptr Complex64; ldc: int) {.importc: "cblas_zsymm", dynlib: libName.} 460 | 461 | 462 | proc syrk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 463 | K: int; alpha: float32; A: ptr float32; lda: int; beta: float32; C: ptr float32; 464 | ldc: int) {.importc: "cblas_ssyrk", dynlib: libName.} 465 | proc syrk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 466 | K: int; alpha: float64; A: ptr float64; lda: int; beta: float64; 467 | C: ptr float64; ldc: int) {.importc: "cblas_dsyrk", dynlib: libName.} 468 | proc syrk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 469 | K: int; alpha: ptr Complex32; A: ptr Complex32; lda: int; beta: ptr Complex32; C: ptr Complex32; 470 | ldc: int) {.importc: "cblas_csyrk", dynlib: libName.} 471 | proc syrk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 472 | K: int; alpha: ptr Complex64; A: ptr Complex64; lda: int; beta: ptr Complex64; C: ptr Complex64; 473 | ldc: int) {.importc: "cblas_zsyrk", dynlib: libName.} 474 | 475 | 476 | proc syr2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 477 | K: int; alpha: float32; A: ptr float32; lda: int; B: ptr float32; ldb: int; 478 | beta: float32; C: ptr float32; ldc: int) {.importc: "cblas_ssyr2k", 479 | dynlib: libName.} 480 | proc syr2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 481 | K: int; alpha: float64; A: ptr float64; lda: int; B: ptr float64; ldb: int; 482 | beta: float64; C: ptr float64; ldc: int) {.importc: "cblas_dsyr2k", 483 | dynlib: libName.} 484 | proc syr2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 485 | K: int; alpha: ptr Complex32; A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int; 486 | beta: ptr Complex32; C: ptr Complex32; ldc: int) {.importc: "cblas_csyr2k", 487 | dynlib: libName.} 488 | proc syr2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 489 | K: int; alpha: ptr Complex64; A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int; 490 | beta: ptr Complex64; C: ptr Complex64; ldc: int) {.importc: "cblas_zsyr2k", 491 | dynlib: libName.} 492 | 493 | 494 | proc trmm*(Order: OrderType; Side: SideType; Uplo: UploType; 495 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: float32; 496 | A: ptr float32; lda: int; B: ptr float32; ldb: int) {.importc: "cblas_strmm", 497 | dynlib: libName.} 498 | proc trmm*(Order: OrderType; Side: SideType; Uplo: UploType; 499 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: float64; 500 | A: ptr float64; lda: int; B: ptr float64; ldb: int) {.importc: "cblas_dtrmm", 501 | dynlib: libName.} 502 | proc trmm*(Order: OrderType; Side: SideType; Uplo: UploType; 503 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: ptr Complex32; 504 | A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int) {.importc: "cblas_ctrmm", 505 | dynlib: libName.} 506 | proc trmm*(Order: OrderType; Side: SideType; Uplo: UploType; 507 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: ptr Complex64; 508 | A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int) {.importc: "cblas_ztrmm", 509 | dynlib: libName.} 510 | 511 | 512 | proc trsm*(Order: OrderType; Side: SideType; Uplo: UploType; 513 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: float32; 514 | A: ptr float32; lda: int; B: ptr float32; ldb: int) {.importc: "cblas_strsm", 515 | dynlib: libName.} 516 | proc trsm*(Order: OrderType; Side: SideType; Uplo: UploType; 517 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: float64; 518 | A: ptr float64; lda: int; B: ptr float64; ldb: int) {.importc: "cblas_dtrsm", 519 | dynlib: libName.} 520 | proc trsm*(Order: OrderType; Side: SideType; Uplo: UploType; 521 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: ptr Complex32; 522 | A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int) {.importc: "cblas_ctrsm", 523 | dynlib: libName.} 524 | proc trsm*(Order: OrderType; Side: SideType; Uplo: UploType; 525 | TransA: TransposeType; Diag: DiagType; M: int; N: int; alpha: ptr Complex64; 526 | A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int) {.importc: "cblas_ztrsm", 527 | dynlib: libName.} 528 | # 529 | # Routines with prefixes C and Z only 530 | # 531 | 532 | proc hemm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 533 | alpha: ptr Complex32; A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int; beta: ptr Complex32; 534 | C: ptr Complex32; ldc: int) {.importc: "cblas_chemm", dynlib: libName.} 535 | proc hemm*(Order: OrderType; Side: SideType; Uplo: UploType; M: int; N: int; 536 | alpha: ptr Complex64; A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int; beta: ptr Complex64; 537 | C: ptr Complex64; ldc: int) {.importc: "cblas_zhemm", dynlib: libName.} 538 | 539 | 540 | proc herk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 541 | K: int; alpha: float32; A: ptr Complex32; lda: int; beta: float32; C: ptr Complex32; 542 | ldc: int) {.importc: "cblas_cherk", dynlib: libName.} 543 | proc herk*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 544 | K: int; alpha: float64; A: ptr Complex64; lda: int; beta: float64; C: ptr Complex64; 545 | ldc: int) {.importc: "cblas_zherk", dynlib: libName.} 546 | 547 | 548 | proc her2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 549 | K: int; alpha: ptr Complex32; A: ptr Complex32; lda: int; B: ptr Complex32; ldb: int; 550 | beta: float32; C: ptr Complex32; ldc: int) {.importc: "cblas_cher2k", 551 | dynlib: libName.} 552 | proc her2k*(Order: OrderType; Uplo: UploType; Trans: TransposeType; N: int; 553 | K: int; alpha: ptr Complex64; A: ptr Complex64; lda: int; B: ptr Complex64; ldb: int; 554 | beta: float64; C: ptr Complex64; ldc: int) {.importc: "cblas_zher2k", 555 | dynlib: libName.} 556 | -------------------------------------------------------------------------------- /nimblas.nimble: -------------------------------------------------------------------------------- 1 | version = "0.3.1" 2 | author = "Andrea Ferretti" 3 | description = "BLAS interface for Nim" 4 | license = "Apache2" 5 | skipDirs = @["tests"] 6 | 7 | requires "nim >= 0.19.9" 8 | 9 | proc configForTests() = 10 | --hints: off 11 | --linedir: on 12 | --stacktrace: on 13 | --linetrace: on 14 | --debuginfo 15 | --path: "." 16 | --run 17 | 18 | task test, "run NimBLAS tests": 19 | configForTests() 20 | setCommand "c", "tests/test.nim" 21 | 22 | task testopenblas, "run NimBLAS tests with openBLAS": 23 | configForTests() 24 | --define:"blas=openblas" 25 | setCommand "c", "tests/test.nim" 26 | 27 | task testatlas, "run NimBLAS tests with ATLAS": 28 | configForTests() 29 | --define:"blas=cblas" 30 | setCommand "c", "tests/test.nim" 31 | 32 | task testmkl, "run NimBLAS tests with MKL": 33 | configForTests() 34 | --define:"blas=mkl_intel_lp64" 35 | --clibdir: "/opt/intel/mkl/lib/intel64" 36 | --passl: "/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.a" 37 | --passl: "-lmkl_core" 38 | --passl: "-lmkl_sequential" 39 | --passl: "-lpthread" 40 | --passl: "-lm" 41 | --dynlibOverride:mkl_intel_lp64 42 | setCommand "c", "tests/test.nim" 43 | 44 | task testmklthreaded, "run NimBLAS tests with MKL threaded": 45 | configForTests() 46 | --define: "blas=mkl_intel_lp64" 47 | --clibdir: "/opt/intel/mkl/lib/intel64" 48 | --passl: "/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.a" 49 | --passl: "-lmkl_core" 50 | --passl: "-lmkl_gnu_thread" 51 | --passl: "-lgomp" 52 | --passl: "-lm" 53 | --dynlibOverride:mkl_intel_lp64 54 | setCommand "c", "tests/test.nim" 55 | 56 | task tests, "run tests with all BLAS versions": 57 | exec("nimble test") 58 | exec("nimble testopenblas") 59 | exec("nimble testatlas") 60 | exec("nimble testmkl") 61 | exec("nimble testmklthreaded") 62 | -------------------------------------------------------------------------------- /nimblas/cblas.nim: -------------------------------------------------------------------------------- 1 | include private/common 2 | 3 | # Allow the use in C++ code. 4 | 5 | # 6 | # Enumerated and derived types 7 | # 8 | 9 | type 10 | CBLAS_INDEX* = int 11 | 12 | type 13 | CBLAS_ORDER* {.size: sizeof(cint).} = enum 14 | CblasRowMajor = 101, CblasColMajor = 102 15 | 16 | 17 | type 18 | CBLAS_TRANSPOSE* {.size: sizeof(cint).} = enum 19 | CblasNoTrans = 111, CblasTrans = 112, CblasConjTrans = 113 20 | 21 | 22 | type 23 | CBLAS_UPLO* {.size: sizeof(cint).} = enum 24 | CblasUpper = 121, CblasLower = 122 25 | 26 | 27 | type 28 | CBLAS_DIAG* {.size: sizeof(cint).} = enum 29 | CblasNonUnit = 131, CblasUnit = 132 30 | 31 | 32 | type 33 | CBLAS_SIDE* {.size: sizeof(cint).} = enum 34 | CblasLeft = 141, CblasRight = 142 35 | 36 | 37 | # 38 | # =========================================================================== 39 | # Prototypes for level 1 BLAS functions (complex are recast as routines) 40 | # =========================================================================== 41 | # 42 | 43 | proc sdsdot*(N: cint; alpha: cfloat; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint): cfloat {. 44 | importc: "cblas_sdsdot", dynlib: libName.} 45 | proc dsdot*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint): cdouble {. 46 | importc: "cblas_dsdot", dynlib: libName.} 47 | proc sdot*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint): cfloat {. 48 | importc: "cblas_sdot", dynlib: libName.} 49 | proc ddot*(N: cint; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint): cdouble {. 50 | importc: "cblas_ddot", dynlib: libName.} 51 | # 52 | # Functions having prefixes Z and C only 53 | # 54 | 55 | proc cdotu_sub*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint; dotu: pointer) {. 56 | importc: "cblas_cdotu_sub", dynlib: libName.} 57 | proc cdotc_sub*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint; dotc: pointer) {. 58 | importc: "cblas_cdotc_sub", dynlib: libName.} 59 | proc zdotu_sub*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint; dotu: pointer) {. 60 | importc: "cblas_zdotu_sub", dynlib: libName.} 61 | proc zdotc_sub*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint; dotc: pointer) {. 62 | importc: "cblas_zdotc_sub", dynlib: libName.} 63 | # 64 | # Functions having prefixes S D SC DZ 65 | # 66 | 67 | proc snrm2*(N: cint; X: ptr cfloat; incX: cint): cfloat {.importc: "cblas_snrm2", 68 | dynlib: libName.} 69 | proc sasum*(N: cint; X: ptr cfloat; incX: cint): cfloat {.importc: "cblas_sasum", 70 | dynlib: libName.} 71 | proc dnrm2*(N: cint; X: ptr cdouble; incX: cint): cdouble {.importc: "cblas_dnrm2", 72 | dynlib: libName.} 73 | proc dasum*(N: cint; X: ptr cdouble; incX: cint): cdouble {.importc: "cblas_dasum", 74 | dynlib: libName.} 75 | proc scnrm2*(N: cint; X: pointer; incX: cint): cfloat {.importc: "cblas_scnrm2", 76 | dynlib: libName.} 77 | proc scasum*(N: cint; X: pointer; incX: cint): cfloat {.importc: "cblas_scasum", 78 | dynlib: libName.} 79 | proc dznrm2*(N: cint; X: pointer; incX: cint): cdouble {.importc: "cblas_dznrm2", 80 | dynlib: libName.} 81 | proc dzasum*(N: cint; X: pointer; incX: cint): cdouble {.importc: "cblas_dzasum", 82 | dynlib: libName.} 83 | # 84 | # Functions having standard 4 prefixes (S D C Z) 85 | # 86 | 87 | proc isamax*(N: cint; X: ptr cfloat; incX: cint): CBLAS_INDEX {.importc: "cblas_isamax", 88 | dynlib: libName.} 89 | proc idamax*(N: cint; X: ptr cdouble; incX: cint): CBLAS_INDEX {.importc: "cblas_idamax", 90 | dynlib: libName.} 91 | proc icamax*(N: cint; X: pointer; incX: cint): CBLAS_INDEX {.importc: "cblas_icamax", 92 | dynlib: libName.} 93 | proc izamax*(N: cint; X: pointer; incX: cint): CBLAS_INDEX {.importc: "cblas_izamax", 94 | dynlib: libName.} 95 | # 96 | # =========================================================================== 97 | # Prototypes for level 1 BLAS routines 98 | # =========================================================================== 99 | # 100 | # 101 | # Routines with standard 4 prefixes (s, d, c, z) 102 | # 103 | 104 | proc sswap*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint) {. 105 | importc: "cblas_sswap", dynlib: libName.} 106 | proc scopy*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint) {. 107 | importc: "cblas_scopy", dynlib: libName.} 108 | proc saxpy*(N: cint; alpha: cfloat; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint) {. 109 | importc: "cblas_saxpy", dynlib: libName.} 110 | proc dswap*(N: cint; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint) {. 111 | importc: "cblas_dswap", dynlib: libName.} 112 | proc dcopy*(N: cint; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint) {. 113 | importc: "cblas_dcopy", dynlib: libName.} 114 | proc daxpy*(N: cint; alpha: cdouble; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint) {. 115 | importc: "cblas_daxpy", dynlib: libName.} 116 | proc cswap*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint) {. 117 | importc: "cblas_cswap", dynlib: libName.} 118 | proc ccopy*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint) {. 119 | importc: "cblas_ccopy", dynlib: libName.} 120 | proc caxpy*(N: cint; alpha: pointer; X: pointer; incX: cint; Y: pointer; incY: cint) {. 121 | importc: "cblas_caxpy", dynlib: libName.} 122 | proc zswap*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint) {. 123 | importc: "cblas_zswap", dynlib: libName.} 124 | proc zcopy*(N: cint; X: pointer; incX: cint; Y: pointer; incY: cint) {. 125 | importc: "cblas_zcopy", dynlib: libName.} 126 | proc zaxpy*(N: cint; alpha: pointer; X: pointer; incX: cint; Y: pointer; incY: cint) {. 127 | importc: "cblas_zaxpy", dynlib: libName.} 128 | # 129 | # Routines with S and D prefix only 130 | # 131 | 132 | proc srotg*(a: ptr cfloat; b: ptr cfloat; c: ptr cfloat; s: ptr cfloat) {. 133 | importc: "cblas_srotg", dynlib: libName.} 134 | proc srotmg*(d1: ptr cfloat; d2: ptr cfloat; b1: ptr cfloat; b2: cfloat; P: ptr cfloat) {. 135 | importc: "cblas_srotmg", dynlib: libName.} 136 | proc srot*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint; c: cfloat; s: cfloat) {. 137 | importc: "cblas_srot", dynlib: libName.} 138 | proc srotm*(N: cint; X: ptr cfloat; incX: cint; Y: ptr cfloat; incY: cint; P: ptr cfloat) {. 139 | importc: "cblas_srotm", dynlib: libName.} 140 | proc drotg*(a: ptr cdouble; b: ptr cdouble; c: ptr cdouble; s: ptr cdouble) {. 141 | importc: "cblas_drotg", dynlib: libName.} 142 | proc drotmg*(d1: ptr cdouble; d2: ptr cdouble; b1: ptr cdouble; b2: cdouble; P: ptr cdouble) {. 143 | importc: "cblas_drotmg", dynlib: libName.} 144 | proc drot*(N: cint; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint; c: cdouble; 145 | s: cdouble) {.importc: "cblas_drot", dynlib: libName.} 146 | proc drotm*(N: cint; X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint; P: ptr cdouble) {. 147 | importc: "cblas_drotm", dynlib: libName.} 148 | # 149 | # Routines with S D C Z CS and ZD prefixes 150 | # 151 | 152 | proc sscal*(N: cint; alpha: cfloat; X: ptr cfloat; incX: cint) {.importc: "cblas_sscal", 153 | dynlib: libName.} 154 | proc dscal*(N: cint; alpha: cdouble; X: ptr cdouble; incX: cint) {.importc: "cblas_dscal", 155 | dynlib: libName.} 156 | proc cscal*(N: cint; alpha: pointer; X: pointer; incX: cint) {.importc: "cblas_cscal", 157 | dynlib: libName.} 158 | proc zscal*(N: cint; alpha: pointer; X: pointer; incX: cint) {.importc: "cblas_zscal", 159 | dynlib: libName.} 160 | proc csscal*(N: cint; alpha: cfloat; X: pointer; incX: cint) {.importc: "cblas_csscal", 161 | dynlib: libName.} 162 | proc zdscal*(N: cint; alpha: cdouble; X: pointer; incX: cint) {.importc: "cblas_zdscal", 163 | dynlib: libName.} 164 | # 165 | # =========================================================================== 166 | # Prototypes for level 2 BLAS 167 | # =========================================================================== 168 | # 169 | # 170 | # Routines with standard 4 prefixes (S, D, C, Z) 171 | # 172 | 173 | proc sgemv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; alpha: cfloat; 174 | A: ptr cfloat; lda: cint; X: ptr cfloat; incX: cint; beta: cfloat; Y: ptr cfloat; 175 | incY: cint) {.importc: "cblas_sgemv", dynlib: libName.} 176 | proc sgbmv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; KL: cint; 177 | KU: cint; alpha: cfloat; A: ptr cfloat; lda: cint; X: ptr cfloat; incX: cint; 178 | beta: cfloat; Y: ptr cfloat; incY: cint) {.importc: "cblas_sgbmv", 179 | dynlib: libName.} 180 | proc strmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 181 | Diag: CBLAS_DIAG; N: cint; A: ptr cfloat; lda: cint; X: ptr cfloat; incX: cint) {. 182 | importc: "cblas_strmv", dynlib: libName.} 183 | proc stbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 184 | Diag: CBLAS_DIAG; N: cint; K: cint; A: ptr cfloat; lda: cint; X: ptr cfloat; 185 | incX: cint) {.importc: "cblas_stbmv", dynlib: libName.} 186 | proc stpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 187 | Diag: CBLAS_DIAG; N: cint; Ap: ptr cfloat; X: ptr cfloat; incX: cint) {. 188 | importc: "cblas_stpmv", dynlib: libName.} 189 | proc strsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 190 | Diag: CBLAS_DIAG; N: cint; A: ptr cfloat; lda: cint; X: ptr cfloat; incX: cint) {. 191 | importc: "cblas_strsv", dynlib: libName.} 192 | proc stbsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 193 | Diag: CBLAS_DIAG; N: cint; K: cint; A: ptr cfloat; lda: cint; X: ptr cfloat; 194 | incX: cint) {.importc: "cblas_stbsv", dynlib: libName.} 195 | proc stpsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 196 | Diag: CBLAS_DIAG; N: cint; Ap: ptr cfloat; X: ptr cfloat; incX: cint) {. 197 | importc: "cblas_stpsv", dynlib: libName.} 198 | proc dgemv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; 199 | alpha: cdouble; A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint; 200 | beta: cdouble; Y: ptr cdouble; incY: cint) {.importc: "cblas_dgemv", 201 | dynlib: libName.} 202 | proc dgbmv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; KL: cint; 203 | KU: cint; alpha: cdouble; A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint; 204 | beta: cdouble; Y: ptr cdouble; incY: cint) {.importc: "cblas_dgbmv", 205 | dynlib: libName.} 206 | proc dtrmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 207 | Diag: CBLAS_DIAG; N: cint; A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint) {. 208 | importc: "cblas_dtrmv", dynlib: libName.} 209 | proc dtbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 210 | Diag: CBLAS_DIAG; N: cint; K: cint; A: ptr cdouble; lda: cint; X: ptr cdouble; 211 | incX: cint) {.importc: "cblas_dtbmv", dynlib: libName.} 212 | proc dtpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 213 | Diag: CBLAS_DIAG; N: cint; Ap: ptr cdouble; X: ptr cdouble; incX: cint) {. 214 | importc: "cblas_dtpmv", dynlib: libName.} 215 | proc dtrsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 216 | Diag: CBLAS_DIAG; N: cint; A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint) {. 217 | importc: "cblas_dtrsv", dynlib: libName.} 218 | proc dtbsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 219 | Diag: CBLAS_DIAG; N: cint; K: cint; A: ptr cdouble; lda: cint; X: ptr cdouble; 220 | incX: cint) {.importc: "cblas_dtbsv", dynlib: libName.} 221 | proc dtpsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 222 | Diag: CBLAS_DIAG; N: cint; Ap: ptr cdouble; X: ptr cdouble; incX: cint) {. 223 | importc: "cblas_dtpsv", dynlib: libName.} 224 | proc cgemv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; 225 | alpha: pointer; A: pointer; lda: cint; X: pointer; incX: cint; beta: pointer; 226 | Y: pointer; incY: cint) {.importc: "cblas_cgemv", dynlib: libName.} 227 | proc cgbmv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; KL: cint; 228 | KU: cint; alpha: pointer; A: pointer; lda: cint; X: pointer; incX: cint; 229 | beta: pointer; Y: pointer; incY: cint) {.importc: "cblas_cgbmv", 230 | dynlib: libName.} 231 | proc ctrmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 232 | Diag: CBLAS_DIAG; N: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 233 | importc: "cblas_ctrmv", dynlib: libName.} 234 | proc ctbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 235 | Diag: CBLAS_DIAG; N: cint; K: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 236 | importc: "cblas_ctbmv", dynlib: libName.} 237 | proc ctpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 238 | Diag: CBLAS_DIAG; N: cint; Ap: pointer; X: pointer; incX: cint) {. 239 | importc: "cblas_ctpmv", dynlib: libName.} 240 | proc ctrsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 241 | Diag: CBLAS_DIAG; N: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 242 | importc: "cblas_ctrsv", dynlib: libName.} 243 | proc ctbsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 244 | Diag: CBLAS_DIAG; N: cint; K: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 245 | importc: "cblas_ctbsv", dynlib: libName.} 246 | proc ctpsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 247 | Diag: CBLAS_DIAG; N: cint; Ap: pointer; X: pointer; incX: cint) {. 248 | importc: "cblas_ctpsv", dynlib: libName.} 249 | proc zgemv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; 250 | alpha: pointer; A: pointer; lda: cint; X: pointer; incX: cint; beta: pointer; 251 | Y: pointer; incY: cint) {.importc: "cblas_zgemv", dynlib: libName.} 252 | proc zgbmv*(order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; M: cint; N: cint; KL: cint; 253 | KU: cint; alpha: pointer; A: pointer; lda: cint; X: pointer; incX: cint; 254 | beta: pointer; Y: pointer; incY: cint) {.importc: "cblas_zgbmv", 255 | dynlib: libName.} 256 | proc ztrmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 257 | Diag: CBLAS_DIAG; N: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 258 | importc: "cblas_ztrmv", dynlib: libName.} 259 | proc ztbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 260 | Diag: CBLAS_DIAG; N: cint; K: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 261 | importc: "cblas_ztbmv", dynlib: libName.} 262 | proc ztpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 263 | Diag: CBLAS_DIAG; N: cint; Ap: pointer; X: pointer; incX: cint) {. 264 | importc: "cblas_ztpmv", dynlib: libName.} 265 | proc ztrsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 266 | Diag: CBLAS_DIAG; N: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 267 | importc: "cblas_ztrsv", dynlib: libName.} 268 | proc ztbsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 269 | Diag: CBLAS_DIAG; N: cint; K: cint; A: pointer; lda: cint; X: pointer; incX: cint) {. 270 | importc: "cblas_ztbsv", dynlib: libName.} 271 | proc ztpsv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; TransA: CBLAS_TRANSPOSE; 272 | Diag: CBLAS_DIAG; N: cint; Ap: pointer; X: pointer; incX: cint) {. 273 | importc: "cblas_ztpsv", dynlib: libName.} 274 | # 275 | # Routines with S and D prefixes only 276 | # 277 | 278 | proc ssymv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; A: ptr cfloat; 279 | lda: cint; X: ptr cfloat; incX: cint; beta: cfloat; Y: ptr cfloat; incY: cint) {. 280 | importc: "cblas_ssymv", dynlib: libName.} 281 | proc ssbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; K: cint; alpha: cfloat; 282 | A: ptr cfloat; lda: cint; X: ptr cfloat; incX: cint; beta: cfloat; Y: ptr cfloat; 283 | incY: cint) {.importc: "cblas_ssbmv", dynlib: libName.} 284 | proc sspmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; Ap: ptr cfloat; 285 | X: ptr cfloat; incX: cint; beta: cfloat; Y: ptr cfloat; incY: cint) {. 286 | importc: "cblas_sspmv", dynlib: libName.} 287 | proc sger*(order: CBLAS_ORDER; M: cint; N: cint; alpha: cfloat; X: ptr cfloat; incX: cint; 288 | Y: ptr cfloat; incY: cint; A: ptr cfloat; lda: cint) {.importc: "cblas_sger", 289 | dynlib: libName.} 290 | proc ssyr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: ptr cfloat; 291 | incX: cint; A: ptr cfloat; lda: cint) {.importc: "cblas_ssyr", dynlib: libName.} 292 | proc sspr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: ptr cfloat; 293 | incX: cint; Ap: ptr cfloat) {.importc: "cblas_sspr", dynlib: libName.} 294 | proc ssyr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: ptr cfloat; 295 | incX: cint; Y: ptr cfloat; incY: cint; A: ptr cfloat; lda: cint) {. 296 | importc: "cblas_ssyr2", dynlib: libName.} 297 | proc sspr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: ptr cfloat; 298 | incX: cint; Y: ptr cfloat; incY: cint; A: ptr cfloat) {.importc: "cblas_sspr2", 299 | dynlib: libName.} 300 | proc dsymv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; 301 | A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint; beta: cdouble; 302 | Y: ptr cdouble; incY: cint) {.importc: "cblas_dsymv", dynlib: libName.} 303 | proc dsbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; K: cint; alpha: cdouble; 304 | A: ptr cdouble; lda: cint; X: ptr cdouble; incX: cint; beta: cdouble; 305 | Y: ptr cdouble; incY: cint) {.importc: "cblas_dsbmv", dynlib: libName.} 306 | proc dspmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; 307 | Ap: ptr cdouble; X: ptr cdouble; incX: cint; beta: cdouble; Y: ptr cdouble; 308 | incY: cint) {.importc: "cblas_dspmv", dynlib: libName.} 309 | proc dger*(order: CBLAS_ORDER; M: cint; N: cint; alpha: cdouble; X: ptr cdouble; incX: cint; 310 | Y: ptr cdouble; incY: cint; A: ptr cdouble; lda: cint) {.importc: "cblas_dger", 311 | dynlib: libName.} 312 | proc dsyr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; X: ptr cdouble; 313 | incX: cint; A: ptr cdouble; lda: cint) {.importc: "cblas_dsyr", dynlib: libName.} 314 | proc dspr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; X: ptr cdouble; 315 | incX: cint; Ap: ptr cdouble) {.importc: "cblas_dspr", dynlib: libName.} 316 | proc dsyr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; 317 | X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint; A: ptr cdouble; lda: cint) {. 318 | importc: "cblas_dsyr2", dynlib: libName.} 319 | proc dspr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; 320 | X: ptr cdouble; incX: cint; Y: ptr cdouble; incY: cint; A: ptr cdouble) {. 321 | importc: "cblas_dspr2", dynlib: libName.} 322 | # 323 | # Routines with C and Z prefixes only 324 | # 325 | 326 | proc chemv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; A: pointer; 327 | lda: cint; X: pointer; incX: cint; beta: pointer; Y: pointer; incY: cint) {. 328 | importc: "cblas_chemv", dynlib: libName.} 329 | proc chbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; K: cint; alpha: pointer; 330 | A: pointer; lda: cint; X: pointer; incX: cint; beta: pointer; Y: pointer; 331 | incY: cint) {.importc: "cblas_chbmv", dynlib: libName.} 332 | proc chpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; Ap: pointer; 333 | X: pointer; incX: cint; beta: pointer; Y: pointer; incY: cint) {. 334 | importc: "cblas_chpmv", dynlib: libName.} 335 | proc cgeru*(order: CBLAS_ORDER; M: cint; N: cint; alpha: pointer; X: pointer; incX: cint; 336 | Y: pointer; incY: cint; A: pointer; lda: cint) {.importc: "cblas_cgeru", 337 | dynlib: libName.} 338 | proc cgerc*(order: CBLAS_ORDER; M: cint; N: cint; alpha: pointer; X: pointer; incX: cint; 339 | Y: pointer; incY: cint; A: pointer; lda: cint) {.importc: "cblas_cgerc", 340 | dynlib: libName.} 341 | proc cher*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: pointer; 342 | incX: cint; A: pointer; lda: cint) {.importc: "cblas_cher", dynlib: libName.} 343 | proc chpr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cfloat; X: pointer; 344 | incX: cint; A: pointer) {.importc: "cblas_chpr", dynlib: libName.} 345 | proc cher2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; X: pointer; 346 | incX: cint; Y: pointer; incY: cint; A: pointer; lda: cint) {. 347 | importc: "cblas_cher2", dynlib: libName.} 348 | proc chpr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; X: pointer; 349 | incX: cint; Y: pointer; incY: cint; Ap: pointer) {.importc: "cblas_chpr2", 350 | dynlib: libName.} 351 | proc zhemv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; A: pointer; 352 | lda: cint; X: pointer; incX: cint; beta: pointer; Y: pointer; incY: cint) {. 353 | importc: "cblas_zhemv", dynlib: libName.} 354 | proc zhbmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; K: cint; alpha: pointer; 355 | A: pointer; lda: cint; X: pointer; incX: cint; beta: pointer; Y: pointer; 356 | incY: cint) {.importc: "cblas_zhbmv", dynlib: libName.} 357 | proc zhpmv*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; Ap: pointer; 358 | X: pointer; incX: cint; beta: pointer; Y: pointer; incY: cint) {. 359 | importc: "cblas_zhpmv", dynlib: libName.} 360 | proc zgeru*(order: CBLAS_ORDER; M: cint; N: cint; alpha: pointer; X: pointer; incX: cint; 361 | Y: pointer; incY: cint; A: pointer; lda: cint) {.importc: "cblas_zgeru", 362 | dynlib: libName.} 363 | proc zgerc*(order: CBLAS_ORDER; M: cint; N: cint; alpha: pointer; X: pointer; incX: cint; 364 | Y: pointer; incY: cint; A: pointer; lda: cint) {.importc: "cblas_zgerc", 365 | dynlib: libName.} 366 | proc zher*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; X: pointer; 367 | incX: cint; A: pointer; lda: cint) {.importc: "cblas_zher", dynlib: libName.} 368 | proc zhpr*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: cdouble; X: pointer; 369 | incX: cint; A: pointer) {.importc: "cblas_zhpr", dynlib: libName.} 370 | proc zher2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; X: pointer; 371 | incX: cint; Y: pointer; incY: cint; A: pointer; lda: cint) {. 372 | importc: "cblas_zher2", dynlib: libName.} 373 | proc zhpr2*(order: CBLAS_ORDER; Uplo: CBLAS_UPLO; N: cint; alpha: pointer; X: pointer; 374 | incX: cint; Y: pointer; incY: cint; Ap: pointer) {.importc: "cblas_zhpr2", 375 | dynlib: libName.} 376 | # 377 | # =========================================================================== 378 | # Prototypes for level 3 BLAS 379 | # =========================================================================== 380 | # 381 | # 382 | # Routines with standard 4 prefixes (S, D, C, Z) 383 | # 384 | 385 | proc sgemm*(Order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; TransB: CBLAS_TRANSPOSE; 386 | M: cint; N: cint; K: cint; alpha: cfloat; A: ptr cfloat; lda: cint; B: ptr cfloat; 387 | ldb: cint; beta: cfloat; C: ptr cfloat; ldc: cint) {.importc: "cblas_sgemm", 388 | dynlib: libName.} 389 | proc ssymm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 390 | alpha: cfloat; A: ptr cfloat; lda: cint; B: ptr cfloat; ldb: cint; beta: cfloat; 391 | C: ptr cfloat; ldc: cint) {.importc: "cblas_ssymm", dynlib: libName.} 392 | proc ssyrk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 393 | K: cint; alpha: cfloat; A: ptr cfloat; lda: cint; beta: cfloat; C: ptr cfloat; 394 | ldc: cint) {.importc: "cblas_ssyrk", dynlib: libName.} 395 | proc ssyr2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 396 | K: cint; alpha: cfloat; A: ptr cfloat; lda: cint; B: ptr cfloat; ldb: cint; 397 | beta: cfloat; C: ptr cfloat; ldc: cint) {.importc: "cblas_ssyr2k", 398 | dynlib: libName.} 399 | proc strmm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 400 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: cfloat; 401 | A: ptr cfloat; lda: cint; B: ptr cfloat; ldb: cint) {.importc: "cblas_strmm", 402 | dynlib: libName.} 403 | proc strsm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 404 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: cfloat; 405 | A: ptr cfloat; lda: cint; B: ptr cfloat; ldb: cint) {.importc: "cblas_strsm", 406 | dynlib: libName.} 407 | proc dgemm*(Order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; TransB: CBLAS_TRANSPOSE; 408 | M: cint; N: cint; K: cint; alpha: cdouble; A: ptr cdouble; lda: cint; 409 | B: ptr cdouble; ldb: cint; beta: cdouble; C: ptr cdouble; ldc: cint) {. 410 | importc: "cblas_dgemm", dynlib: libName.} 411 | proc dsymm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 412 | alpha: cdouble; A: ptr cdouble; lda: cint; B: ptr cdouble; ldb: cint; 413 | beta: cdouble; C: ptr cdouble; ldc: cint) {.importc: "cblas_dsymm", 414 | dynlib: libName.} 415 | proc dsyrk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 416 | K: cint; alpha: cdouble; A: ptr cdouble; lda: cint; beta: cdouble; 417 | C: ptr cdouble; ldc: cint) {.importc: "cblas_dsyrk", dynlib: libName.} 418 | proc dsyr2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 419 | K: cint; alpha: cdouble; A: ptr cdouble; lda: cint; B: ptr cdouble; ldb: cint; 420 | beta: cdouble; C: ptr cdouble; ldc: cint) {.importc: "cblas_dsyr2k", 421 | dynlib: libName.} 422 | proc dtrmm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 423 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: cdouble; 424 | A: ptr cdouble; lda: cint; B: ptr cdouble; ldb: cint) {.importc: "cblas_dtrmm", 425 | dynlib: libName.} 426 | proc dtrsm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 427 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: cdouble; 428 | A: ptr cdouble; lda: cint; B: ptr cdouble; ldb: cint) {.importc: "cblas_dtrsm", 429 | dynlib: libName.} 430 | proc cgemm*(Order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; TransB: CBLAS_TRANSPOSE; 431 | M: cint; N: cint; K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; 432 | ldb: cint; beta: pointer; C: pointer; ldc: cint) {.importc: "cblas_cgemm", 433 | dynlib: libName.} 434 | proc csymm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 435 | alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; beta: pointer; 436 | C: pointer; ldc: cint) {.importc: "cblas_csymm", dynlib: libName.} 437 | proc csyrk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 438 | K: cint; alpha: pointer; A: pointer; lda: cint; beta: pointer; C: pointer; 439 | ldc: cint) {.importc: "cblas_csyrk", dynlib: libName.} 440 | proc csyr2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 441 | K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; 442 | beta: pointer; C: pointer; ldc: cint) {.importc: "cblas_csyr2k", 443 | dynlib: libName.} 444 | proc ctrmm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 445 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: pointer; 446 | A: pointer; lda: cint; B: pointer; ldb: cint) {.importc: "cblas_ctrmm", 447 | dynlib: libName.} 448 | proc ctrsm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 449 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: pointer; 450 | A: pointer; lda: cint; B: pointer; ldb: cint) {.importc: "cblas_ctrsm", 451 | dynlib: libName.} 452 | proc zgemm*(Order: CBLAS_ORDER; TransA: CBLAS_TRANSPOSE; TransB: CBLAS_TRANSPOSE; 453 | M: cint; N: cint; K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; 454 | ldb: cint; beta: pointer; C: pointer; ldc: cint) {.importc: "cblas_zgemm", 455 | dynlib: libName.} 456 | proc zsymm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 457 | alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; beta: pointer; 458 | C: pointer; ldc: cint) {.importc: "cblas_zsymm", dynlib: libName.} 459 | proc zsyrk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 460 | K: cint; alpha: pointer; A: pointer; lda: cint; beta: pointer; C: pointer; 461 | ldc: cint) {.importc: "cblas_zsyrk", dynlib: libName.} 462 | proc zsyr2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 463 | K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; 464 | beta: pointer; C: pointer; ldc: cint) {.importc: "cblas_zsyr2k", 465 | dynlib: libName.} 466 | proc ztrmm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 467 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: pointer; 468 | A: pointer; lda: cint; B: pointer; ldb: cint) {.importc: "cblas_ztrmm", 469 | dynlib: libName.} 470 | proc ztrsm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; 471 | TransA: CBLAS_TRANSPOSE; Diag: CBLAS_DIAG; M: cint; N: cint; alpha: pointer; 472 | A: pointer; lda: cint; B: pointer; ldb: cint) {.importc: "cblas_ztrsm", 473 | dynlib: libName.} 474 | # 475 | # Routines with prefixes C and Z only 476 | # 477 | 478 | proc chemm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 479 | alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; beta: pointer; 480 | C: pointer; ldc: cint) {.importc: "cblas_chemm", dynlib: libName.} 481 | proc cherk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 482 | K: cint; alpha: cfloat; A: pointer; lda: cint; beta: cfloat; C: pointer; 483 | ldc: cint) {.importc: "cblas_cherk", dynlib: libName.} 484 | proc cher2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 485 | K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; 486 | beta: cfloat; C: pointer; ldc: cint) {.importc: "cblas_cher2k", 487 | dynlib: libName.} 488 | proc zhemm*(Order: CBLAS_ORDER; Side: CBLAS_SIDE; Uplo: CBLAS_UPLO; M: cint; N: cint; 489 | alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; beta: pointer; 490 | C: pointer; ldc: cint) {.importc: "cblas_zhemm", dynlib: libName.} 491 | proc zherk*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 492 | K: cint; alpha: cdouble; A: pointer; lda: cint; beta: cdouble; C: pointer; 493 | ldc: cint) {.importc: "cblas_zherk", dynlib: libName.} 494 | proc zher2k*(Order: CBLAS_ORDER; Uplo: CBLAS_UPLO; Trans: CBLAS_TRANSPOSE; N: cint; 495 | K: cint; alpha: pointer; A: pointer; lda: cint; B: pointer; ldb: cint; 496 | beta: cdouble; C: pointer; ldc: cint) {.importc: "cblas_zher2k", 497 | dynlib: libName.} 498 | # proc xerbla*(p: cint; rout: cstring; form: cstring) {.varargs, importc: "cblas_xerbla", 499 | # dynlib: libName.} -------------------------------------------------------------------------------- /nimblas/private/common.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2015-2017 UniCredit S.p.A. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | when defined(windows): 16 | const 17 | libSuffix = ".dll" 18 | libPrefix = "(lib|)" 19 | blas {.strdefine.} = "(blas|openblas|mkl_intel_lp64)" 20 | elif defined(macosx): 21 | const 22 | libSuffix = ".dylib" 23 | libPrefix = "lib" 24 | blas {.strdefine.} = "blas" 25 | else: 26 | const 27 | libSuffix = ".so(|.3|.2|.1|.0)" 28 | libPrefix = "lib" 29 | blas {.strdefine.} = "(blas|cblas|openblas)" 30 | 31 | const 32 | libName = libPrefix & blas & libSuffix 33 | 34 | when defined(atlas): 35 | {.warning: """ 36 | The flag -d:atlas is deprecated since NimBLAS 0.2 37 | Use -d:blas=LIBNAME instead 38 | """ .} 39 | 40 | when defined(openblas): 41 | {.warning: """ 42 | The flag -d:openblas is deprecated since NimBLAS 0.2 43 | Use -d:blas=LIBNAME instead 44 | """ .} 45 | 46 | when defined(mkl): 47 | {.warning: """ 48 | The flag -d:mkl is deprecated since NimBLAS 0.2 49 | Use -d:blas=LIBNAME instead 50 | """ .} 51 | 52 | {.hint: 53 | if '|' in libName: 54 | "Using BLAS library matching pattern: " & libName 55 | else: 56 | "Using BLAS library with name: " & libName 57 | .} 58 | -------------------------------------------------------------------------------- /tests/test.nim: -------------------------------------------------------------------------------- 1 | # Copyright 2017 UniCredit S.p.A. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import unittest, complex 16 | import nimblas/cblas, nimblas 17 | 18 | template first[A](x: openArray[A]): ptr A = addr(x[0]) 19 | 20 | 21 | suite "CBLAS test": 22 | test "vector dot product": 23 | var 24 | u = [1.0, 2.0, 3.0, 4.0] 25 | v = [2.0, 2.0, 2.0, 1.0] 26 | 27 | let d = ddot(4, u.first, 1, v.first, 1) 28 | check d == 16.0 29 | 30 | test "matrix product": 31 | var 32 | m = [ 33 | 1.0, 2.0, 3.0, 4.0, 34 | 5.0, 6.0, 7.0, 8.0, 35 | 1.0, 2.0, 1.0, 1.0 36 | ] 37 | n = [ 38 | 2.0, 2.0, 2.0, 39 | 1.0, 2.0, 3.0 40 | ] 41 | r: array[8, float] 42 | 43 | dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, 4, 2, 3, 1, m.first, 44 | 4, n.first, 3, 0, r.first, 4) 45 | check @r[0..3] == @[14.0, 20.0, 22.0, 26.0] 46 | check @r[4..7] == @[14.0, 20.0, 20.0, 23.0] 47 | 48 | test "complex matrix product i.e. cblas_zgemm": 49 | const 50 | size:int = 2 51 | ss = size*size 52 | 53 | var 54 | one = complex64(1.0,0.0) 55 | A = cast[array[0..ss-1, Complex64]](alloc0(ss*sizeof(Complex64))) 56 | B = cast[array[0..ss-1, Complex64]](alloc0(ss*sizeof(Complex64))) 57 | C = cast[array[0..ss-1, Complex64]](alloc0(ss*sizeof(Complex64))) 58 | resultC = cast[array[0..ss-1, Complex64]](alloc0(ss*sizeof(Complex64))) 59 | resultArray = [2.0,4.0,8.0,14.0] 60 | 61 | for i in 0..ss-1: 62 | A[i] = complex64((float64)i,0.0) 63 | B[i] = complex64((float64)i,0.0) 64 | C[i] = complex64((float64)i,0.0) 65 | resultC[i] = complex64(resultArray[i],0.0) 66 | 67 | gemm(OrderType.rowMajor, TransposeType.noTranspose, TransposeType.noTranspose, 68 | size,size,size,unsafeAddr(one),unsafeAddr(A[0]),size,unsafeAddr(B[0]),size, 69 | unsafeAddr(one),unsafeAddr(C[0]),size) 70 | 71 | check(C == resultC) 72 | echo "dealloc" # for some reason, failing to have this hangs the test on MacOS 73 | dealloc(addr(A)) 74 | dealloc(addr(B)) 75 | dealloc(addr(C)) 76 | echo "done" # for some reason, failing to have this hangs the test on MacOS --------------------------------------------------------------------------------