eliminate spin from basis
parent
02f209b30a
commit
fa6d7b7069
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2009 Marc Fauconneau.
|
! Copyright (C) 2009 Marc Fauconneau.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays byte-arrays combinators
|
USING: accessors arrays byte-arrays combinators
|
||||||
grouping compression.huffman images
|
grouping compression.huffman images fry
|
||||||
images.processing io io.binary io.encodings.binary io.files
|
images.processing io io.binary io.encodings.binary io.files
|
||||||
io.streams.byte-array kernel locals math math.bitwise
|
io.streams.byte-array kernel locals math math.bitwise
|
||||||
math.constants math.functions math.matrices math.order
|
math.constants math.functions math.matrices math.order
|
||||||
|
@ -232,7 +232,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
|
||||||
block dup length>> sqrt >fixnum group flip
|
block dup length>> sqrt >fixnum group flip
|
||||||
dup matrix-dim coord-matrix flip
|
dup matrix-dim coord-matrix flip
|
||||||
[
|
[
|
||||||
[ first2 spin nth nth ]
|
[ '[ _ [ second ] [ first ] bi ] dip nth nth ]
|
||||||
[ x,y v+ color-id jpeg-image draw-color ] bi
|
[ x,y v+ color-id jpeg-image draw-color ] bi
|
||||||
] with each^2 ;
|
] with each^2 ;
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,17 @@ M: winnt add-completion ( win32-handle -- )
|
||||||
} cond
|
} cond
|
||||||
] with-timeout ;
|
] with-timeout ;
|
||||||
|
|
||||||
:: wait-for-overlapped ( us -- bytes-transferred overlapped error? )
|
:: wait-for-overlapped ( usec -- bytes-transferred overlapped error? )
|
||||||
master-completion-port get-global
|
master-completion-port get-global
|
||||||
0 <int> [ ! bytes
|
0 <int> :> bytes
|
||||||
f <void*> ! key
|
f <void*> :> key
|
||||||
f <void*> [ ! overlapped
|
f <void*> :> overlapped
|
||||||
us [ 1000 /i ] [ INFINITE ] if* ! timeout
|
usec [ 1000 /i ] [ INFINITE ] if* :> timeout
|
||||||
GetQueuedCompletionStatus zero?
|
bytes key overlapped timeout GetQueuedCompletionStatus zero? :> error?
|
||||||
] keep
|
|
||||||
*void* dup [ OVERLAPPED memory>struct ] when
|
bytes *int
|
||||||
] keep *int spin ;
|
overlapped *void* dup [ OVERLAPPED memory>struct ] when
|
||||||
|
error? ;
|
||||||
|
|
||||||
: resume-callback ( result overlapped -- )
|
: resume-callback ( result overlapped -- )
|
||||||
>c-ptr pending-overlapped get-global delete-at* drop resume-with ;
|
>c-ptr pending-overlapped get-global delete-at* drop resume-with ;
|
||||||
|
|
|
@ -78,10 +78,10 @@ PRIVATE>
|
||||||
: n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V! ; inline
|
: n*V+V ( alpha x y -- alpha*x+y ) clone n*V+V! ; inline
|
||||||
: n*V ( alpha x -- alpha*x ) clone n*V! ; inline
|
: n*V ( alpha x -- alpha*x ) clone n*V! ; inline
|
||||||
|
|
||||||
: V+ ( x y -- x+y )
|
:: V+ ( x y -- x+y )
|
||||||
1.0 -rot n*V+V ; inline
|
1.0 x y n*V+V ; inline
|
||||||
: V- ( x y -- x-y )
|
:: V- ( x y -- x-y )
|
||||||
-1.0 spin n*V+V ; inline
|
-1.0 y x n*V+V ; inline
|
||||||
|
|
||||||
: Vneg ( x -- -x )
|
: Vneg ( x -- -x )
|
||||||
-1.0 swap n*V ; inline
|
-1.0 swap n*V ; inline
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2006, 2008 Slava Pestov.
|
! Copyright (C) 2006, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math math.vectors math.matrices namespaces
|
USING: kernel locals math math.vectors math.matrices
|
||||||
sequences ;
|
namespaces sequences ;
|
||||||
IN: math.matrices.elimination
|
IN: math.matrices.elimination
|
||||||
|
|
||||||
SYMBOL: matrix
|
SYMBOL: matrix
|
||||||
|
@ -85,12 +85,11 @@ SYMBOL: matrix
|
||||||
] each
|
] each
|
||||||
] with-matrix ;
|
] with-matrix ;
|
||||||
|
|
||||||
: basis-vector ( row col# -- )
|
:: basis-vector ( row col# -- )
|
||||||
[ clone ] dip
|
row clone :> row'
|
||||||
[ swap nth neg recip ] 2keep
|
col# row' nth neg recip :> a
|
||||||
[ 0 spin set-nth ] 2keep
|
0 col# row' set-nth
|
||||||
[ n*v ] dip
|
a row n*v col# matrix get set-nth ;
|
||||||
matrix get set-nth ;
|
|
||||||
|
|
||||||
: nullspace ( matrix -- seq )
|
: nullspace ( matrix -- seq )
|
||||||
echelon reduced dup empty? [
|
echelon reduced dup empty? [
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
IN: persistent.hashtables.tests
|
IN: persistent.hashtables.tests
|
||||||
USING: persistent.hashtables persistent.assocs hashtables assocs
|
USING: persistent.hashtables persistent.assocs hashtables assocs
|
||||||
tools.test kernel namespaces random math.ranges sequences fry ;
|
tools.test kernel locals namespaces random math.ranges sequences fry ;
|
||||||
|
|
||||||
[ t ] [ PH{ } assoc-empty? ] unit-test
|
[ t ] [ PH{ } assoc-empty? ] unit-test
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ M: hash-0-b hashcode* 2drop 0 ;
|
||||||
: random-assocs ( n -- hash phash )
|
: random-assocs ( n -- hash phash )
|
||||||
[ random-string ] replicate
|
[ random-string ] replicate
|
||||||
[ H{ } clone [ '[ swap _ set-at ] each-index ] keep ]
|
[ H{ } clone [ '[ swap _ set-at ] each-index ] keep ]
|
||||||
[ PH{ } clone swap [ spin new-at ] each-index ]
|
[ PH{ } clone swap [| ph elt i | i elt ph new-at ] each-index ]
|
||||||
bi ;
|
bi ;
|
||||||
|
|
||||||
: ok? ( assoc1 assoc2 -- ? )
|
: ok? ( assoc1 assoc2 -- ? )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Based on Clojure's PersistentHashMap by Rich Hickey.
|
! Based on Clojure's PersistentHashMap by Rich Hickey.
|
||||||
|
|
||||||
USING: kernel math accessors assocs fry combinators parser
|
USING: kernel math accessors assocs fry combinators parser
|
||||||
prettyprint.custom make
|
prettyprint.custom locals make
|
||||||
persistent.assocs
|
persistent.assocs
|
||||||
persistent.hashtables.nodes
|
persistent.hashtables.nodes
|
||||||
persistent.hashtables.nodes.empty
|
persistent.hashtables.nodes.empty
|
||||||
|
@ -38,8 +38,8 @@ M: persistent-hash pluck-at
|
||||||
|
|
||||||
M: persistent-hash >alist [ root>> >alist% ] { } make ;
|
M: persistent-hash >alist [ root>> >alist% ] { } make ;
|
||||||
|
|
||||||
: >persistent-hash ( assoc -- phash )
|
:: >persistent-hash ( assoc -- phash )
|
||||||
T{ persistent-hash } swap [ spin new-at ] assoc-each ;
|
T{ persistent-hash } assoc [| ph k v | v k ph new-at ] assoc-each ;
|
||||||
|
|
||||||
M: persistent-hash equal?
|
M: persistent-hash equal?
|
||||||
over persistent-hash? [ assoc= ] [ 2drop f ] if ;
|
over persistent-hash? [ assoc= ] [ 2drop f ] if ;
|
||||||
|
|
|
@ -44,12 +44,12 @@ TUPLE: parts in out ;
|
||||||
[ _ meaningful-integers ] keep add-out
|
[ _ meaningful-integers ] keep add-out
|
||||||
] map ;
|
] map ;
|
||||||
|
|
||||||
: class-partitions ( classes -- assoc )
|
:: class-partitions ( classes -- assoc )
|
||||||
[ integer? ] partition [
|
classes [ integer? ] partition :> ( integers classes )
|
||||||
dup powerset-partition spin add-integers
|
|
||||||
[ [ partition>class ] keep 2array ] map
|
classes powerset-partition classes integers add-integers
|
||||||
[ first ] filter
|
[ [ partition>class ] keep 2array ] map [ first ] filter
|
||||||
] [ '[ _ singleton-partition ] map ] 2bi append ;
|
integers [ classes singleton-partition ] map append ;
|
||||||
|
|
||||||
: new-transitions ( transitions -- assoc ) ! assoc is class, partition
|
: new-transitions ( transitions -- assoc ) ! assoc is class, partition
|
||||||
values [ keys ] gather
|
values [ keys ] gather
|
||||||
|
|
|
@ -9,7 +9,7 @@ IN: validators
|
||||||
>lower "on" = ;
|
>lower "on" = ;
|
||||||
|
|
||||||
: v-default ( str def -- str/def )
|
: v-default ( str def -- str/def )
|
||||||
over empty? spin ? ;
|
[ nip empty? ] 2keep ? ;
|
||||||
|
|
||||||
: v-required ( str -- str )
|
: v-required ( str -- str )
|
||||||
dup empty? [ "required" throw ] when ;
|
dup empty? [ "required" throw ] when ;
|
||||||
|
|
|
@ -44,8 +44,8 @@ C: <test-implementation> test-implementation
|
||||||
[ >>x drop ] ! IInherited::setX
|
[ >>x drop ] ! IInherited::setX
|
||||||
} }
|
} }
|
||||||
{ IUnrelated {
|
{ IUnrelated {
|
||||||
[ swap x>> + ] ! IUnrelated::xPlus
|
[ [ x>> ] [ + ] bi* ] ! IUnrelated::xPlus
|
||||||
[ spin x>> * + ] ! IUnrelated::xMulAdd
|
[ [ x>> ] [ * ] [ + ] tri* ] ! IUnrelated::xMulAdd
|
||||||
} }
|
} }
|
||||||
} <com-wrapper>
|
} <com-wrapper>
|
||||||
dup +test-wrapper+ set [
|
dup +test-wrapper+ set [
|
||||||
|
|
|
@ -27,8 +27,8 @@ COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
|
||||||
[ >>x drop ] ! IInherited::setX
|
[ >>x drop ] ! IInherited::setX
|
||||||
} }
|
} }
|
||||||
{ "IUnrelated" {
|
{ "IUnrelated" {
|
||||||
[ swap x>> + ] ! IUnrelated::xPlus
|
[ [ x>> ] [ + ] bi* ] ! IUnrelated::xPlus
|
||||||
[ spin x>> * + ] ! IUnrealted::xMulAdd
|
[ [ x>> ] [ * ] [ + ] tri* ] ! IUnrealted::xMulAdd
|
||||||
} }
|
} }
|
||||||
} <com-wrapper>""" } ;
|
} <com-wrapper>""" } ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue