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 ;
{ $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." }
[ { 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
: 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