]> gitweb.factorcode.org Git - factor.git/commitdiff
Rename variables in some stack declarations for consistency.
authorAlexander Iljin <ajsoft@yandex.ru>
Tue, 29 Sep 2015 14:48:10 +0000 (17:48 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 4 Nov 2015 15:47:57 +0000 (07:47 -0800)
It doesn't look great when a word is called "v/n", but the declared
parameters are "u" and "n". Better to have the parameters "v" and "n".
Also for consistency all input parameters are named "v" for "vector" (or
"u" and "v" in the alphabetical order), and the result vector is always
"w".

basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors.factor

index 90b9d1a0fc9eb3453e492d5266f4a138dcc32b8d..1f4be3508fd8078bb2a1ac5b756bd41ff0bb48f1 100644 (file)
@@ -190,53 +190,53 @@ ARTICLE: "math-vectors" "Vector operations"
 ABOUT: "math-vectors"
 
 HELP: vneg
-{ $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } }
-{ $description "Negates each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
+{ $description "Negates each element of " { $snippet "v" } "." } ;
 
 HELP: vabs
-{ $values { "u" "a sequence of numbers" } { "v" "a sequence of non-negative real numbers" } }
-{ $description "Takes the absolute value of each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "w" "a sequence of non-negative real numbers" } }
+{ $description "Takes the absolute value of each element of " { $snippet "v" } "." } ;
 
 HELP: vsqrt
-{ $values { "u" "a sequence of non-negative real numbers" } { "v" "a sequence of non-negative real numbers" } }
-{ $description "Takes the square root of each element of " { $snippet "u" } "." }
+{ $values { "v" "a sequence of non-negative real numbers" } { "w" "a sequence of non-negative real numbers" } }
+{ $description "Takes the square root of each element of " { $snippet "v" } "." }
 { $warning "For performance reasons, this does not work with negative inputs, unlike " { $link sqrt } "." } ;
 
 HELP: vfloor
-{ $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
-{ $description "Takes the " { $link floor } " of each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
+{ $description "Takes the " { $link floor } " of each element of " { $snippet "v" } "." } ;
 
 HELP: vceiling
-{ $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
-{ $description "Takes the " { $link ceiling } " of each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
+{ $description "Takes the " { $link ceiling } " of each element of " { $snippet "v" } "." } ;
 
 HELP: vtruncate
-{ $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } }
-{ $description "Truncates each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of real numbers" } { "w" "a sequence of real numbers" } }
+{ $description "Truncates each element of " { $snippet "v" } "." } ;
 
 HELP: n+v
 { $values { "n" number } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Adds " { $snippet "n" } " to each element of " { $snippet "v" } "." } ;
 
 HELP: v+n
-{ $values { "u" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
-{ $description "Adds " { $snippet "n" } " to each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
+{ $description "Adds " { $snippet "n" } " to each element of " { $snippet "v" } "." } ;
 
 HELP: n-v
 { $values { "n" number } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Subtracts each element of " { $snippet "v" } " from " { $snippet "n" } "." } ;
 
 HELP: v-n
-{ $values { "u" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
-{ $description "Subtracts " { $snippet "n" } " from each element of " { $snippet "u" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
+{ $description "Subtracts " { $snippet "n" } " from each element of " { $snippet "v" } "." } ;
 
 HELP: n*v
 { $values { "n" number } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Multiplies each element of " { $snippet "v" } " by " { $snippet "n" } "." } ;
 
 HELP: v*n
-{ $values { "u" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
-{ $description "Multiplies each element of " { $snippet "u" } " by " { $snippet "n" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
+{ $description "Multiplies each element of " { $snippet "v" } " by " { $snippet "n" } "." } ;
 
 HELP: n/v
 { $values { "n" number } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
@@ -244,8 +244,8 @@ HELP: n/v
 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
 
 HELP: v/n
-{ $values { "u" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
-{ $description "Divides each element of " { $snippet "u" } " by " { $snippet "n" } "." }
+{ $values { "v" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
+{ $description "Divides each element of " { $snippet "v" } " by " { $snippet "n" } "." }
 { $errors "May throw an error if a division by zero occurs; see " { $link "division-by-zero" } "." } ;
 
 HELP: n^v
@@ -253,8 +253,8 @@ HELP: n^v
 { $description "Raises " { $snippet "n" } " to the power of each element of " { $snippet "v" } "." } ;
 
 HELP: v^n
-{ $values { "u" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
-{ $description "Raises each element of " { $snippet "u" } " to the power of " { $snippet "n" } "." } ;
+{ $values { "v" "a sequence of numbers" } { "n" number } { "w" "a sequence of numbers" } }
+{ $description "Raises each element of " { $snippet "u" } " to the power of " { $snippet "v" } "." } ;
 
 HELP: v+
 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
@@ -359,21 +359,21 @@ HELP: vbitxor
 { $notes "Unlike " { $link bitxor } ", this word may be used on a specialized array of floats or doubles, in which case the bitwise representation of the floating point numbers is operated upon." } ;
 
 HELP: vlshift
-{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
-{ $description "Shifts each element of " { $snippet "u" } " to the left by " { $snippet "n" } " bits." }
+{ $values { "v" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
+{ $description "Shifts each element of " { $snippet "v" } " to the left by " { $snippet "n" } " bits." }
 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
 
 HELP: vrshift
-{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
-{ $description "Shifts each element of " { $snippet "u" } " to the right by " { $snippet "n" } " bits." }
+{ $values { "v" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
+{ $description "Shifts each element of " { $snippet "v" } " to the right by " { $snippet "n" } " bits." }
 { $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
 
 HELP: hlshift
-{ $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
+{ $values { "v" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
 { $description "Shifts the entire SIMD array to the left by " { $snippet "n" } " bytes, filling the vacated right-hand bits with zeroes. This word may only be used in a context where the compiler can statically infer that the input is a SIMD array." } ;
 
 HELP: hrshift
-{ $values { "u" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
+{ $values { "v" "a SIMD array" } { "n" "a non-negative integer" } { "w" "a SIMD array" } }
 { $description "Shifts the entire SIMD array to the right by " { $snippet "n" } " bytes, filling the vacated left-hand bits with zeroes. This word may only be used in a context where the compiler can statically infer that the input is a SIMD array." } ;
 
 HELP: vmerge
@@ -434,7 +434,7 @@ HELP: vbroadcast
 } ;
 
 HELP: vshuffle
-{ $values { "u" "a SIMD array" } { "perm" "an array of integers, or a byte-array" } { "v" "a SIMD array" } }
+{ $values { "v" "a SIMD array" } { "perm" "an array of integers, or a byte-array" } { "w" "a SIMD array" } }
 { $description "Permutes the elements of a SIMD array. Duplicate entries are allowed in the permutation. The " { $snippet "perm" } " argument can have one of two forms:"
 { $list
 { "A literal array of integers of the same length as the vector. This will perform a static, elementwise shuffle." }
@@ -478,8 +478,8 @@ HELP: p-norm
 { $description "Computes the length of a mathematical vector in " { $snippet "L^p" } " space." } ;
 
 HELP: normalize
-{ $values { "u" "a sequence of numbers, not all zero" } { "v" "a sequence of numbers" } }
-{ $description "Outputs a vector with the same direction as " { $snippet "u" } " but length 1." } ;
+{ $values { "v" "a sequence of numbers, not all zero" } { "w" "a sequence of numbers" } }
+{ $description "Outputs a vector with the same direction as " { $snippet "v" } " but length 1." } ;
 
 HELP: distance
 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
@@ -541,8 +541,8 @@ HELP: vxor
 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
 
 HELP: vnot
-{ $values { "u" "a sequence of booleans" } { "w" "a sequence of booleans" } }
-{ $description "Takes the logical NOT of each element of " { $snippet "u" } "." }
+{ $values { "v" "a sequence of booleans" } { "w" "a sequence of booleans" } }
+{ $description "Takes the logical NOT of each element of " { $snippet "v" } "." }
 { $notes "See " { $link "math-vectors-simd-logic" } " for notes on dealing with vector boolean inputs and results when using SIMD types." } ;
 
 HELP: v?
index 7c5a2fc70e60d0f28b04e194f9dbea21218b1aee..f30c095d455a91e351dd05e9500e24ae04c3ac11 100644 (file)
@@ -6,28 +6,28 @@ fry combinators byte-arrays accessors locals ;
 QUALIFIED-WITH: alien.c-types c
 IN: math.vectors
 
-GENERIC: vneg ( u -- v )
+GENERIC: vneg ( v -- w )
 M: object vneg [ neg ] map ; inline
 
-GENERIC# v+n 1 ( u n -- w )
+GENERIC# v+n 1 ( v n -- w )
 M: object v+n [ + ] curry map ; inline
 
 GENERIC: n+v ( n v -- w )
 M: object n+v [ + ] with map ; inline
 
-GENERIC# v-n 1 ( u n -- w )
+GENERIC# v-n 1 ( v n -- w )
 M: object v-n [ - ] curry map ; inline
 
 GENERIC: n-v ( n v -- w )
 M: object n-v [ - ] with map ; inline
 
-GENERIC# v*n 1 ( u n -- w )
+GENERIC# v*n 1 ( v n -- w )
 M: object v*n [ * ] curry map ; inline
 
 GENERIC: n*v ( n v -- w )
 M: object n*v [ * ] with map ; inline
 
-GENERIC# v/n 1 ( u n -- w )
+GENERIC# v/n 1 ( v n -- w )
 M: object v/n [ / ] curry map ; inline
 
 GENERIC: n/v ( n v -- w )
@@ -48,7 +48,7 @@ M: object v* [ * ] 2map ; inline
 GENERIC: v*high ( u v -- w )
 
 <PRIVATE
-: (h+) ( u -- w ) 2 <groups> [ first2 + ] map ;
+: (h+) ( v -- w ) 2 <groups> [ first2 + ] map ;
 PRIVATE>
 
 GENERIC: v*hs+ ( u v -- w )
@@ -60,7 +60,7 @@ M: object v/ [ / ] 2map ; inline
 GENERIC: v^ ( u v -- w )
 M: object v^ [ ^ ] 2map ; inline
 
-GENERIC: v^n ( u n -- w )
+GENERIC: v^n ( v n -- w )
 M: object v^n [ ^ ] curry map ; inline
 
 GENERIC: n^v ( n v -- w )
@@ -90,10 +90,10 @@ M: object vs- [ - ] 2map ; inline
 GENERIC: vs* ( u v -- w )
 M: object vs* [ * ] 2map ; inline
 
-GENERIC: vabs ( u -- v )
+GENERIC: vabs ( v -- w )
 M: object vabs [ abs ] map ; inline
 
-GENERIC: vsqrt ( u -- v )
+GENERIC: vsqrt ( v -- w )
 M: object vsqrt [ >float fsqrt ] map ; inline
 
 GENERIC: vsad ( u v -- n )
@@ -113,13 +113,13 @@ GENERIC: vbitor ( u v -- w )
 M: object vbitor [ bitor ] 2map ; inline
 GENERIC: vbitxor ( u v -- w )
 M: object vbitxor [ bitxor ] 2map ; inline
-GENERIC: vbitnot ( u -- w )
+GENERIC: vbitnot ( v -- w )
 M: object vbitnot [ bitnot ] map ; inline
 
 GENERIC# vbroadcast 1 ( u n -- v )
 M:: object vbroadcast ( u n -- v ) u length n u nth <repetition> u like ; inline
 
-GENERIC# vshuffle-elements 1 ( u perm -- v )
+GENERIC# vshuffle-elements 1 ( v perm -- w )
 M: object vshuffle-elements
     over length 0 pad-tail
     swap [ '[ _ nth ] ] keep map-as ; inline
@@ -128,19 +128,19 @@ GENERIC# vshuffle2-elements 1 ( u v perm -- w )
 M: object vshuffle2-elements
     [ append ] dip vshuffle-elements ; inline
 
-GENERIC# vshuffle-bytes 1 ( u perm -- v )
+GENERIC# vshuffle-bytes 1 ( v perm -- w )
 
-GENERIC: vshuffle ( u perm -- v )
-M: array vshuffle ( u perm -- v )
+GENERIC: vshuffle ( v perm -- w )
+M: array vshuffle ( v perm -- w )
     vshuffle-elements ; inline
 
-GENERIC# vlshift 1 ( u n -- w )
+GENERIC# vlshift 1 ( v n -- w )
 M: object vlshift '[ _ shift ] map ; inline
-GENERIC# vrshift 1 ( u n -- w )
+GENERIC# vrshift 1 ( v n -- w )
 M: object vrshift neg '[ _ shift ] map ; inline
 
-GENERIC# hlshift 1 ( u n -- w )
-GENERIC# hrshift 1 ( u n -- w )
+GENERIC# hlshift 1 ( v n -- w )
+GENERIC# hrshift 1 ( v n -- w )
 
 GENERIC: (vmerge-head) ( u v -- h )
 M: object (vmerge-head) over length 2 /i '[ _ head-slice ] bi@ [ zip ] keep concat-as ; inline
@@ -165,7 +165,7 @@ M: object vor [ or ] 2map ; inline
 GENERIC: vxor ( u v -- w )
 M: object vxor [ xor ] 2map ; inline
 
-GENERIC: vnot ( u -- w )
+GENERIC: vnot ( v -- w )
 M: object vnot [ not ] map ; inline
 
 GENERIC: vall? ( v -- ? )
@@ -209,10 +209,10 @@ M: object v?
         [ [ call ] dip call v? ]
     } cond ; inline
 
-: v>integer ( u -- v ) [ >integer ] map ;
-: vfloor ( u -- v ) [ floor ] map ;
-: vceiling ( u -- v ) [ ceiling ] map ;
-: vtruncate ( u -- v ) [ truncate ] map ;
+: v>integer ( v -- w ) [ >integer ] map ;
+: vfloor ( v -- w ) [ floor ] map ;
+: vceiling ( v -- w ) [ ceiling ] map ;
+: vtruncate ( v -- w ) [ truncate ] map ;
 
 : vsupremum ( seq -- vmax ) [ ] [ vmax ] map-reduce ; inline
 : vinfimum ( seq -- vmin ) [ ] [ vmin ] map-reduce ; inline
@@ -241,7 +241,7 @@ M: object norm-sq [ absq ] [ + ] map-reduce ; inline
         [ p-norm-default ]
     } cond ;
 
-: normalize ( u -- v ) dup norm v/n ; inline
+: normalize ( v -- w ) dup norm v/n ; inline
 
 GENERIC: distance ( u v -- x )
 M: object distance [ - absq ] [ + ] 2map-reduce sqrt ; inline