diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 35d6f380cb..9fc4f879e8 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -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 ; diff --git a/basis/math/vectors/vectors-docs.factor b/basis/math/vectors/vectors-docs.factor index b037d42786..920fbd81e6 100644 --- a/basis/math/vectors/vectors-docs.factor +++ b/basis/math/vectors/vectors-docs.factor @@ -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." } diff --git a/basis/math/vectors/vectors-tests.factor b/basis/math/vectors/vectors-tests.factor index 54ffc92481..3f6a34cea3 100644 --- a/basis/math/vectors/vectors-tests.factor +++ b/basis/math/vectors/vectors-tests.factor @@ -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 diff --git a/basis/math/vectors/vectors.factor b/basis/math/vectors/vectors.factor index 35b69f74a2..3f933c10b5 100644 --- a/basis/math/vectors/vectors.factor +++ b/basis/math/vectors/vectors.factor @@ -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