]> gitweb.factorcode.org Git - factor.git/commitdiff
math.vectors,matrices: l2-norm -> aliased as norm (?) and help updated
authorCat Stevens <catb0t@protonmail.ch>
Tue, 10 Mar 2020 00:02:07 +0000 (20:02 -0400)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Dec 2021 20:09:32 +0000 (12:09 -0800)
basis/math/matrices/matrices-docs.factor
basis/math/quaternions/quaternions-tests.factor
basis/math/vectors/simd/simd-docs.factor
basis/math/vectors/simd/simd-tests.factor
basis/math/vectors/simd/simd.factor
basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors.factor

index 4ba8822240b8e6811c929c37751c429056edcbfa..6a8595c7d1c5ffbe3b8da8fceca0c02569de1d50 100644 (file)
@@ -983,7 +983,7 @@ $nl "This is the matrix norm when " { $snippet "p=1" } ", and is the overall max
 
 HELP: matrix-l2-norm
 { $values { "m" matrix } { "n" number } }
-{ $description "Find the norm (size) of a matrix in 𝑙₂ (" { $snippet "L^2" } ") vector space, usually written ∥・∥₂."
+{ $description "Find the norm (size) of a matrix in 𝑙₂ (" { $snippet "L^2" } ") vector space, usually written ∥・∥₂."
 $nl "This is the matrix norm when " { $snippet "p=2" } ", and is the square root of the sums of the squares of all the elements of the matrix." }
 { $notelist
     { "This norm is sometimes called the Hilbert-Schmidt norm." }
@@ -1070,7 +1070,7 @@ HELP: matrix-p-norm
 } ;
 
 { matrix-p-norm matrix-p-norm-entrywise } related-words
-{ matrix-p-norm matrix-p-q-norm } related-words
+{ matrix-l1-norm matrix-l2-norm matrix-l-infinity-norm matrix-p-norm matrix-p-q-norm } related-words
 
 HELP: matrix-normalize
 { $values { "m" "a matrix with at least 1 non-zero number" } { "m'" matrix } }
index c1149290da08f510deaea40e919378ceace46ce6..cb082aecac083076221bbb8d51b5ddaa5c578ab4 100644 (file)
@@ -8,11 +8,11 @@ CONSTANT: qi { 0 1 0 0 }
 CONSTANT: qj { 0 0 1 0 }
 CONSTANT: qk { 0 0 0 1 }
 
-{ 1.0 } [ qi l2-norm ] unit-test
-{ 1.0 } [ qj l2-norm ] unit-test
-{ 1.0 } [ qk l2-norm ] unit-test
-{ 1.0 } [ q1 l2-norm ] unit-test
-{ 0.0 } [ q0 l2-norm ] unit-test
+{ 1.0 } [ qi norm ] unit-test
+{ 1.0 } [ qj norm ] unit-test
+{ 1.0 } [ qk norm ] unit-test
+{ 1.0 } [ q1 norm ] unit-test
+{ 0.0 } [ q0 norm ] unit-test
 { t } [ qi qj q* qk = ] unit-test
 { t } [ qj qk q* qi = ] unit-test
 { t } [ qk qi q* qj = ] unit-test
index f4b684a38827e2f0e23112f6a56d1274503d2670..5f7d3189fa6f11e918acff90fe16ba1219c34b93 100644 (file)
@@ -23,7 +23,7 @@ $nl
 $nl
 "SSE2 introduces double-precision SIMD (" { $snippet "double-2" } ") and integer SIMD (all types). Integer SIMD is missing a few features; in particular, the " { $link vmin } " and " { $link vmax } " operations only work on " { $snippet "uchar-16" } " and " { $snippet "short-8" } "."
 $nl
-"SSE3 introduces horizontal adds (summing all components of a single vector register), which are useful for computing dot products. Where available, SSE3 operations are used to speed up " { $link sum } ", " { $link vdot } ", " { $link norm-sq } ", " { $link l2-norm } ", and " { $link distance } "."
+"SSE3 introduces horizontal adds (summing all components of a single vector register), which are useful for computing dot products. Where available, SSE3 operations are used to speed up " { $link sum } ", " { $link vdot } ", " { $link norm-sq } ", " { $link norm } ", and " { $link distance } "."
 $nl
 "SSSE3 introduces " { $link vabs } " for " { $snippet "char-16" } ", " { $snippet "short-8" } " and " { $snippet "int-4" } "."
 $nl
index 683ff3c52a4f087fe730240955ecbd6c1e6c0d03..9f4a17e64e5ee178b453961709d6c96e138bf65d 100644 (file)
@@ -15,7 +15,7 @@ IN: math.vectors.simd.tests
 ! Test type propagation
 { V{ float } } [ [ { float-4 } declare norm-sq ] final-classes ] unit-test
 
-{ V{ float } } [ [ { float-4 } declare l2-norm ] final-classes ] unit-test
+{ V{ float } } [ [ { float-4 } declare norm ] final-classes ] unit-test
 
 { V{ float-4 } } [ [ { float-4 } declare normalize ] final-classes ] unit-test
 
@@ -64,7 +64,7 @@ CONSTANT: vector-words
         { n+v { +scalar+ +vector+ -> +vector+ } }
         { n-v { +scalar+ +vector+ -> +vector+ } }
         { n/v { +scalar+ +vector+ -> +vector+ } }
-        { l2-norm { +vector+ -> +nonnegative+ } }
+        { norm { +vector+ -> +nonnegative+ } }
         { norm-sq { +vector+ -> +nonnegative+ } }
         { normalize { +vector+ -> +vector+ } }
         { v* { +vector+ +vector+ -> +vector+ } }
index fde5f7cdc4accca83d96412d0a274c8d6e8b86a7..79bf7044cecb8b1199d0f5a9e44d77c593fd2e7b 100644 (file)
@@ -254,7 +254,7 @@ M: simd-128 v-n over simd-with v- ; inline
 M: simd-128 v*n over simd-with v* ; inline
 M: simd-128 v/n over simd-with v/ ; inline
 M: simd-128 norm-sq dup vdot assert-positive ; inline
-M: simd-128 distance v- l2-norm ; inline
+M: simd-128 distance v- norm ; inline
 
 M: simd-128 >pprint-sequence ;
 M: simd-128 pprint* pprint-object ;
index 74313bca3aaddfc2e94669bba702060220688ceb..4af1d944e0dfde37d83b608b3da5ed422ec15ecd 100644 (file)
@@ -47,7 +47,7 @@ ARTICLE: "math-vectors-arithmetic" "Vector arithmetic"
     vdot
     norm-sq
     l1-norm
-    l2-norm
+    norm
     l-infinity-norm
     p-norm
 }
