From 18cf8c37e1282be2970db4682fb5f6b8dfcc55b0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 27 Sep 2009 17:18:02 -0500 Subject: [PATCH] math.vectors.simd: add *-cast words for converting between representations --- basis/math/vectors/simd/functor/functor.factor | 8 ++++++++ basis/math/vectors/simd/simd-docs.factor | 1 + 2 files changed, 9 insertions(+) diff --git a/basis/math/vectors/simd/functor/functor.factor b/basis/math/vectors/simd/functor/functor.factor index c76ed573d5..6ed74caa1f 100644 --- a/basis/math/vectors/simd/functor/functor.factor +++ b/basis/math/vectors/simd/functor/functor.factor @@ -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 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 ) diff --git a/basis/math/vectors/simd/simd-docs.factor b/basis/math/vectors/simd/simd-docs.factor index 2fdb9ff88c..6dc0f87dd4 100644 --- a/basis/math/vectors/simd/simd-docs.factor +++ b/basis/math/vectors/simd/simd-docs.factor @@ -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" } }