# BLAS

Apple’s implementation of the Basic Linear Algebra Subprograms (BLAS).

## Overview

The vecLib framework contains nine C header files (not counting `vecLib.h` which merely includes the others).

This document describes the functions declared in the header files `cblas.h` and `vblas.h`, which contain the interfaces for Apple’s implementation of the Basic Linear Algebra Subprograms (BLAS) API.

## Topics

### General Functions

`func cblas_icamax(Int32, UnsafeRawPointer!, Int32) -> Int32`

Returns the index of the element with the largest absolute value in a vector (single-precision complex).

`func cblas_idamax(Int32, UnsafePointer<Double>!, Int32) -> Int32`

Returns the index of the element with the largest absolute value in a vector (double-precision).

`func cblas_isamax(Int32, UnsafePointer<Float>!, Int32) -> Int32`

Returns the index of the element with the largest absolute value in a vector (single-precision).

`func cblas_izamax(Int32, UnsafeRawPointer!, Int32) -> Int32`

Returns the index of the element with the largest absolute value in a vector (double-precision complex).

### CATLAS and CBLAS Vector Functions

`func catlas_caxpby(Int32, UnsafeRawPointer!, UnsafeRawPointer!, Int32, UnsafeRawPointer!, UnsafeMutableRawPointer!, Int32)`

Computes the product of two vectors, scaling each one separately (single-precision complex).

`func catlas_cset(Int32, UnsafeRawPointer!, UnsafeMutableRawPointer!, Int32)`

Modifies a vector (single-precision complex) in place, setting each element to a given value.

`func catlas_dset(Int32, Double, UnsafeMutablePointer<Double>!, Int32)`

Modifies a vector (double-precision) in place, setting each element to a given value.

`func catlas_saxpby(Int32, Float, UnsafePointer<Float>!, Int32, Float, UnsafeMutablePointer<Float>!, Int32)`

Computes the sum of two vectors, scaling each one separately (single-precision).

`func catlas_sset(Int32, Float, UnsafeMutablePointer<Float>!, Int32)`

Modifies a vector (single-precision) in place, setting each element to a given value.

`func catlas_zset(Int32, UnsafeRawPointer!, UnsafeMutableRawPointer!, Int32)`

Modifies a vector (double-precision complex) in place, setting each element to a given value.

`func cblas_sdsdot(Int32, Float, UnsafePointer<Float>!, Int32, UnsafePointer<Float>!, Int32) -> Float`

Computes the dot product of two single-precision vectors plus an initial single-precision value.

