From aa5623eedec65c50546c0e4b29d0d7bc5816f67a Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 24 Oct 2017 12:26:39 -0700 Subject: [PATCH] math: using ``v.`` instead of ``v* sum`` in a few places. --- basis/math/polynomials/polynomials.factor | 2 +- extra/arrays/shaped/shaped.factor | 4 ++-- extra/euler/modeling/modeling.factor | 2 +- extra/gml/coremath/coremath.factor | 2 +- extra/math/distances/distances.factor | 8 ++++---- extra/math/similarity/similarity.factor | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/basis/math/polynomials/polynomials.factor b/basis/math/polynomials/polynomials.factor index 5312804ff2..b5d074e954 100644 --- a/basis/math/polynomials/polynomials.factor +++ b/basis/math/polynomials/polynomials.factor @@ -36,7 +36,7 @@ ALIAS: n*p n*v [ drop length [ ] keep ] [ nip ] [ drop ] 2tri - '[ _ _ _ v* sum ] map reverse! ; + '[ _ _ _ v. ] map reverse! ; : p-sq ( p -- p^2 ) dup p* ; inline diff --git a/extra/arrays/shaped/shaped.factor b/extra/arrays/shaped/shaped.factor index e02ef76edd..81c2a48fe2 100644 --- a/extra/arrays/shaped/shaped.factor +++ b/extra/arrays/shaped/shaped.factor @@ -208,10 +208,10 @@ ERROR: shaped-bounds-error seq shape ; ! Inefficient : calculate-row-major-index ( seq shape -- i ) - 1 [ * ] accumulate nip reverse v* sum ; + 1 [ * ] accumulate nip reverse v. ; : calculate-column-major-index ( seq shape -- i ) - 1 [ * ] accumulate nip v* sum ; + 1 [ * ] accumulate nip v. ; : set-shaped-row-major ( obj seq shaped -- ) shaped-bounds-check [ shape calculate-row-major-index ] [ underlying>> ] bi set-nth ; diff --git a/extra/euler/modeling/modeling.factor b/extra/euler/modeling/modeling.factor index 21c6974283..b72112e952 100644 --- a/extra/euler/modeling/modeling.factor +++ b/extra/euler/modeling/modeling.factor @@ -65,7 +65,7 @@ sharp-continue ; :: project-pt-line ( p p0 p1 -- q ) p1 p0 v- :> vt - p p0 v- vt v* sum + p p0 v- vt v. vt norm-sq / vt n*v p0 v+ ; inline diff --git a/extra/gml/coremath/coremath.factor b/extra/gml/coremath/coremath.factor index bfb6a1b462..3a4d72d153 100644 --- a/extra/gml/coremath/coremath.factor +++ b/extra/gml/coremath/coremath.factor @@ -191,7 +191,7 @@ GML: aNormal ( x -- y ) } cond ; : det2 ( x y -- z ) - { 1 0 } vshuffle double-2{ 1 -1 } v* v* sum ; inline + { 1 0 } vshuffle double-2{ 1 -1 } v* v. ; inline : det3 ( x y z -- w ) [ cross ] dip v. ; inline diff --git a/extra/math/distances/distances.factor b/extra/math/distances/distances.factor index e59fbad5d0..7f56d6da19 100644 --- a/extra/math/distances/distances.factor +++ b/extra/math/distances/distances.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2012 John Benediktsson ! See http://factorcode.org/license.txt for BSD license -USING: kernel math math.functions math.statistics math.vectors -sequences sequences.extras ; +USING: kernel math math.functions math.similarity +math.statistics math.vectors sequences sequences.extras ; IN: math.distances @@ -22,7 +22,7 @@ IN: math.distances v- vabs supremum ; : cosine-distance ( a b -- n ) - [ v* sum ] [ [ norm ] bi@ * ] 2bi / 1 swap - ; + cosine-similarity 1 swap - ; : canberra-distance ( a b -- n ) [ v- vabs ] [ [ vabs ] bi@ v+ ] 2bi v/ sum ; @@ -31,4 +31,4 @@ IN: math.distances [ v- ] [ v+ ] 2bi [ vabs sum ] bi@ / ; : correlation-distance ( a b -- n ) - [ demean ] bi@ [ v* sum ] [ [ norm ] bi@ * ] 2bi / 1 swap - ; + [ demean ] bi@ cosine-distance ; diff --git a/extra/math/similarity/similarity.factor b/extra/math/similarity/similarity.factor index 1fdc82cfdb..6f4cfa8935 100644 --- a/extra/math/similarity/similarity.factor +++ b/extra/math/similarity/similarity.factor @@ -12,4 +12,4 @@ IN: math.similarity over length 3 < [ 2drop 1.0 ] [ population-corr 0.5 * 0.5 + ] if ; : cosine-similarity ( a b -- n ) - [ v* sum ] [ [ norm ] bi@ * ] 2bi / ; + [ v. ] [ [ norm ] bi@ * ] 2bi / ;