Commit Graph

63 Commits (14b1418f6a0c76397d0030c548408c56b4031163)

Author SHA1 Message Date
John Benediktsson e256a4ba18 math.intervals: workaround possible compiler bug by widening interval-bitor.
IN: scratchpad [
                   { byte-array } declare
                   [ 0 alien-unsigned-4 32 shift ]
                   [ 4 alien-unsigned-4 ] bi bitor
                   64 >signed
               ] optimized.

! working
[
    dup >R 0 alien-unsigned-4 32 fixnum-shift
    R> 4 alien-unsigned-4 over tag 0 eq?
    [ fixnum-bitor ] [ fixnum>bignum bignum-bitor ] if
    18446744073709551615 >R >bignum R> bignum-bitand
    dup 63 bignum-bit? [ 18446744073709551616 bignum- ] [ ] if
]

! broken
[
    dup >R 0 alien-unsigned-4 32 fixnum-shift
    R> 4 alien-unsigned-4 over tag 0 eq?
    [ fixnum-bitor ] [ fixnum>bignum bignum-bitor ] if
    dup 63 bignum-bit? [ 18446744073709551616 bignum- ] [ ] if
]

The second case correctly eliminates the bitand but incorrectly assumes
that the item on the stack (which is an integer -- either a fixnum or a
bignum), was converted to a bignum.
2019-10-31 10:45:54 -07:00
John Benediktsson f68df75b84 math.intervals: simplify interval-bitand. 2019-10-31 10:45:36 -07:00
John Benediktsson bccdb5419b math.intervals: improve interval-bitand. 2019-10-31 10:27:17 -07:00
John Benediktsson 20c4e2feaa math.intervals: remove extra non-interval tests. 2019-10-30 09:47:04 -07:00
timor 30f2d6e78f math.intervals.tests: clean up literal syntax 2019-10-30 09:44:39 -07:00
timor 449224878f math.intervals: more exact interval-bitxor operation
- fixed: `interval-bitxor` caused bit-growth
- improved: `interval-bitxor` more exact case for negative intervals
2019-10-30 09:44:23 -07:00
timor 713cfa79f8 math.intervals: more exact interval-bitor operation
Addresses #2170

- fixed: `interval-bitor` caused bit-growth
- improved: `interval-bitor` more exact about lower bounds

The added utility words could be used as a basis to make the other bitwise
interval operations more exact also.
2019-10-30 09:43:44 -07:00
timor 14d75bbbcb math.intervals: Consistent handling of special intervals
Make both `empty-interval` and `full-interval` singletons, use generic functions
and methods where they are special-cased.

All words which work with interval points should also now work with the special
intervals.
2019-09-09 14:09:57 -07:00
Doug Coleman e189954ecc core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota-tuple ... ; 2017-06-02 11:57:05 -05:00
John Benediktsson e477f6996f Fix comments to be ! not #!. 2015-09-08 16:15:10 -07:00
Doug Coleman 892c62e1dc factor: second stab at [ ] [ ] unit-test -> { } [ ] unit-test 2015-07-03 09:39:59 -07:00
Doug Coleman 59f3b1ea57 Revert "factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!"
Needs a bit more work.

