]> gitweb.factorcode.org Git - factor.git/commitdiff
math.vectors: make these non-generic to fix simd-128 issue.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Dec 2021 20:15:09 +0000 (12:15 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Dec 2021 20:15:09 +0000 (12:15 -0800)
basis/math/matrices/matrices.factor
basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors.factor

index 3d5c7439f990311d8bfcc57371569b90f5da2b63..e74236feb4e8e8d0a9af819820553e0a520c93e4 100644 (file)
@@ -2,18 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays classes.singleton columns combinators
 combinators.short-circuit combinators.smart formatting fry
-<<<<<<< HEAD
 grouping kernel locals math math.bits math.functions math.order
 math.private math.ranges math.statistics math.vectors
 math.vectors.private sequences sequences.deep sequences.private
 slots.private summary ;
-=======
-grouping kernel kernel.private locals math math.bits
-math.functions math.order math.private math.ranges
-math.statistics math.vectors math.vectors.private sequences
-sequences.deep sequences.extras sequences.private slots.private
-summary ;
->>>>>>> 0ac3067a26 (vnorm rename)
 IN: math.matrices
 
 ! defined here because of issue #1943
@@ -283,14 +275,14 @@ DEFER: matrix-set-nths
         [ [ sq ] map-sum ] map-sum sqrt
     ] if ; inline foldable
 
-M: zero-matrix l1-norm drop 0 ; inline
-M: matrix l1-norm matrix-l1-norm ; inline
+! XXX: M: zero-matrix l1-norm drop 0 ; inline
+! XXX: M: matrix l1-norm matrix-l1-norm ; inline
 
-M: zero-matrix l2-norm drop 0 ; inline
-M: matrix l2-norm matrix-l2-norm ; inline
+! XXX: M: zero-matrix l2-norm drop 0 ; inline
+! XXX: M: matrix l2-norm matrix-l2-norm ; inline
 
-M: zero-matrix l-infinity-norm drop 0 ; inline
-M: matrix l-infinity-norm matrix-l-infinity-norm ; inline
+! XXX: M: zero-matrix l-infinity-norm drop 0 ; inline
+! XXX: M: matrix l-infinity-norm matrix-l-infinity-norm ; inline
 
 ALIAS: frobenius-norm matrix-l2-norm
 ALIAS: hilbert-schmidt-norm matrix-l2-norm
@@ -303,8 +295,8 @@ ALIAS: hilbert-schmidt-norm matrix-l2-norm
 : matrix-p-norm-entrywise ( m p -- n )
     [ flatten1 V{ } like ] dip p-norm-default ; inline
 
-M: zero-matrix p-norm-default 2drop 0 ; inline
-M: matrix p-norm-default matrix-p-norm-entrywise ; inline
+! XXX: M: zero-matrix p-norm-default 2drop 0 ; inline
+! XXX: M: matrix p-norm-default matrix-p-norm-entrywise ; inline
 
 : matrix-p-norm ( m p -- n )
     over zero-matrix? [ 2drop 0 ] [
@@ -316,8 +308,8 @@ M: matrix p-norm-default matrix-p-norm-entrywise ; inline
         } cond
     ] if ; inline foldable
 
-M: zero-matrix p-norm 2drop 0 ; inline
-M: matrix p-norm matrix-p-norm ; inline
+! XXX: M: zero-matrix p-norm 2drop 0 ; inline
+! XXX: M: matrix p-norm matrix-p-norm ; inline
 
 : matrix-normalize ( m -- m' )
     dup zero-matrix? [
index 4af1d944e0dfde37d83b608b3da5ed422ec15ecd..a5d1ba909dd98a214574e77d6defce9b3fd16ea4 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax kernel math math.functions
-math.matrices sequences ;
+sequences ;
 IN: math.vectors
 
 ARTICLE: "math-vectors-arithmetic" "Vector arithmetic"
@@ -486,7 +486,6 @@ 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, usually written ∥・∥₁." }
-{ $notes "See " { $link matrix-l1-norm } " for matrix-specific documentation about this word." }
 { $examples
     { $example
         "USING: math.vectors prettyprint ;"
@@ -497,8 +496,7 @@ HELP: l1-norm
 
 HELP: l2-norm
 { $values { "k" sequence } { "x" "a non-negative real number" } }
-{ $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." } ;
+{ $contract "Implementation for the default " { $link norm } ", in 𝑙₂ (" { $snippet "L^2" } ") vector space, usually written ∥・∥₂." } ;
 
 HELP: norm
 { $values { "k" sequence } { "x" "a non-negative real number" } }
@@ -515,7 +513,6 @@ HELP: norm
 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, 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
         "USING: math.vectors prettyprint ;"
@@ -526,8 +523,7 @@ 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, usually written ∥・∥ₚ." }
-{ $notes "See " { $link matrix-p-norm } " for matrix-specific documentation about this word." } ;
+{ $contract "Computes the norm (size) of " { $snippet "k" } " in 𝑙ₚ (" { $snippet "L^p" } ") vector space, usually written ∥・∥ₚ." } ;
 
 { norm-sq l1-norm l2-norm norm l-infinity-norm p-norm } related-words
 
@@ -535,8 +531,6 @@ 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 0ef7cad587d286b419b114adfa30342cc31175b2..8633cbe0057ede477eaec5b2fd89acdcba952006 100644 (file)
@@ -225,22 +225,18 @@ M: object hdot [ conjugate * ] [ + ] 2map-reduce ; inline
 GENERIC: norm-sq ( v -- x )
 M: object norm-sq [ absq ] [ + ] map-reduce ; inline
 
-GENERIC: l1-norm ( k -- x )
-M: object l1-norm [ abs ] map-sum ; inline
+: l1-norm ( k -- x ) [ abs ] map-sum ; inline
+
+: l2-norm ( k -- x ) norm-sq sqrt ; 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
+: l-infinity-norm ( k -- x ) supremum ; inline
 
-GENERIC#: p-norm-default 1 ( k p -- x )
-M: object p-norm-default
+: p-norm-default ( k p -- x )
     [ [ [ abs ] dip ^ ] curry map-sum ] keep recip ^ ; inline
 
-GENERIC#: p-norm 1 ( k p -- x )
-M: object p-norm
+: p-norm ( k p -- x )
     {
         { [ dup 1 = ] [ drop l1-norm ] }
         { [ dup 2 = ] [ drop l2-norm ] }