@@ -485,7 +485,7 @@ HELP: norm-sq
 
 HELP: l1-norm
 { $values { "k" sequence } { "x" "a non-negative real number" } }
-{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙₁ (" { $snippet "L^1" } ") vector space." }
+{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙₁ (" { $snippet "L^1" } ") vector space, usually written ∥・∥₁." }
 { $notes "See " { $link matrix-l1-norm } " for matrix-specific documentation about this word." }
 { $examples
     { $example
@@ -497,19 +497,24 @@ HELP: l1-norm
 
 HELP: l2-norm
 { $values { "k" sequence } { "x" "a non-negative real number" } }
-{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙₂ (" { $snippet "L^2" } ") vector space." }
-{ $notes "See " { $link matrix-l2-norm } " for matrix-specific documentation about this word." }
+{ $contract "Implementation for the default " { $link norm } ", in 𝑙₂ (" { $snippet "L^2" } ") vector space, usually written ∥・∥₂." }
+{ $notes "See " { $link matrix-l2-norm } " for matrix-specific documentation about this word." } ;
+
+HELP: norm
+{ $values { "k" sequence } { "x" "a non-negative real number" } }
+{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙₂ (" { $snippet "L^2" } ") vector space, usually written ∥・∥₂. " }
+{ $notes "This is generally the \"default norm\", and when referring to an unqualified norm, so it is an alias for the " { $link l2-norm } " implementation." }
 { $examples
     { $example
         "USING: math.vectors math.functions prettyprint ;"
-        "{ 1 2 3 4 } l2-norm 5.4772255 10e-8 ~ ."
+        "{ 1 2 3 4 } norm 5.4772255 10e-8 ~ ."
         "t"
     }
 } ;
 
 HELP: l-infinity-norm
 { $values { "k" sequence } { "x" "a non-negative real number" } }
-{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙∞ (" { $snippet "L^∞" } ") vector space. For a mathematical vector, this is simply its " { $link supremum } "." }
+{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙∞ (" { $snippet "L^∞" } ") vector space, usually written ∥・∥∞. For a mathematical vector, this is simply its " { $link supremum } "." }
 { $notes "See " { $link matrix-l-infinity-norm } " for matrix-specific documentation about this word." }
 { $examples
     { $example
@@ -521,13 +526,17 @@ HELP: l-infinity-norm
 
 HELP: p-norm
 { $values { "k" { $sequence number } } { "p" "a positive real number" } { "x" "a non-negative real number" } }
-{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙ₚ (" { $snippet "L^p" } ") vector space." }
+{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙ₚ (" { $snippet "L^p" } ") vector space, usually written ∥・∥ₚ." }
 { $notes "See " { $link matrix-p-norm } " for matrix-specific documentation about this word." } ;
 
+{ norm-sq l1-norm l2-norm norm l-infinity-norm p-norm } related-words
+
 HELP: normalize
 { $values { "v" { $sequence "at least 1 non-zero number" } } { "w" { $sequence number } } }
 { $description "Outputs a vector with the same direction as " { $snippet "v" } ", but length 1." } ;
 
+{ normalize matrix-normalize } related-words
+
 HELP: distance
 { $values { "u" { $sequence number } } { "v" { $sequence number } } { "x" "a non-negative real number" } }
 { $description "Outputs the Euclidean distance between two vectors." } ;
index 191838fefb5808c84d0d927c700daec254a50e99..0ef7cad587d286b419b114adfa30342cc31175b2 100644 (file)
@@ -230,6 +230,7 @@ M: object l1-norm [ abs ] map-sum ; inline
 
 GENERIC: l2-norm ( k -- x )
 M: object l2-norm norm-sq sqrt ; inline
+ALIAS: norm l2-norm
 
 GENERIC: l-infinity-norm ( k -- x )
 M: object l-infinity-norm supremum ; inline