JuliaLang/julia — pull request #9151 by nwh (2014-11-25 20:47:19+00:00)
Title: Level-1 BLAS method cleanup

This PR addresses several issues with input argument types for BLAS level-1 interface methods.

## For `BLAS.dot`

When `BLAS.dot` accepts `StridedArrays` the following may occur:

```julia
using Base.BLAS
n = 5
A = zeros(n,n)
A[1,1:5] = 1
B = zeros(n,n)
B[1:5,1] = 1
sA = sub(A,1,1:5)
sB = sub(B,1:5,1)
a = BLAS.dot(sA,sB)
println("sA: $sA")
println("sB: $sB")
println("BLAS.dot(sA,sB): $a")
```

Output:

```
sA: [1.0 1.0 1.0 1.0 1.0]
sB: [1.0,1.0,1.0,1.0,1.0]
BLAS.dot(sA,sB): 1.0
```

Solution:
* main `BLAS.dot` methods should only accept `Ptr`s or `DenseArray`s
* helper `BLAS.dot` methods should only accept `DenseArray`s and
`StridedVector`s, the pass `Ptr`s to the main `BLAS.dot` methods

## For `BLAS.nrm2`, `BLAS.asum`, `BLAS.iamax`

The problem for `BLAS.nrm2` is allowing `StridedVectors` in the main
method. This is demonstraded with the following code:

```julia
using Base.BLAS
a = ones(6)
a[2:2:6] = 0
b = sub(a,2:2:6)
n1 = BLAS.nrm2(b)
n2 = BLAS.nrm2(3,b,1)
println("b: $b")
println("BLAS.nrm2(b): $n1")
println("BLAS.nrm2(3,b,1): $n2")
```

Output:

```
b: [0.0,0.0,0.0]
BLAS.nrm2(b): 0.0
BLAS.nrm2(3,b,1): 1.0
```

Fix:

* Main `BLAS.nrm2` (and `BLAS.asum`) methods now accept `Ptr` and
`DenseArray`

* Method specialized for a `StridedVector` passes a `Ptr` to the main
method.

* Fix is the same for both `BLAS.nrm2`, `BLAS.asum`, and `BLAS.iamax`

## For `BLAS.axpy!`

* main interface method now accepts `Ptr` and `DenseArray`
* helper method accepts `DenseArray` and `StridedVector`