`func cblas_cdotc_sub(Int32, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Calculates the dot product of the complex conjugate of a single-precision complex vector with a second single-precision complex vector.

`func cblas_dsdot(Int32, UnsafePointer<Float>!, Int32, UnsafePointer<Float>!, Int32) -> Double`

Computes the double-precision dot product of a pair of single-precision vectors.

`func cblas_zdotc_sub(Int32, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Calculates the dot product of the complex conjugate of a double-precision complex vector with a second double-precision complex vector.

### Sparse Computation

Matrix and Vector Operations

Perform computations with matrices and vectors.

Pointwise Matrix Operations

Create, insert values into, and extract values from a pointwise sparse matrix.

Blockwise Matrix Operations

Create, insert values into, and extract values from a blockwise sparse matrix.

General Sparse Matrix Management Operations

Operations to manage and work with sparse matrix properties.

Sparse Utility Operations

Various utility operations for creating and working with sparse structures.

### Single-Precision Float Matrix Functions

`func cblas_sasum(Int32, UnsafePointer<Float>!, Int32) -> Float`

Computes the sum of the absolute values of elements in a vector (single-precision).

`func cblas_snrm2(Int32, UnsafePointer<Float>!, Int32) -> Float`

Computes the L2 norm (Euclidian length) of a vector (single precision).

`func cblas_sscal(Int32, Float, UnsafeMutablePointer<Float>!, Int32)`

Multiplies each element of a vector by a constant (single-precision).

`func cblas_sspmv(CBLAS_ORDER, CBLAS_UPLO, Int32, Float, UnsafePointer<Float>!, UnsafePointer<Float>!, Int32, Float, UnsafeMutablePointer<Float>!, Int32)`

Scales a packed symmetric matrix, then multiplies by a vector, then scales and adds another vector (single precision).

`func cblas_sspr(CBLAS_ORDER, CBLAS_UPLO, Int32, Float, UnsafePointer<Float>!, Int32, UnsafeMutablePointer<Float>!)`

Rank one update: adds a packed symmetric matrix to the product of a scaling factor, a vector, and its transpose (single precision).

`func cblas_ssyr(CBLAS_ORDER, CBLAS_UPLO, Int32, Float, UnsafePointer<Float>!, Int32, UnsafeMutablePointer<Float>!, Int32)`

Rank one update: adds a symmetric matrix to the product of a scaling factor, a vector, and its transpose (single precision).

### Single-Precision Complex Matrix Functions

`func cblas_cher(CBLAS_ORDER, CBLAS_UPLO, Int32, Float, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!, Int32)`

Hermitian rank 1 update: adds the product of a scaling factor, vector `X`, and the conjugate transpose of `X` to matrix `A`.

`func cblas_cher2(CBLAS_ORDER, CBLAS_UPLO, Int32, UnsafeRawPointer!, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!, Int32)`

Hermitian rank 2 update: adds the product of a scaling factor, vector `X`, and the conjugate transpose of vector `Y` to the product of the conjugate of the scaling factor, vector `Y`, and the conjugate transpose of vector `X`, and adds the result to matrix `A`.

`func cblas_cherk(CBLAS_ORDER, CBLAS_UPLO, CBLAS_TRANSPOSE, Int32, Int32, Float, UnsafeRawPointer!, Int32, Float, UnsafeMutableRawPointer!, Int32)`

Rank-k update—multiplies a Hermitian matrix by its transpose and adds a second matrix (single precision).

`func cblas_chpr(CBLAS_ORDER, CBLAS_UPLO, Int32, Float, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Scales and multiplies a vector times its conjugate transpose, then adds a matrix.

`func cblas_chpr2(CBLAS_ORDER, CBLAS_UPLO, Int32, UnsafeRawPointer!, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Multiplies a vector times the conjugate transpose of a second vector and vice-versa, sums the results, and adds a matrix.

`func cblas_cscal(Int32, UnsafeRawPointer!, UnsafeMutableRawPointer!, Int32)`

Multiplies each element of a vector by a constant (single-precision complex).

`func cblas_csscal(Int32, Float, UnsafeMutableRawPointer!, Int32)`

Multiplies each element of a vector by a constant (single-precision complex).

`func cblas_scasum(Int32, UnsafeRawPointer!, Int32) -> Float`

Computes the sum of the absolute values of real and imaginary parts of elements in a vector (single-precision complex).

`func cblas_scnrm2(Int32, UnsafeRawPointer!, Int32) -> Float`

Computes the unitary norm of a vector (single-precision complex).

### Double-Precision Float Matrix Functions

`func cblas_dasum(Int32, UnsafePointer<Double>!, Int32) -> Double`

Computes the sum of the absolute values of elements in a vector (double-precision).

`func cblas_dnrm2(Int32, UnsafePointer<Double>!, Int32) -> Double`

Computes the L2 norm (Euclidian length) of a vector (double precision).

`func cblas_dscal(Int32, Double, UnsafeMutablePointer<Double>!, Int32)`

Multiplies each element of a vector by a constant (double-precision).

`func cblas_dspmv(CBLAS_ORDER, CBLAS_UPLO, Int32, Double, UnsafePointer<Double>!, UnsafePointer<Double>!, Int32, Double, UnsafeMutablePointer<Double>!, Int32)`

Scales a packed symmetric matrix, then multiplies by a vector, then scales and adds another vector (double precision).

`func cblas_dspr(CBLAS_ORDER, CBLAS_UPLO, Int32, Double, UnsafePointer<Double>!, Int32, UnsafeMutablePointer<Double>!)`

Rank one update: adds a packed symmetric matrix to the product of a scaling factor, a vector, and its transpose (double precision).

`func cblas_dsyr(CBLAS_ORDER, CBLAS_UPLO, Int32, Double, UnsafePointer<Double>!, Int32, UnsafeMutablePointer<Double>!, Int32)`

Rank one update: adds a symmetric matrix to the product of a scaling factor, a vector, and its transpose (double precision).

### Double-Precision Complex Matrix Functions

`func cblas_dzasum(Int32, UnsafeRawPointer!, Int32) -> Double`

Computes the sum of the absolute values of real and imaginary parts of elements in a vector (single-precision complex).

`func cblas_dznrm2(Int32, UnsafeRawPointer!, Int32) -> Double`

Computes the unitary norm of a vector (double-precision complex).

`func cblas_zdscal(Int32, Double, UnsafeMutableRawPointer!, Int32)`

Multiplies each element of a vector by a constant (double-precision complex).

`func cblas_zher(CBLAS_ORDER, CBLAS_UPLO, Int32, Double, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!, Int32)`

Adds the product of a scaling factor, vector `X`, and the conjugate transpose of `X` to matrix `A`.

`func cblas_zher2(CBLAS_ORDER, CBLAS_UPLO, Int32, UnsafeRawPointer!, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!, Int32)`

Hermitian rank 2 update: adds the product of a scaling factor, vector `X`, and the conjugate transpose of vector `Y` to the product of the conjugate of the scaling factor, vector `Y`, and the conjugate transpose of vector `X`, and adds the result to matrix `A`.

`func cblas_zhpr(CBLAS_ORDER, CBLAS_UPLO, Int32, Double, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Scales and multiplies a vector times its conjugate transpose, then adds a matrix.

`func cblas_zhpr2(CBLAS_ORDER, CBLAS_UPLO, Int32, UnsafeRawPointer!, UnsafeRawPointer!, Int32, UnsafeRawPointer!, Int32, UnsafeMutableRawPointer!)`

Multiplies a vector times the conjugate transpose of a second vector and vice-versa, sums the results, and adds a matrix.

`func cblas_zscal(Int32, UnsafeRawPointer!, UnsafeMutableRawPointer!, Int32)`

Multiplies each element of a vector by a constant (double-precision complex).

### Data Types

`typealias BLASParamErrorProc`

BLAS error handler callback type.