math.vectors: remove special handling for negative shifts, now we just say the behavior of vlshift and vrshift with negative shifts is undefined
parent
0be72153ff
commit
9d47f5d80d
|
@ -209,11 +209,13 @@ HELP: vbitxor
|
||||||
|
|
||||||
HELP: vlshift
|
HELP: vlshift
|
||||||
{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
|
{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
|
||||||
{ $description "Shifts each element of " { $snippet "u" } " to the left by " { $snippet "n" } " bits." } ;
|
{ $description "Shifts each element of " { $snippet "u" } " to the left by " { $snippet "n" } " bits." }
|
||||||
|
{ $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
|
||||||
|
|
||||||
HELP: vrshift
|
HELP: vrshift
|
||||||
{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
|
{ $values { "u" "a sequence of integers" } { "n" "a non-negative integer" } { "w" "a sequence of integers" } }
|
||||||
{ $description "Shifts each element of " { $snippet "u" } " to the right by " { $snippet "n" } " bits." } ;
|
{ $description "Shifts each element of " { $snippet "u" } " to the right by " { $snippet "n" } " bits." }
|
||||||
|
{ $notes "Undefined behavior will result if " { $snippet "n" } " is negative." } ;
|
||||||
|
|
||||||
HELP: norm-sq
|
HELP: norm-sq
|
||||||
{ $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
|
{ $values { "v" "a sequence of numbers" } { "x" "a non-negative real number" } }
|
||||||
|
|
|
@ -24,11 +24,3 @@ SPECIALIZED-ARRAY: int
|
||||||
[ { 0 3 2 5 4 } ] [ { 1 2 3 4 5 } { 1 1 1 1 1 } v+- ] unit-test
|
[ { 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
|
[ 1 ] [ { C{ 0 1 } } dup v. ] unit-test
|
||||||
|
|
||||||
! Make sure vector shifts behave the same as hardware SIMD vector shifts
|
|
||||||
[ int-array{ 0 0 0 0 } ] [ int-array{ 10 20 30 40 } -1 vlshift ] unit-test
|
|
||||||
|
|
||||||
[ int-array{ 0 0 0 0 } ] [
|
|
||||||
int-array{ 10 20 30 40 }
|
|
||||||
[ { int-array } declare -1 vlshift ] compile-call
|
|
||||||
] unit-test
|
|
|
@ -61,8 +61,8 @@ PRIVATE>
|
||||||
: vbitor ( u v -- w ) over '[ _ [ bitor ] fp-bitwise-op ] 2map ;
|
: vbitor ( u v -- w ) over '[ _ [ bitor ] fp-bitwise-op ] 2map ;
|
||||||
: vbitxor ( u v -- w ) over '[ _ [ bitxor ] fp-bitwise-op ] 2map ;
|
: vbitxor ( u v -- w ) over '[ _ [ bitxor ] fp-bitwise-op ] 2map ;
|
||||||
|
|
||||||
: vlshift ( u n -- w ) HEX: ffffffff bitand '[ _ shift ] map ;
|
: vlshift ( u n -- w ) '[ _ shift ] map ;
|
||||||
: vrshift ( u n -- w ) HEX: ffffffff bitand neg '[ _ shift ] map ;
|
: vrshift ( u n -- w ) neg '[ _ shift ] map ;
|
||||||
|
|
||||||
: vfloor ( u -- v ) [ floor ] map ;
|
: vfloor ( u -- v ) [ floor ] map ;
|
||||||
: vceiling ( u -- v ) [ ceiling ] map ;
|
: vceiling ( u -- v ) [ ceiling ] map ;
|
||||||
|
|
Loading…
Reference in New Issue