Commit graph

7672 commits

Author SHA1 Message Date
Daniel Kochmański
41afa2da35 complex-float: add some tests
Most of things is covered in ANSI-TESTS anway, these are just smoke
tests for some functionality and taking into account internal
implementation details.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
044858cf23 complex-float: rework numlib functions (atanh and such)
numlib is similar to math operation definitions in core but these
functions are implemented in C.

- refactor functions for code clarity
- add definitions for complex float
2019-05-15 16:35:16 +02:00
Daniel Kochmański
8cc0ae7222 complex float: add compiler optimizations and ffi definitions
- add ffi implementation for long-float
- add ffi implementation for (complex float) types
- add compiler optimizations and definitions for complex float

We do not add c?float common constants (long-float i.e has optimizer
for 0.0 and -0.0), because we don't know if they are common at all and
if we think about it each would have four entries counting signed
zeros).

Also add informative comment about global-entries.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
51594b8037 complex-float: print like any other complex number
During printing we cons new floats for imag and real part. We could
opencode that but that would add a lot of code for a little gain. If
this proves to be a real bottleneck we will refactor float printing.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
2bcba673f3 complex-float: implement hashing methods
- _Complex long double is first cast to _Complex double (just like
  long double) to avoid hashing non-meaningful bits

- We adhere to the "similarity" principle, that is sxhash -0.0 is the
  same as sxhash 0.0.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
86f10de4a0 complex float: implement eql, equal and equalp
equalp is delegated to ecl_number_equalp. we do not treat signed zero,
infinity nor nan.

float_eql is not the same as ==, because we have signed zeros and nan
values which should be compared memory-wise.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
d73b604fc8 complex float: implement expt 2019-05-15 16:35:16 +02:00
Daniel Kochmański
7323d05504 complex float: implement equalp 2019-05-15 16:35:16 +02:00
Daniel Kochmański
ba154a606a complex-float: implement divide and times operations 2019-05-15 16:35:16 +02:00
Daniel Kochmański
14156559e3 complex-float: implement minus operation 2019-05-15 16:35:16 +02:00
Daniel Kochmański
9e06e30660 complex float: implement plus operator
complex float: plus: fix contagion issue

also we expand into the same code path for c?float types disregarding
the argument order.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
800ba8e319 complex float: implement unary math operators
- still missing: trig/hyper arcus variants
- unary < <= = >= = min max
2019-05-15 16:35:16 +02:00
Daniel Kochmański
e1adfd2794 numeric tower: merge <complex float> with <complex>
cl_type_of: give better results for (type-of <complex>)

Instead of simply returning complex we return:

  (complex real)

when code is built without complex float support, and otherwise

  (complex rational)
  (complex single-float)
  (complex double-float)
  (complex long-float)

New functions:
- ecl_to_csfloat
- ecl_to_cdfloat
- ecl_to_clfloat
2019-05-15 16:35:16 +02:00
Daniel Kochmański
fdc40520a2 complex float: extend math_dispatch macros and add appropriate stubs 2019-05-15 16:35:11 +02:00
Daniel Kochmański
a0a92dc2af complex float: add a new types and builtin classes
What has changed:

- new types si:complex-float, si:complex-single-float,
  si:complex-double-float and si:complex-long-float
- new builtin classes long-float (for completness) and
  si:complex-float
- new internal function si:complex-float and si:complex-float-p for
  constructing complex floats (both arguments must be of the same
  float type) and a type predicate
- printer for new types (right now it conses, see below)
- a new feature :complex-float
- a new type is recognized as a type disjoint of complex and real

- cleanup: +built-in-type-list+: remove some redundancy
  For instance instread of saying
    (real (or integer single-float double-float ratio))
  We say
    (real (or integer float ratio))
  etc.

Flaws which will be fixed in upcoming commits:

- complex-float hierarchy is independent of the complex hierarchy
- ecl_make_complex_float could be replaced by _ecl_make_complex_*float
- write_complex_float allocates new objects for printing
- write_complex_float does print unreadable object
- math dispatchers doesn't recognize the object

Testing things out:

> (si:complex-float 0.0d0 0.0d0)
; #<CF(0.0d0 0.0d0)>
> (si:complex-float 0.0d0 0.0s0)       ; signals type error
> (+ (si:complex-float 0.0d0 0.0d0) 1) ; signals type error

lisp runtime: make si_complex-float a subtype of a number.
2019-05-13 19:48:54 +02:00
Daniel Kochmański
20a7030277 complex float: add gc boilerplate 2019-05-06 08:17:33 +02:00
Daniel Kochmański
f78cb49def complex float: rename cl_lispunion member complex to gencomplex
Complex is a macro specified in complex.h for c99 to simplify using
_Complex type. This file also contains functions to work on complex
floats. To avoid conflicts we rename internal name complex to
gencomplex and update all references to it.
2019-05-06 08:17:33 +02:00
Daniel Kochmański
6ecd2473c4 complex float: add types and structures to core runtime
t_csfloat - ecl_csfloat,
t_cdfloat - ecl_cdfloat,
t_clfloat - ecl_clfloat.
2019-05-06 08:17:33 +02:00
Daniel Kochmański
e7725d4bcf abs: (abs -0.0) -> 0.0
example in clhs is not normative and this code is wrong. We use
fabs(f/l) to have a correct result.
2019-05-05 22:54:51 +02:00
Marius Gerbershagen
aa5ed8bc7b printer: ensure that we generate enough digits for floats
When the number of digits was not specified, we were sometimes
outputting a number that was exactly halfway between the exact value
and the next higher float. When reading that number in again, one
would get a different value due to rounding issues. Therefore, we now
always output enough digits, so that the number can be reconstructed
unambigously. Fixes #500.
2019-05-05 16:58:17 +02:00
Marius Gerbershagen
8a82b9fcfb numbers: fix coercion of ratios/bignums to floats
The function extracting the mantissa and exponent from a ratio has
been simplified and improved.
2019-05-05 16:58:17 +02:00
Marius Gerbershagen
a7c6820506 Merge branch 'clean-math-3' into 'develop'
Clean math 3 (without float conversion changes)

Closes #486 und #497

See merge request embeddable-common-lisp/ecl!147
2019-05-05 13:40:17 +00:00
Daniel Kochmański
0fcf21b4a7 tests: compiler: add regression test for constant folding. 2019-05-05 10:38:02 +02:00
Daniel Kochmański
0033f24be2 constant folding: fix regression for single and multiple values
Closes #497.
2019-05-05 10:38:02 +02:00
Daniel Kochmański
5dd4174225 msvc: gmp: add mpq sources 2019-05-05 10:38:02 +02:00
Daniel Kochmański
1533824059 buildsystem: improve checks for floats
We do not check for c99-mandated functions for long float (we only
check for the type). We also check for complex numbers in a separate
function and define ECL_COMPLEX_FLOAT when found.
2019-05-05 10:38:02 +02:00
Daniel Kochmański
7c6de43e4c numbers: use fast dispatch in ecl_integer_divide (round) 2019-05-05 10:38:02 +02:00
Daniel Kochmański
0bf83ed03d numbers: test for appropriate argument type in unary ops
This touches minmax, equalp and comparison of numbers. We also replace
old nested switch in ecl_number_compare with fast dispatch. Fixes #486.
2019-04-20 22:31:21 +02:00
Daniel Kochmański
22865f0c55 tests: improve signals macro to allow description 2019-04-20 22:31:21 +02:00
Daniel Kochmański
0c8fe7e2c8 cleanup: line breaks, dead code removal 2019-04-20 22:31:21 +02:00
Daniel Kochmański
3766821b25 cosmetic: indent, line breaks 2019-04-20 22:31:21 +02:00
Marius Gerbershagen
299f9fb1c6 Merge branch 'fix-complex-typep' into 'develop'
Fix complex typep

Closes #493

