math.vectors.simd: add *-cast words for converting between representations

db4
Slava Pestov 2009-09-27 17:18:02 -05:00
parent 77fa16c76f
commit 18cf8c37e1
2 changed files with 9 additions and 0 deletions

View File

@ -111,6 +111,7 @@ N [ 16 T heap-size /i ]
A DEFINES-CLASS ${T}-${N}
A-boa DEFINES ${A}-boa
A-with DEFINES ${A}-with
A-cast DEFINES ${A}-cast
>A DEFINES >${A}
A{ DEFINES ${A}{
@ -170,6 +171,9 @@ SYNTAX: A{ \ } [ >A ] parse-literal ;
\ A-boa \ A-rep \ A define-boa-custom-inlining
] when
: A-cast ( simd-array -- simd-array' )
underlying>> \ A boa ; inline
INSTANCE: A sequence
<PRIVATE
@ -228,6 +232,7 @@ A/2-with IS ${A/2}-with
A DEFINES-CLASS ${T}-${N}
A-boa DEFINES ${A}-boa
A-with DEFINES ${A}-with
A-cast DEFINES ${A}-cast
>A DEFINES >${A}
A{ DEFINES ${A}{
@ -295,6 +300,9 @@ M: A pprint* pprint-object ;
\ A-rep 2 boa-effect \ A-boa set-stack-effect
: A-cast ( simd-array -- simd-array' )
[ underlying1>> ] [ underlying2>> ] bi \ A boa ; inline
INSTANCE: A sequence
: A-vv->v-op ( v1 v2 quot -- v3 )

View File

@ -68,6 +68,7 @@ ARTICLE: "math.vectors.simd.words" "SIMD vector words"
{ "Word" "Stack effect" "Description" }
{ { $snippet "type-with" } { $snippet "( x -- simd-array )" } "creates a new instance where all components are set to a single scalar" }
{ { $snippet "type-boa" } { $snippet "( ... -- simd-array )" } "creates a new instance where components are read from the stack" }
{ { $snipept "type-cast" } { $snippet "( simd-array -- simd-array' )" } "creates a new SIMD array where the underlying data is taken from another SIMD array, with no format conversion" }
{ { $snippet ">type" } { $snippet "( seq -- simd-array )" } "creates a new instance initialized with the elements of an existing sequence, which must have the correct length" }
{ { $snippet "type{" } { $snippet "type{ elements... }" } "parsing word defining literal syntax for an SIMD vector; the correct number of elements must be given" }
}