1 // Copyright ©2016 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //+build !amd64 noasm appengine
12 // for _, v := range x {
16 func L1Norm(x []float64) (sum float64) {
24 // for i := 0; i < n*incX; i += incX {
25 // sum += math.Abs(x[i])
28 func L1NormInc(x []float64, n, incX int) (sum float64) {
29 for i := 0; i < n*incX; i += incX {
36 // for i, v := range s {
39 func Add(dst, s []float64) {
49 func AddConst(alpha float64, x []float64) {
60 // for i, v := range s[1:] {
61 // dst[i+1] = dst[i] + v
64 func CumSum(dst, s []float64) []float64 {
69 for i, v := range s[1:] {
80 // for i, v := range s[1:] {
81 // dst[i+1] = dst[i] * v
84 func CumProd(dst, s []float64) []float64 {
89 for i, v := range s[1:] {
96 // for i, v := range s {
99 func Div(dst, s []float64) {
100 for i, v := range s {
106 // for i, v := range s {
110 func DivTo(dst, s, t []float64) []float64 {
111 for i, v := range s {
119 // for i, v := range s {
120 // norm += math.Abs(t[i] - v)
123 func L1Dist(s, t []float64) float64 {
125 for i, v := range s {
126 norm += math.Abs(t[i] - v)
136 // norm = math.Abs(t[0] - s[0])
137 // for i, v := range s[1:] {
138 // absDiff := math.Abs(t[i+1] - v)
139 // if absDiff > norm || math.IsNaN(norm) {
144 func LinfDist(s, t []float64) float64 {
149 norm = math.Abs(t[0] - s[0])
150 for i, v := range s[1:] {
151 absDiff := math.Abs(t[i+1] - v)
152 if absDiff > norm || math.IsNaN(norm) {