]> gitweb.factorcode.org Git - factor.git/commitdiff
math.vectors: separate "dot product" from "Hermitian inner product". Fixes #484.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 29 Mar 2012 17:56:39 +0000 (10:56 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 29 Mar 2012 17:56:39 +0000 (10:56 -0700)
basis/math/matrices/matrices.factor
basis/math/vectors/vectors-docs.factor
basis/math/vectors/vectors-tests.factor
basis/math/vectors/vectors.factor

index 35d6f380cbda6d7e18dceae5c6db9109962632fb..9fc4f879e82c7fb3bc2857ef8af0a59936db85ff 100644 (file)
@@ -124,7 +124,7 @@ IN: math.matrices
     dupd proj v- ;
 
 : angle-between ( v u -- a )
-    [ normalize ] bi@ v. acos ;
+    [ normalize ] bi@ h. acos ;
 
 : (gram-schmidt) ( v seq -- newseq )
     [ dupd proj v- ] each ;
index b037d427861fcfff610e60bbe2a162d1e5f13aff..920fbd81e637833093b57d7af7436f3cba00a26f 100644 (file)
@@ -289,6 +289,10 @@ HELP: v.
 { $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } }
 { $description "Computes the dot product of two vectors." } ;
 
+HELP: h.
+{ $values { "u" "a sequence of real numbers" } { "v" "a sequence of real numbers" } { "x" "a real number" } }
+{ $description "Computes the Hermitian inner product of two vectors." } ;
+
 HELP: vs+
 { $values { "u" "a sequence of numbers" } { "v" "a sequence of numbers" } { "w" "a sequence of numbers" } }
 { $description "Adds " { $snippet "u" } " and " { $snippet "v" } " component-wise with saturation." }
index 54ffc924811b54e2cf375006e9eb9fc39b66947f..3f6a34cea3c1a34846bc4c1a8ab6404e83a011ed 100644 (file)
@@ -23,4 +23,7 @@ SPECIALIZED-ARRAY: int
 
 [ { 0 3 2 5 4 } ] [ { 1 2 3 4 5 } { 1 1 1 1 1 } v+- ] unit-test
 
-[ 1 ] [ { C{ 0 1 } } dup v. ] unit-test
+[ 32 ] [ { 1 2 3 } { 4 5 6 } v. ] unit-test
+[ -1 ] [ { C{ 0 1 } } dup v. ] unit-test
+
+[ 1 ] [ { C{ 0 1 } } dup h. ] unit-test
index 35b69f74a2a3c09527a91a54670d533ce0fd8c31..3f933c10b5243d53bd024d15cd4fad4273bf8176 100644 (file)
@@ -208,7 +208,10 @@ M: object v?
 : vinfimum ( seq -- vmin ) [ ] [ vmin ] map-reduce ; inline
 
 GENERIC: v. ( u v -- x )
-M: object v. [ conjugate * ] [ + ] 2map-reduce ; inline
+M: object v. [ * ] [ + ] 2map-reduce ; inline
+
+GENERIC: h. ( u v -- x )
+M: object h. [ conjugate * ] [ + ] 2map-reduce ; inline
 
 GENERIC: norm-sq ( v -- x )
 M: object norm-sq [ absq ] [ + ] map-reduce ; inline