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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections and no cover texts. A copy of the license is
included in the section entitled "GNU Free Documentation License". -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Scientific Library – Reference Manual: BLAS Support</title>
<meta name="description" content="GNU Scientific Library – Reference Manual: BLAS Support">
<meta name="keywords" content="GNU Scientific Library – Reference Manual: BLAS Support">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-Index.html#Function-Index" rel="index" title="Function Index">
<link href="index.html#Top" rel="up" title="Top">
<link href="GSL-BLAS-Interface.html#GSL-BLAS-Interface" rel="next" title="GSL BLAS Interface">
<link href="Sorting-References-and-Further-Reading.html#Sorting-References-and-Further-Reading" rel="previous" title="Sorting References and Further Reading">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="BLAS-Support"></a>
<div class="header">
<p>
Next: <a href="Linear-Algebra.html#Linear-Algebra" accesskey="n" rel="next">Linear Algebra</a>, Previous: <a href="Sorting.html#Sorting" accesskey="p" rel="previous">Sorting</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="BLAS-Support-1"></a>
<h2 class="chapter">13 BLAS Support</h2>
<a name="index-linear-algebra_002c-BLAS"></a>
<a name="index-matrix_002c-operations"></a>
<a name="index-vector_002c-operations"></a>
<a name="index-BLAS"></a>
<a name="index-CBLAS"></a>
<a name="index-Basic-Linear-Algebra-Subroutines-_0028BLAS_0029"></a>
<p>The Basic Linear Algebra Subprograms (<small>BLAS</small>) define a set of fundamental
operations on vectors and matrices which can be used to create optimized
higher-level linear algebra functionality.
</p>
<p>The library provides a low-level layer which corresponds directly to the
C-language <small>BLAS</small> standard, referred to here as “<small>CBLAS</small>”, and a
higher-level interface for operations on GSL vectors and matrices.
Users who are interested in simple operations on GSL vector and matrix
objects should use the high-level layer described
in this chapter. The functions are declared in the file
<samp>gsl_blas.h</samp> and should satisfy the needs of most users.
</p>
<p>Note that GSL matrices are implemented using dense-storage so the
interface only includes the corresponding dense-storage <small>BLAS</small>
functions. The full <small>BLAS</small> functionality for band-format and
packed-format matrices is available through the low-level <small>CBLAS</small>
interface. Similarly, GSL vectors are restricted to positive strides,
whereas the low-level <small>CBLAS</small> interface supports negative
strides as specified in the <small>BLAS</small> standard.<a name="DOCF12" href="#FOOT12"><sup>12</sup></a>
</p>
<p>The interface for the <code>gsl_cblas</code> layer is specified in the file
<samp>gsl_cblas.h</samp>. This interface corresponds to the <small>BLAS</small> Technical
Forum’s standard for the C interface to legacy <small>BLAS</small>
implementations. Users who have access to other conforming <small>CBLAS</small>
implementations can use these in place of the version provided by the
library. Note that users who have only a Fortran <small>BLAS</small> library can
use a <small>CBLAS</small> conformant wrapper to convert it into a <small>CBLAS</small>
library. A reference <small>CBLAS</small> wrapper for legacy Fortran
implementations exists as part of the <small>CBLAS</small> standard and can
be obtained from Netlib. The complete set of <small>CBLAS</small> functions is
listed in an appendix (see <a href="GSL-CBLAS-Library.html#GSL-CBLAS-Library">GSL CBLAS Library</a>).
</p>
<p>There are three levels of <small>BLAS</small> operations,
</p>
<dl compact="compact">
<dt><b>Level 1</b></dt>
<dd><p>Vector operations, e.g. <em>y = \alpha x + y</em>
</p></dd>
<dt><b>Level 2</b></dt>
<dd><p>Matrix-vector operations, e.g. <em>y = \alpha A x + \beta y</em>
</p></dd>
<dt><b>Level 3</b></dt>
<dd><p>Matrix-matrix operations, e.g. <em>C = \alpha A B + C</em>
</p></dd>
</dl>
<p>Each routine has a name which specifies the operation, the type of
matrices involved and their precisions. Some of the most common
operations and their names are given below,
</p>
<dl compact="compact">
<dt><b>DOT</b></dt>
<dd><p>scalar product, <em>x^T y</em>
</p></dd>
<dt><b>AXPY</b></dt>
<dd><p>vector sum, <em>\alpha x + y</em>
</p></dd>
<dt><b>MV</b></dt>
<dd><p>matrix-vector product, <em>A x</em>
</p></dd>
<dt><b>SV</b></dt>
<dd><p>matrix-vector solve, <em>inv(A) x</em>
</p></dd>
<dt><b>MM</b></dt>
<dd><p>matrix-matrix product, <em>A B</em>
</p></dd>
<dt><b>SM</b></dt>
<dd><p>matrix-matrix solve, <em>inv(A) B</em>
</p></dd>
</dl>
<p>The types of matrices are,
</p>
<dl compact="compact">
<dt><b>GE</b></dt>
<dd><p>general
</p></dd>
<dt><b>GB</b></dt>
<dd><p>general band
</p></dd>
<dt><b>SY</b></dt>
<dd><p>symmetric
</p></dd>
<dt><b>SB</b></dt>
<dd><p>symmetric band
</p></dd>
<dt><b>SP</b></dt>
<dd><p>symmetric packed
</p></dd>
<dt><b>HE</b></dt>
<dd><p>hermitian
</p></dd>
<dt><b>HB</b></dt>
<dd><p>hermitian band
</p></dd>
<dt><b>HP</b></dt>
<dd><p>hermitian packed
</p></dd>
<dt><b>TR</b></dt>
<dd><p>triangular
</p></dd>
<dt><b>TB</b></dt>
<dd><p>triangular band
</p></dd>
<dt><b>TP</b></dt>
<dd><p>triangular packed
</p></dd>
</dl>
<p>Each operation is defined for four precisions,
</p>
<dl compact="compact">
<dt><b>S</b></dt>
<dd><p>single real
</p></dd>
<dt><b>D</b></dt>
<dd><p>double real
</p></dd>
<dt><b>C</b></dt>
<dd><p>single complex
</p></dd>
<dt><b>Z</b></dt>
<dd><p>double complex
</p></dd>
</dl>
<p>Thus, for example, the name <small>SGEMM</small> stands for “single-precision
general matrix-matrix multiply” and <small>ZGEMM</small> stands for
“double-precision complex matrix-matrix multiply”.
</p>
<p>Note that the vector and matrix arguments to BLAS functions must not
be aliased, as the results are undefined when the underlying arrays
overlap (see <a href="Aliasing-of-arrays.html#Aliasing-of-arrays">Aliasing of arrays</a>).
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="GSL-BLAS-Interface.html#GSL-BLAS-Interface" accesskey="1">GSL BLAS Interface</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="BLAS-Examples.html#BLAS-Examples" accesskey="2">BLAS Examples</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="BLAS-References-and-Further-Reading.html#BLAS-References-and-Further-Reading" accesskey="3">BLAS References and Further Reading</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>
<h3><a name="FOOT12" href="#DOCF12">(12)</a></h3>
<p>In the low-level
<small>CBLAS</small> interface, a negative stride accesses the vector elements
in reverse order, i.e. the <em>i</em>-th element is given by
<em>(N-i)*|incx|</em> for <em>incx < 0</em>.</p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Linear-Algebra.html#Linear-Algebra" accesskey="n" rel="next">Linear Algebra</a>, Previous: <a href="Sorting.html#Sorting" accesskey="p" rel="previous">Sorting</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="Function-Index.html#Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|