See merge request embeddable-common-lisp/ecl!144
2019-04-20 15:51:31 +00:00
Daniel Kochmański
155ccac218 tests: add regression test for typep and subtypep and complex.
Fixes #493.
2019-04-20 17:14:19 +02:00
Daniel Kochmański
097fa96ae0 cmp: coerce: resolve fixme for atomic complex specifier
it is not true, that

  (type= '(complex) '(complex double-float)) == T

so we may put complex in +coercion-table+.
2019-04-20 17:14:14 +02:00
Daniel Kochmański
d7c351c76a predlib: type= doesn't yield T for complex types
TYPE= is only used from cmpopt's typep compiler macro which optimizes
atomic complex types by other means. Compound complex types are
handled differently for subtypep and typep (the first relies on
upgraded type and the second relies on the actual types), so we can't
rely in this case on SAFE-CANONICAL-TYPE.
2019-04-20 17:13:17 +02:00
Marius Gerbershagen
06b8e49d89 cis: check argument type to be real 2019-04-19 17:33:10 +02:00
Daniel Kochmański
2ec7688554 Revert "si::type=: do not assume all complex number types to be equivalent"
This reverts commit 177ad215ea.

See #493. the issue with typecase must be resolved outside the
subtypep because these numbers indeed have the same internal
representation (see clhs entry for subtypep and typep).
2019-04-19 17:28:19 +02:00
Daniel Kochmański
ab35ce71a2 Merge branch 'develop' into 'develop'
Fix for #482

Closes #482

See merge request embeddable-common-lisp/ecl!143
2019-04-18 10:32:10 +00:00
Marius Gerbershagen
93496e108c configure: change manual installation
Introduce a configure option controlling the installation and build
the documentation during the build instead of the install phase. Targets
for installation of the html version have also been added.
Fixes #482.
2019-04-11 18:17:02 +02:00
Marius Gerbershagen
1ad91df1cf configure: fix check for system libatomic_ops
Previously we would not fail if trying to link to an incompatible
libatomic_ops.a
Fixes #481.
2019-03-25 19:46:02 +01:00
Marius Gerbershagen
209434f91a cmp: fix constant folding for functions that return multiple values 2019-03-23 18:51:18 +01:00
Marius Gerbershagen
0407b9697c defstruct: fix print-object and print-function options for lambdas
Bug introduced in commit ba573abf9e.
2019-03-23 17:36:37 +01:00
Marius Gerbershagen
8bc2f8a983 loop: fix type declarations for nil-initialized variables
In expansions such as
(loop for i of-type some-type in some-list ...)
we were declaring the type of i to be some-type instead of the
correct (or null some-type).
2019-03-23 16:35:29 +01:00
Marius Gerbershagen
f7cd2b8775 defstruct: be less strict about struct redefinitions
Only disallow struct redefinition if we are certain about subtype
relationships in slots. Otherwise, we can wrongly disallow struct
redefinitions which don't change slot types.
2019-03-20 22:40:21 +01:00
Marius Gerbershagen
177ad215ea si::type=: do not assume all complex number types to be equivalent
This leads to compiled code checking types such as (complex
single-float) with a simple call to complexp. While this may
technically be allowed by the ANSI standard, since
upgraded-complex-part-type always returns 'real, it is very confusing
since for example typep correctly discriminates between different
complex part types.
See #468.
2019-03-20 22:03:06 +01:00
Marius Gerbershagen
944805cbf5 contrib: defsystem: (hopefully) finally remove all old package names
Fixes #480.
2019-03-20 21:20:28 +01:00
Daniel Kochmański
106c31937b Merge branch 'develop' into 'develop'
add msvc/package-locks.asd to .gitignore

See merge request embeddable-common-lisp/ecl!142
2019-03-19 13:03:54 +00:00
Yuguo Zhang
608dbdecf2 add msvc/package-locks.asd to .gitignore 2019-03-19 12:52:48 +08:00
Daniel Kochmański
20fdd44b79 contrib: defsystem: fix packages 2019-03-15 20:38:39 +01:00
Daniel Kochmański
d22bfd0ce1 Merge branch 'unix-signal' into 'develop'
Document unix signal handling capabilities

See merge request embeddable-common-lisp/ecl!137
2019-03-15 19:26:56 +00:00