mirror of
https://github.com/gonum/gonum.git
synced 2025-10-16 12:10:37 +08:00
mat: make RowView and ColView return Vector type and add RowViewOf and ColViewOf
Also change Dot signature to accept Vector parameters.
This commit is contained in:

committed by
Dan Kortschak

parent
d7342e68fb
commit
e01a71d4d5
@@ -136,13 +136,14 @@ func jacobianConcurrent(dst *mat.Dense, f func([]float64, []float64), x, origin
|
||||
xcopy := make([]float64, n)
|
||||
y := make([]float64, m)
|
||||
yVec := mat.NewVecDense(m, y)
|
||||
var col mat.VecDense
|
||||
for job := range jobs {
|
||||
copy(xcopy, x)
|
||||
xcopy[job.j] += job.pt.Loc * step
|
||||
f(y, xcopy)
|
||||
col := dst.ColView(job.j)
|
||||
col.ColViewOf(dst, job.j)
|
||||
mu[job.j].Lock()
|
||||
col.AddScaledVec(col, job.pt.Coeff, yVec)
|
||||
col.AddScaledVec(&col, job.pt.Coeff, yVec)
|
||||
mu[job.j].Unlock()
|
||||
}
|
||||
}
|
||||
@@ -184,9 +185,10 @@ func jacobianConcurrent(dst *mat.Dense, f func([]float64, []float64), x, origin
|
||||
if pt.Loc != 0 {
|
||||
continue
|
||||
}
|
||||
var col mat.VecDense
|
||||
for j := 0; j < n; j++ {
|
||||
col := dst.ColView(j)
|
||||
col.AddScaledVec(col, pt.Coeff, originVec)
|
||||
col.ColViewOf(dst, j)
|
||||
col.AddScaledVec(&col, pt.Coeff, originVec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user