Merge branch 'master' of git://factorcode.org/git/factor
commit
9d4bf40e46
|
@ -84,7 +84,7 @@ M:: #recursive remove-dead-code* ( node -- nodes )
|
||||||
drop-outputs [ node drop-recursive-outputs ] |
|
drop-outputs [ node drop-recursive-outputs ] |
|
||||||
node [ (remove-dead-code) ] change-child drop
|
node [ (remove-dead-code) ] change-child drop
|
||||||
node label>> [ filter-live ] change-enter-out drop
|
node label>> [ filter-live ] change-enter-out drop
|
||||||
drop-inputs node drop-outputs 3array
|
{ drop-inputs node drop-outputs }
|
||||||
] ;
|
] ;
|
||||||
|
|
||||||
M: #return-recursive remove-dead-code* ;
|
M: #return-recursive remove-dead-code* ;
|
||||||
|
|
|
@ -7,7 +7,8 @@ byte-arrays classes.algebra classes.tuple.private
|
||||||
math.functions math.private strings layouts
|
math.functions math.private strings layouts
|
||||||
compiler.tree.propagation.info compiler.tree.def-use
|
compiler.tree.propagation.info compiler.tree.def-use
|
||||||
compiler.tree.debugger compiler.tree.checker
|
compiler.tree.debugger compiler.tree.checker
|
||||||
slots.private words hashtables classes assocs ;
|
slots.private words hashtables classes assocs locals
|
||||||
|
float-arrays ;
|
||||||
IN: compiler.tree.propagation.tests
|
IN: compiler.tree.propagation.tests
|
||||||
|
|
||||||
\ propagate must-infer
|
\ propagate must-infer
|
||||||
|
@ -587,6 +588,8 @@ MIXIN: empty-mixin
|
||||||
[ { fixnum integer } declare bitand ] final-classes
|
[ { fixnum integer } declare bitand ] final-classes
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ V{ float-array } ] [ [| | F{ } ] final-classes ] unit-test
|
||||||
|
|
||||||
! [ V{ string } ] [
|
! [ V{ string } ] [
|
||||||
! [ dup string? t xor [ "A" throw ] [ ] if ] final-classes
|
! [ dup string? t xor [ "A" throw ] [ ] if ] final-classes
|
||||||
! ] unit-test
|
! ] unit-test
|
||||||
|
|
|
@ -62,10 +62,6 @@ M: float-regs store-return-reg load/store-float-return FSTP ;
|
||||||
: with-aligned-stack ( n quot -- )
|
: with-aligned-stack ( n quot -- )
|
||||||
swap dup align-sub slip align-add ; inline
|
swap dup align-sub slip align-add ; inline
|
||||||
|
|
||||||
! On x86, we can always use an address as an operand
|
|
||||||
! directly.
|
|
||||||
M: x86.32 address-operand ;
|
|
||||||
|
|
||||||
M: x86.32 fixnum>slot@ 1 SHR ;
|
M: x86.32 fixnum>slot@ 1 SHR ;
|
||||||
|
|
||||||
M: x86.32 prepare-division CDQ ;
|
M: x86.32 prepare-division CDQ ;
|
||||||
|
|
|
@ -33,13 +33,6 @@ M: float-regs vregs
|
||||||
M: float-regs param-regs
|
M: float-regs param-regs
|
||||||
drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ;
|
drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ;
|
||||||
|
|
||||||
M: x86.64 address-operand ( address -- operand )
|
|
||||||
#! On AMD64, we have to load 64-bit addresses into a
|
|
||||||
#! scratch register first. The usage of R11 here is a hack.
|
|
||||||
#! This word can only be called right before a subroutine
|
|
||||||
#! call, where all vregs have been flushed anyway.
|
|
||||||
temp-reg v>operand [ swap MOV ] keep ;
|
|
||||||
|
|
||||||
M: x86.64 fixnum>slot@ drop ;
|
M: x86.64 fixnum>slot@ drop ;
|
||||||
|
|
||||||
M: x86.64 prepare-division CQO ;
|
M: x86.64 prepare-division CQO ;
|
||||||
|
@ -49,8 +42,8 @@ M: x86.64 load-indirect ( literal reg -- )
|
||||||
|
|
||||||
M: stack-params %load-param-reg
|
M: stack-params %load-param-reg
|
||||||
drop
|
drop
|
||||||
>r temp-reg v>operand swap stack@ MOV
|
>r R11 swap stack@ MOV
|
||||||
r> stack@ temp-reg v>operand MOV ;
|
r> stack@ R11 MOV ;
|
||||||
|
|
||||||
M: stack-params %save-param-reg
|
M: stack-params %save-param-reg
|
||||||
>r stack-frame* + cell + swap r> %load-param-reg ;
|
>r stack-frame* + cell + swap r> %load-param-reg ;
|
||||||
|
@ -138,7 +131,9 @@ M: x86.64 %alien-global
|
||||||
[ 0 MOV rc-absolute-cell rel-dlsym ] [ dup [] MOV ] bi ;
|
[ 0 MOV rc-absolute-cell rel-dlsym ] [ dup [] MOV ] bi ;
|
||||||
|
|
||||||
M: x86.64 %alien-invoke
|
M: x86.64 %alien-invoke
|
||||||
0 address-operand >r rc-absolute-cell rel-dlsym r> CALL ;
|
R11 0 MOV
|
||||||
|
rc-absolute-cell rel-dlsym
|
||||||
|
R11 CALL ;
|
||||||
|
|
||||||
M: x86.64 %prepare-alien-indirect ( -- )
|
M: x86.64 %prepare-alien-indirect ( -- )
|
||||||
"unbox_alien" f %alien-invoke
|
"unbox_alien" f %alien-invoke
|
||||||
|
|
|
@ -39,8 +39,6 @@ GENERIC: store-return-reg ( stack@ reg-class -- )
|
||||||
HOOK: temp-reg-1 cpu ( -- reg )
|
HOOK: temp-reg-1 cpu ( -- reg )
|
||||||
HOOK: temp-reg-2 cpu ( -- reg )
|
HOOK: temp-reg-2 cpu ( -- reg )
|
||||||
|
|
||||||
HOOK: address-operand cpu ( address -- operand )
|
|
||||||
|
|
||||||
HOOK: fixnum>slot@ cpu ( op -- )
|
HOOK: fixnum>slot@ cpu ( op -- )
|
||||||
|
|
||||||
HOOK: prepare-division cpu ( -- )
|
HOOK: prepare-division cpu ( -- )
|
||||||
|
|
|
@ -20,9 +20,24 @@ HELP: specialized-def
|
||||||
{ $description "Outputs the definition of a word after it has been split into specialized branches. This is the definition which will actually be compiled by the compiler." } ;
|
{ $description "Outputs the definition of a word after it has been split into specialized branches. This is the definition which will actually be compiled by the compiler." } ;
|
||||||
|
|
||||||
HELP: HINTS:
|
HELP: HINTS:
|
||||||
{ $values { "word" word } { "hints..." "a list of sequences of classes" } }
|
{ $values { "defspec" "a definition specifier" } { "hints..." "a list of sequences of classes" } }
|
||||||
{ $description "Defines specialization hints for each words. Each sequence of classes in the list will cause a specialized version of the word to be compiled." }
|
{ $description "Defines specialization hints for a word or a method."
|
||||||
|
$nl
|
||||||
|
"Each sequence of classes in the list will cause a specialized version of the word to be compiled." }
|
||||||
{ $examples "The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:"
|
{ $examples "The " { $link append } " word has a specializer for the very common case where two strings or two arrays are appended:"
|
||||||
{ $code "HINTS: append { string string } { array array } ;" } } ;
|
{ $code "HINTS: append { string string } { array array } ;" }
|
||||||
|
"Specializers can also be defined on methods:"
|
||||||
|
{ $code
|
||||||
|
"GENERIC: count-occurrences ( elt obj -- n )"
|
||||||
|
""
|
||||||
|
"M: sequence count-occurrences [ = ] with count ;"
|
||||||
|
""
|
||||||
|
"M: assoc count-occurrences"
|
||||||
|
" swap [ = nip ] curry assoc-filter assoc-size ;"
|
||||||
|
""
|
||||||
|
"HINTS: { sequence count-occurrences } { object array } ;"
|
||||||
|
"HINTS: { assoc count-occurrences } { object hashtable } ;"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
ABOUT: "hints"
|
ABOUT: "hints"
|
||||||
|
|
|
@ -42,11 +42,11 @@ IN: hints
|
||||||
|
|
||||||
: specialized-def ( word -- quot )
|
: specialized-def ( word -- quot )
|
||||||
dup def>> swap {
|
dup def>> swap {
|
||||||
{ [ dup standard-method? ] [ specialize-method ] }
|
|
||||||
{
|
{
|
||||||
[ dup "specializer" word-prop ]
|
[ dup "specializer" word-prop ]
|
||||||
[ "specializer" word-prop specialize-quot ]
|
[ "specializer" word-prop specialize-quot ]
|
||||||
}
|
}
|
||||||
|
{ [ dup standard-method? ] [ specialize-method ] }
|
||||||
[ drop ]
|
[ drop ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ IN: hints
|
||||||
dup [ array? ] all? [ first ] when length ;
|
dup [ array? ] all? [ first ] when length ;
|
||||||
|
|
||||||
: HINTS:
|
: HINTS:
|
||||||
scan-word
|
scan-object
|
||||||
|
dup method-spec? [ first2 method ] when
|
||||||
[ redefined ]
|
[ redefined ]
|
||||||
[ parse-definition "specializer" set-word-prop ] bi ;
|
[ parse-definition "specializer" set-word-prop ] bi ;
|
||||||
parsing
|
parsing
|
||||||
|
|
|
@ -330,3 +330,5 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
|
||||||
|
|
||||||
[ T{ slice f 0 3 "abc" } ]
|
[ T{ slice f 0 3 "abc" } ]
|
||||||
[ 0 3 "abc" [| from to seq | T{ slice f from to seq } ] call ] unit-test
|
[ 0 3 "abc" [| from to seq | T{ slice f from to seq } ] call ] unit-test
|
||||||
|
|
||||||
|
{ 3 1 } [| from to seq | T{ slice f from to seq } ] must-infer-as
|
|
@ -6,7 +6,7 @@ quotations debugger macros arrays macros splitting combinators
|
||||||
prettyprint.backend definitions prettyprint hashtables
|
prettyprint.backend definitions prettyprint hashtables
|
||||||
prettyprint.sections sets sequences.private effects
|
prettyprint.sections sets sequences.private effects
|
||||||
effects.parser generic generic.parser compiler.units accessors
|
effects.parser generic generic.parser compiler.units accessors
|
||||||
locals.backend memoize macros.expander lexer
|
locals.backend memoize macros.expander lexer classes
|
||||||
stack-checker.known-words ;
|
stack-checker.known-words ;
|
||||||
IN: locals
|
IN: locals
|
||||||
|
|
||||||
|
@ -195,70 +195,41 @@ M: block lambda-rewrite*
|
||||||
swap point-free ,
|
swap point-free ,
|
||||||
] keep length \ curry <repetition> % ;
|
] keep length \ curry <repetition> % ;
|
||||||
|
|
||||||
|
GENERIC: rewrite-element ( obj -- )
|
||||||
|
|
||||||
|
: rewrite-elements ( seq -- )
|
||||||
|
[ rewrite-element ] each ;
|
||||||
|
|
||||||
|
: rewrite-sequence ( seq -- )
|
||||||
|
[ rewrite-elements ] [ length , ] [ , ] tri \ nsequence , ;
|
||||||
|
|
||||||
|
M: array rewrite-element rewrite-sequence ;
|
||||||
|
|
||||||
|
M: vector rewrite-element rewrite-sequence ;
|
||||||
|
|
||||||
|
M: hashtable rewrite-element >alist rewrite-sequence \ >hashtable , ;
|
||||||
|
|
||||||
|
M: tuple rewrite-element
|
||||||
|
[ tuple-slots rewrite-elements ] [ class , ] bi \ boa , ;
|
||||||
|
|
||||||
|
M: local rewrite-element , ;
|
||||||
|
|
||||||
|
M: word rewrite-element literalize , ;
|
||||||
|
|
||||||
|
M: object rewrite-element , ;
|
||||||
|
|
||||||
|
M: array local-rewrite* rewrite-element ;
|
||||||
|
|
||||||
|
M: vector local-rewrite* rewrite-element ;
|
||||||
|
|
||||||
|
M: tuple local-rewrite* rewrite-element ;
|
||||||
|
|
||||||
|
M: hashtable local-rewrite* rewrite-element ;
|
||||||
|
|
||||||
M: object lambda-rewrite* , ;
|
M: object lambda-rewrite* , ;
|
||||||
|
|
||||||
M: object local-rewrite* , ;
|
M: object local-rewrite* , ;
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
! Broil is used to support locals in literals
|
|
||||||
|
|
||||||
DEFER: [broil]
|
|
||||||
DEFER: [broil-hashtable]
|
|
||||||
DEFER: [broil-tuple]
|
|
||||||
|
|
||||||
: broil-element ( obj -- quot )
|
|
||||||
{
|
|
||||||
{ [ dup number? ] [ 1quotation ] }
|
|
||||||
{ [ dup string? ] [ 1quotation ] }
|
|
||||||
{ [ dup sequence? ] [ [broil] ] }
|
|
||||||
{ [ dup hashtable? ] [ [broil-hashtable] ] }
|
|
||||||
{ [ dup tuple? ] [ [broil-tuple] ] }
|
|
||||||
{ [ dup local? ] [ 1quotation ] }
|
|
||||||
{ [ dup word? ] [ literalize 1quotation ] }
|
|
||||||
{ [ t ] [ 1quotation ] }
|
|
||||||
}
|
|
||||||
cond ;
|
|
||||||
|
|
||||||
: [broil] ( seq -- quot )
|
|
||||||
[ [ broil-element ] map concat >quotation ]
|
|
||||||
[ length ]
|
|
||||||
[ ]
|
|
||||||
tri
|
|
||||||
[ nsequence ] curry curry compose ;
|
|
||||||
|
|
||||||
MACRO: broil ( seq -- quot ) [broil] ;
|
|
||||||
|
|
||||||
: [broil-hashtable] ( hashtable -- quot )
|
|
||||||
>alist
|
|
||||||
[ [ broil-element ] map concat >quotation ]
|
|
||||||
[ length ]
|
|
||||||
[ ]
|
|
||||||
tri
|
|
||||||
[ nsequence >hashtable ] curry curry compose ;
|
|
||||||
|
|
||||||
MACRO: broil-hashtable ( hashtable -- quot ) [broil-hashtable] ;
|
|
||||||
|
|
||||||
: [broil-tuple] ( tuple -- quot )
|
|
||||||
tuple>array
|
|
||||||
[ [ broil-element ] map concat >quotation ]
|
|
||||||
[ length ]
|
|
||||||
[ ]
|
|
||||||
tri
|
|
||||||
[ nsequence >tuple ] curry curry compose ;
|
|
||||||
|
|
||||||
MACRO: broil-tuple ( tuple -- quot ) [broil-tuple] ;
|
|
||||||
|
|
||||||
! Engage broil on arrays and vectors. Can't do it on 'sequence'
|
|
||||||
! because that will pick up strings and integers. What do do...
|
|
||||||
|
|
||||||
M: array local-rewrite* ( array -- ) [broil] % ;
|
|
||||||
M: vector local-rewrite* ( vector -- ) [broil] % ;
|
|
||||||
M: tuple local-rewrite* ( tuple -- ) [broil-tuple] % ;
|
|
||||||
M: hashtable local-rewrite* ( hashtable -- ) [broil-hashtable] % ;
|
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
: make-local ( name -- word )
|
: make-local ( name -- word )
|
||||||
"!" ?tail [
|
"!" ?tail [
|
||||||
<local-reader>
|
<local-reader>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors kernel words parser io summary quotations
|
USING: accessors kernel words parser io summary quotations
|
||||||
sequences prettyprint continuations effects definitions
|
sequences prettyprint continuations effects definitions
|
||||||
compiler.units namespaces assocs tools.walker generic
|
compiler.units namespaces assocs tools.walker generic
|
||||||
inspector ;
|
inspector fry ;
|
||||||
IN: tools.annotations
|
IN: tools.annotations
|
||||||
|
|
||||||
GENERIC: reset ( word -- )
|
GENERIC: reset ( word -- )
|
||||||
|
@ -49,20 +49,18 @@ M: word reset
|
||||||
.s
|
.s
|
||||||
] if* "\\--" print flush ;
|
] if* "\\--" print flush ;
|
||||||
|
|
||||||
: (watch) ( word def -- def )
|
: (watch) ( word def -- def ) over '[ _ entering @ _ leaving ] ;
|
||||||
over [ entering ] curry
|
|
||||||
rot [ leaving ] curry
|
|
||||||
swapd 3append ;
|
|
||||||
|
|
||||||
: watch ( word -- )
|
: watch ( word -- )
|
||||||
dup [ (watch) ] annotate ;
|
dup [ (watch) ] annotate ;
|
||||||
|
|
||||||
: (watch-vars) ( quot word vars -- newquot )
|
: (watch-vars) ( quot word vars -- newquot )
|
||||||
[
|
rot
|
||||||
"--- Entering: " write swap .
|
'[
|
||||||
"--- Variable values:" print
|
"--- Entering: " write _ .
|
||||||
[ dup get ] H{ } map>assoc describe
|
"--- Variable values:" print _ [ dup get ] H{ } map>assoc describe
|
||||||
] 2curry prepose ;
|
@
|
||||||
|
] ;
|
||||||
|
|
||||||
: watch-vars ( word vars -- )
|
: watch-vars ( word vars -- )
|
||||||
dupd [ (watch-vars) ] 2curry annotate ;
|
dupd [ (watch-vars) ] 2curry annotate ;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
USING: arrays accessors float-arrays io io.files
|
USING: arrays accessors float-arrays io io.files
|
||||||
io.encodings.binary kernel math math.functions math.vectors
|
io.encodings.binary kernel math math.functions math.vectors
|
||||||
math.parser make sequences sequences.private words ;
|
math.parser make sequences sequences.private words hints ;
|
||||||
IN: benchmark.raytracer
|
IN: benchmark.raytracer
|
||||||
|
|
||||||
! parameters
|
! parameters
|
||||||
|
@ -38,34 +38,40 @@ TUPLE: sphere { center float-array read-only } { radius float read-only } ;
|
||||||
C: <sphere> sphere
|
C: <sphere> sphere
|
||||||
|
|
||||||
: sphere-v ( sphere ray -- v )
|
: sphere-v ( sphere ray -- v )
|
||||||
swap center>> swap orig>> v- ; inline
|
[ center>> ] [ orig>> ] bi* v- ; inline
|
||||||
|
|
||||||
: sphere-b ( ray v -- b ) swap dir>> v. ; inline
|
: sphere-b ( v ray -- b )
|
||||||
|
dir>> v. ; inline
|
||||||
|
|
||||||
: sphere-disc ( sphere v b -- d )
|
: sphere-d ( sphere b v -- d )
|
||||||
sq swap norm-sq - swap radius>> sq + ; inline
|
[ radius>> sq ] [ sq ] [ norm-sq ] tri* - + ; inline
|
||||||
|
|
||||||
: -+ ( x y -- x-y x+y ) [ - ] 2keep + ; inline
|
: -+ ( x y -- x-y x+y )
|
||||||
|
[ - ] [ + ] 2bi ; inline
|
||||||
|
|
||||||
: sphere-b/d ( b d -- t )
|
: sphere-t ( b d -- t )
|
||||||
-+ dup 0.0 <
|
-+ dup 0.0 <
|
||||||
[ 2drop 1.0/0.0 ] [ [ [ 0.0 > ] keep ] dip ? ] if ; inline
|
[ 2drop 1.0/0.0 ] [ [ [ 0.0 > ] keep ] dip ? ] if ; inline
|
||||||
|
|
||||||
: ray-sphere ( sphere ray -- t )
|
: sphere-b&v ( sphere ray -- b v )
|
||||||
2dup sphere-v tuck sphere-b [ sphere-disc ] keep
|
[ sphere-v ] [ nip ] 2bi
|
||||||
over 0.0 < [ 2drop 1.0/0.0 ] [ swap sqrt sphere-b/d ] if ;
|
[ sphere-b ] [ drop ] 2bi ; inline
|
||||||
inline
|
|
||||||
|
|
||||||
: sphere-n ( ray sphere l -- n )
|
: ray-sphere ( sphere ray -- t )
|
||||||
pick dir>> n*v swap center>> v- swap orig>> v+ ;
|
[ drop ] [ sphere-b&v ] 2bi
|
||||||
inline
|
[ drop ] [ sphere-d ] 3bi
|
||||||
|
dup 0.0 < [ 3drop 1/0. ] [ sqrt sphere-t nip ] if ; inline
|
||||||
|
|
||||||
: if-ray-sphere ( hit ray sphere quot -- hit )
|
: if-ray-sphere ( hit ray sphere quot -- hit )
|
||||||
#! quot: hit ray sphere l -- hit
|
#! quot: hit ray sphere l -- hit
|
||||||
[
|
[
|
||||||
pick lambda>> [ 2dup swap ray-sphere dup ] dip >=
|
[ ] [ swap ray-sphere nip ] [ 2drop lambda>> ] 3tri
|
||||||
[ 3drop ]
|
[ drop ] [ < ] 2bi
|
||||||
] dip if ; inline
|
] dip [ 3drop ] if ; inline
|
||||||
|
|
||||||
|
: sphere-n ( ray sphere l -- n )
|
||||||
|
[ [ orig>> ] [ dir>> ] bi ] [ center>> ] [ ] tri*
|
||||||
|
swap [ v*n ] dip v- v+ ; inline
|
||||||
|
|
||||||
M: sphere intersect-scene ( hit ray sphere -- hit )
|
M: sphere intersect-scene ( hit ray sphere -- hit )
|
||||||
[ [ sphere-n normalize ] keep <hit> nip ] if-ray-sphere ;
|
[ [ sphere-n normalize ] keep <hit> nip ] if-ray-sphere ;
|
||||||
|
@ -79,21 +85,17 @@ TUPLE: group < sphere { objs array read-only } ;
|
||||||
swap [ { } make ] dip <group> ; inline
|
swap [ { } make ] dip <group> ; inline
|
||||||
|
|
||||||
M: group intersect-scene ( hit ray group -- hit )
|
M: group intersect-scene ( hit ray group -- hit )
|
||||||
[
|
[ drop objs>> [ intersect-scene ] with each ] if-ray-sphere ;
|
||||||
drop
|
|
||||||
objs>> [ [ tuck ] dip intersect-scene swap ] each
|
|
||||||
drop
|
|
||||||
] if-ray-sphere ;
|
|
||||||
|
|
||||||
: initial-hit T{ hit f F{ 0.0 0.0 0.0 } 1.0/0.0 } ; inline
|
: initial-hit T{ hit f F{ 0.0 0.0 0.0 } 1/0. } ; inline
|
||||||
|
|
||||||
: initial-intersect ( ray scene -- hit )
|
: initial-intersect ( ray scene -- hit )
|
||||||
initial-hit -rot intersect-scene ; inline
|
[ initial-hit ] 2dip intersect-scene ; inline
|
||||||
|
|
||||||
: ray-o ( ray hit -- o )
|
: ray-o ( ray hit -- o )
|
||||||
over dir>> over lambda>> v*n
|
[ [ orig>> ] [ normal>> delta v*n ] bi* ]
|
||||||
swap normal>> delta v*n v+
|
[ [ dir>> ] [ lambda>> ] bi* v*n ]
|
||||||
swap orig>> v+ ; inline
|
2bi v+ v+ ; inline
|
||||||
|
|
||||||
: sray-intersect ( ray scene hit -- ray )
|
: sray-intersect ( ray scene hit -- ray )
|
||||||
swap [ ray-o light vneg <ray> ] dip initial-intersect ; inline
|
swap [ ray-o light vneg <ray> ] dip initial-intersect ; inline
|
||||||
|
@ -101,10 +103,10 @@ M: group intersect-scene ( hit ray group -- hit )
|
||||||
: ray-g ( hit -- g ) normal>> light v. ; inline
|
: ray-g ( hit -- g ) normal>> light v. ; inline
|
||||||
|
|
||||||
: cast-ray ( ray scene -- g )
|
: cast-ray ( ray scene -- g )
|
||||||
2dup initial-intersect dup lambda>> 1.0/0.0 = [
|
2dup initial-intersect dup lambda>> 1/0. = [
|
||||||
3drop 0.0
|
3drop 0.0
|
||||||
] [
|
] [
|
||||||
[ sray-intersect lambda>> 1.0/0.0 = ] keep swap
|
[ sray-intersect lambda>> 1/0. = ] keep swap
|
||||||
[ ray-g neg ] [ drop 0.0 ] if
|
[ ray-g neg ] [ drop 0.0 ] if
|
||||||
] if ; inline
|
] if ; inline
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,10 @@ IN: benchmark.spectral-norm
|
||||||
: eval-AtA-times-u ( u n -- seq )
|
: eval-AtA-times-u ( u n -- seq )
|
||||||
[ eval-A-times-u ] [ eval-At-times-u ] bi ; inline
|
[ eval-A-times-u ] [ eval-At-times-u ] bi ; inline
|
||||||
|
|
||||||
|
: ones ( n -- seq ) [ 1.0 ] F{ } replicate-as ; inline
|
||||||
|
|
||||||
:: u/v ( n -- u v )
|
:: u/v ( n -- u v )
|
||||||
n 1.0 <repetition> >float-array dup
|
n ones dup
|
||||||
10 [
|
10 [
|
||||||
drop
|
drop
|
||||||
n eval-AtA-times-u
|
n eval-AtA-times-u
|
||||||
|
|
Loading…
Reference in New Issue