--- /dev/null
+! (c)Joe Groff bsd license
+USING: accessors alien.c-types arrays assocs classes combinators
+cords fry kernel math math.vectors sequences ;
+IN: math.vectors.conversion.backend
+
+: saturate-map-as ( v quot result -- w )
+ [ element-type '[ @ _ c-type-clamp ] ] keep map-as ; inline
+
+: (v>float) ( i to-type -- f )
+ [ >float ] swap new map-as ;
+: (v>integer) ( f to-type -- i )
+ [ >integer ] swap new map-as ;
+: (vpack-signed) ( a b to-type -- ab )
+ [ cord-append [ ] ] dip new saturate-map-as ;
+: (vpack-unsigned) ( a b to-type -- ab )
+ [ cord-append [ ] ] dip new saturate-map-as ;
+: (vunpack-head) ( ab to-type -- a )
+ [ dup length 2 /i head-slice ] dip new like ;
+: (vunpack-tail) ( ab to-type -- b )
+ [ dup length 2 /i tail-slice ] dip new like ;
+
! (c)Joe Groff bsd license
USING: accessors alien.c-types arrays assocs classes combinators
combinators.short-circuit cords fry kernel locals math
-math.vectors sequences ;
+math.vectors math.vectors.conversion.backend sequences ;
FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong float double ;
IN: math.vectors.conversion
<PRIVATE
-: saturate-map-as ( v quot result -- w )
- [ element-type '[ @ _ c-type-clamp ] ] keep map-as ; inline
-
-: (v>float) ( i to-type -- f )
- [ >float ] swap new map-as ;
-: (v>integer) ( f to-type -- i )
- [ >integer ] swap new map-as ;
-: (vpack-signed) ( a b to-type -- ab )
- [ cord-append [ ] ] dip new saturate-map-as ;
-: (vpack-unsigned) ( a b to-type -- ab )
- [ cord-append [ ] ] dip new saturate-map-as ;
-: (vunpack-head) ( ab to-type -- a )
- [ dup length 2 /i head-slice ] dip new like ;
-: (vunpack-tail) ( ab to-type -- b )
- [ dup length 2 /i tail-slice ] dip new like ;
-
: float-type? ( c-type -- ? )
{ float double } memq? ;
: unsigned-type? ( c-type -- ? )
USING: accessors assocs byte-arrays classes classes.algebra effects fry
functors generalizations kernel literals locals math math.functions
math.vectors math.vectors.private math.vectors.simd.intrinsics
-math.vectors.conversion math.vectors.conversion.private
+math.vectors.conversion.backend
math.vectors.specialization parser prettyprint.custom sequences
sequences.private strings words definitions macros cpu.architecture
namespaces arrays quotations combinators combinators.short-circuit sets
USING: alien alien.c-types alien.data assocs combinators
cpu.architecture compiler.cfg.comparisons fry generalizations
kernel libc macros math
-math.vectors.conversion math.vectors.conversion.private
+math.vectors.conversion.backend
sequences effects accessors namespaces
lexer parser vocabs.parser words arrays math.vectors ;
IN: math.vectors.simd.intrinsics
! See http://factorcode.org/license.txt for BSD license.
USING: words kernel make sequences effects sets kernel.private
accessors combinators math math.intervals math.vectors
-math.vectors.conversion math.vectors.conversion.private
+math.vectors.conversion.backend
namespaces assocs fry splitting classes.algebra generalizations
locals compiler.tree.propagation.info ;
IN: math.vectors.specialization