This reverts commit 7e54cc2824.
2015-07-02 13:47:06 -07:00
Doug Coleman 7e54cc2824 factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool! 2015-07-02 11:36:08 -07:00
John Benediktsson 57f9d78892 improve help by linking to types directly. 2014-05-23 20:20:15 -07:00
John Benediktsson 013160df9a change some "2drop 2drop" to "4drop". 2012-10-23 12:21:30 -07:00
John Benediktsson 0359a4e823 math.intervals: using short-circuit logic. 2012-07-17 20:08:12 -07:00
Doug Coleman 51c033a1f6 Fix all failures in the linux64 build email 2011-10-24 19:33:09 -07:00
Doug Coleman 181f11faa8 Make M\ throw an error upon lookup failure. Change method -> ?lookup-method, lookup-method is the throwing version of ?lookup-method. Fixes #229. 2011-10-03 15:49:49 -07:00
Keita Haga e8ce62c64e math.intervals: fix some typos in docs 2011-01-18 21:18:35 +09:00
Doug Coleman 4c71d71907 random is generic now -- iota random -> random 2010-01-14 12:48:57 -06:00
Slava Pestov df4fb4a3ee Removing integers-as-sequences 2010-01-15 07:15:33 +13:00
Slava Pestov 0612bc6177 Factor source files should not be executable 2009-11-21 17:50:43 -06:00
Joe Groff 61d579360d remove non-primitive-related uses of tuck from basis 2009-11-05 17:03:24 -06:00
Doug Coleman bd13e018dd memq? -> member-eq?, sorted-memq? -> sorted-member-eq? 2009-10-28 15:02:00 -05:00
Keith Lazuka 405e5d015b docs: change $subsection to $subsections 2009-10-02 12:15:48 -04:00
Slava Pestov 2bb6293217 compiler: add fixnum-min/max intrinsics; ~10% speedup on benchmark.yuv-to-rgb 2009-08-28 19:02:59 -05:00
Slava Pestov f82627e736 math.intervals: comment out questionable unit tests 2009-08-22 19:39:32 -05:00
Slava Pestov 81b72cb5c5 Add some unit tests 2009-08-22 17:15:10 -05:00
Slava Pestov 770429a629 math.intervals: help lint fix 2009-08-19 16:08:52 -05:00
Slava Pestov 2bc38bf019 math.intervals: tighter interval arithmetic for intervals with infinities 2009-08-19 02:32:18 -05:00
Doug Coleman 7c92ab1ea5 move if-zero etc to math, remove 1-/1+ from math 2009-08-14 14:27:23 -05:00
Slava Pestov 4ecf5a904a More accurate wrap-interval in compiler.tree.propagation.info fixes test regression; constructing an interval with endpoints at infinity now outputs full-interval 2009-08-12 03:25:53 -05:00
Slava Pestov 7bfbb0c5ac math.intervals: fix interval-rem 2009-08-11 16:49:28 -05:00
Slava Pestov 7e35723db0 compiler.tree.propagation: be more careful with intervals, ensuring that the inferred interval of a value is a subset of the value class's interval. This improves accuracy, for example [ >fixnum 1 + >fixnum most-positive-fixnum <= ] constant-folds to true 2009-08-10 01:16:49 -05:00
Slava Pestov 1cb0f3370b math.vectors.specialization: first attempt at some call site splitting for vector ops. Specialized array types generate customized variants of all vector words, if input types are known at compile time, a call to the specialized version is inserted 2009-08-09 03:07:33 -05:00
Slava Pestov e400d80d8b More accurate interval inference for mod, rem, and propagation can now infer intervals in the case where a value might be f. so, [ [ 127 bitand ] [ drop f ] if dup [ 0 >= ] [ not ] if ] now constant-folds down to 't'! 2009-08-08 23:03:45 -05:00
Slava Pestov 61ea749bb6 More accurate interval-mod and interval-rem 2009-08-08 22:01:12 -05:00
Slava Pestov d7b40d72a0 Code cleanups 2009-05-07 12:33:31 -05:00
Doug Coleman d168f76ab0 remove 1-, 1+, use iota somewhere 2009-05-05 23:32:23 -05:00
Slava Pestov 3353a777f7 Fixing some unit test failures 2009-04-22 07:05:00 -05:00
Doug Coleman 364ea217ef fix more compiler errors 2009-04-17 14:44:08 -05:00
sheeple a4e62dfdba Fix for math.parser syntax change 2009-04-13 14:47:39 -05:00
Slava Pestov a5116d0b5d Remove two swapd usages 2009-02-02 14:26:54 -06:00
Doug Coleman 3c408342ef renaming: contain? -> any?, deep-contains? -> deep-any?, pad-left -> pad-head, pad-right -> pad-tail, trim-left -> trim-head, trim-right -> trim-tail 2009-01-29 22:19:07 -06:00
Slava Pestov 34792a9f23 Remove >r/r> 2008-12-17 19:17:37 -06:00
Slava Pestov 63fda570bf Fixing assorted compile errors and help lint warnings 2008-12-16 01:12:36 -06:00
Slava Pestov daf2857d7b define-inline now takes an effect parameter
C: now sets the stack effect of the new word to slot names
add new basis/constants vocab; CONSTANT: foo bar is equivalent to : foo bar ; inline
(going to fold CONSTANT:, ALIAS: and qualified into core soon perhaps)
tighten the screws: inline words now need a stack declaration too
update some usages of inline words
2008-12-15 19:44:56 -06:00
Slava Pestov e4f8448eb1 Fix some problems with arithmetic type inference, exposed by recent changes to log2 word
- declared input type for bignum-shift was stricter than the runtime behavior, leading to bad propagation of type info if shift count was a bignum
- types inferred for type functions which used number-valued/integer-valued/real-valued were not always precise, eg bignum bignum bitxor => integer
- add interval-log2, type function for (log2)
- remove math-class-min, it was useless
2008-12-07 19:44:49 -06:00
Aaron Schaefer 5d8b3c3fb1 Cleanup math.intervals and eliminate >r r> usage 2008-11-17 17:20:56 -05:00
Slava Pestov 93e9e34175 Add $maybe markup element 2008-11-16 06:02:13 -06:00