Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
mat64: use asm.Dscal in Vector.ScaleVec()
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Jan 15, 2016
1 parent 4660516 commit ad8a74d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mat64/vector.go
Expand Up @@ -127,11 +127,19 @@ func (v *Vector) ScaleVec(alpha float64, a *Vector) {
n := a.Len()
if v != a {
v.reuseAs(n)
blas64.Copy(n, a.mat, v.mat)
if v.mat.Inc == 1 && a.mat.Inc == 1 {
asm.DscalUnitaryTo(v.mat.Data, alpha, a.mat.Data)
return
}
asm.DscalIncTo(v.mat.Data, uintptr(v.mat.Inc), 0,
alpha, a.mat.Data, uintptr(n), uintptr(a.mat.Inc), 0)
return
}
if alpha != 1 {
blas64.Scal(n, alpha, v.mat)
if v.mat.Inc == 1 {
asm.DscalUnitary(alpha, v.mat.Data)
return
}
asm.DscalInc(alpha, v.mat.Data, uintptr(n), uintptr(v.mat.Inc), 0)
}

// AddScaledVec adds the vectors a and alpha*b, placing the result in the receiver.
Expand Down

0 comments on commit ad8a74d

Please sign in to comment.