Commit graph

45 commits

Author SHA1 Message Date
Morten Piibeleht
6ddbd340b0 Make convert(Real, ::HalfInteger) yield HalfInteger (#5)
As HalfInteger <: Real, there should be no reason to convert anything in
this situation. It happens because the convert method resorts to Float64
as an intermediate value.

To still get conversion to floats, we can just dispatch on AbstractFloat
instead. However, it should be better to convert the numerator to T
first and then divide, so that we would not use a potentially lower
precision intermediate value.

This solves the problem where calling sum on an vector of HalfIntegers
yields a floating point value, even though there is no reason to convert
in the summation:

julia> sum([HalfInteger(1//2), HalfInteger(3//2)])
2.0

This is because there is an implicit convert(::Real) in the Base.add_sum
function. With this patch the sum call correctly yields a HalfInteger.

It also updates the tests related to HalfInteger convert methods:

 - Make sure that the convert tests also check types
 - Add a few tests for converting out of HalfInteger
2019-02-21 00:16:26 +01:00
Jutho Haegeman
65e3f34649 export HalfInteger 2019-01-10 23:05:52 +01:00
Jutho Haegeman
088c52e1fb update ci 2019-01-10 21:59:51 +01:00
Morten Piibeleht
8ebb2c791b Partially revamp the HalfInteger type (#4)
* Call the HalfInteger field twofold

Makes it more immediately obvious what the meaning of the value stored
in the field is.

* Introduce new constructors for HalfInteger

The primary inner constructor mirrors the two-argument constructor of
the Rational type, where the user provides the numerator and denominator
values.

There is also a single argument outer constructor that makes HalfInteger
behave like a normal numeric type such that HalfInteger(n) == n.

* Move HalfInteger tests to a separate file

The using statements in halfinteger.jl are there so that it would be
possible to run the file separately from the other tests.

* Test the single-argument HalfInteger constructor

* Organize halfinteger.jl a bit

Prioritise the convert methods.

* Add multiplication with integer to HalfInteger

* Implement parsing and printing for HalfInteger

* parse(::HalfInteger, x) method
* Overload show to pretty-print HalfInteger

* Overload Base.numerator/denominator

And add tests for the other supplementary functions and methods as
well.

* Add HalfIntegerRange type

Can be constructed using the range operator :. Currently only supports
unit steps in the positive direction.

* Address feedback

* Rename .twofold -> .numerator
* Consistent variable names
* Remove unnecessary methods for HalfIntegerRange

* Allow constructing HalfIntegerRange with non-integer difference

* Add docs and ceil(::HalfInteger)
2019-01-10 21:50:46 +01:00
Jutho Haegeman
80038db6a3 update require and travis.yml 2018-10-24 09:51:00 +02:00
Jutho Haegeman
6f90f842d7 remove dead julia pkg eval from readme 2018-10-05 23:33:59 +02:00
Jutho Haegeman
d871d4db3d update travis.yml 2018-10-05 23:33:23 +02:00
Jutho
42efa10861 update installation instructions 2018-10-05 17:21:30 +02:00
Jutho
39bbd0ced8 update HalfInteger 2018-10-05 17:20:22 +02:00
Jutho Haegeman
8854cfbb97 update README 2018-07-25 00:32:51 +02:00
Jutho
396bc52d2e
update tests for julia 0.7 2018-07-12 11:39:31 +02:00
Jutho Haegeman
38524431e1 more update travis 2018-07-10 02:16:13 +02:00
Jutho Haegeman
7f91c5acc0 update travis and require 2018-07-10 02:09:36 +02:00
Jutho Haegeman
3400fe8577 update tests 2018-07-10 02:07:31 +02:00
Jutho
cf7c940c5f
first attempt to (exclusive) v0.7 compatibility
first attempt to (exclusive) v0.7 compatibility
2018-06-22 00:21:31 +02:00
Jutho Haegeman
dd208b42a6 first attempt to (exclusive) v0.7 compatibility 2018-06-21 23:29:33 +02:00
Jutho Haegeman
0b8be07d6a remove erroneous empty line 2018-06-17 02:08:51 +02:00
Jutho Haegeman
cdb460332c speed improvement plus v0.7 compatibility 2018-01-31 17:10:37 +08:00
Jutho Haegeman
21688c9a2b improve speed of conversion from halfinteger to integer 2018-01-30 16:47:07 +08:00
Jutho Haegeman
ba3303cb68 Move halfinteger into WignerSymbols 2018-01-30 16:11:33 +08:00
Jutho
61eaa24215 deprecation fix 2018-01-24 16:45:33 +01:00
Jutho Haegeman
b734fe001f Update for latest version of v0.7 2017-12-08 00:52:21 +01:00
Jutho Haegeman
9350aae469 Fix argument order in clebschgordan docs. 2017-11-10 11:20:03 +01:00
Jutho Haegeman
dd75309fe6 Enable precompilation 2017-10-27 16:28:53 +02:00
Jutho Haegeman
a05b93dc48 Fix readme (2) 2017-10-19 00:46:54 +02:00
Jutho Haegeman
bc47b88f38 Fix README 2017-10-19 00:46:04 +02:00
Jutho Haegeman
32b8e13165 Reenable 0.6 in travis.yml 2017-10-14 01:40:07 +02:00
Jutho Haegeman
258246f854 add MPZ for 0.6 compatibility; update REQUIRE, add testsets 2017-10-14 01:33:52 +02:00
Jutho Haegeman
cb09b427c9 bugfix in Racah W sign when different irreps don't match 2017-10-09 15:28:29 +02:00
Jutho Haegeman
e56bea0cf9 fix bug in delta 2017-10-06 23:27:58 +02:00
Jutho
f647d8948b fix depwarn for .+ in range 2017-09-26 10:39:58 +02:00
Jutho
b3f65e9b46 Remove @show in tests 2017-08-12 00:22:07 +02:00
Jutho
07efc88cf7 Change test tolerance due to julia#22742
See https://github.com/JuliaLang/julia/pull/22742
2017-08-12 00:18:04 +02:00
Jutho
9524e3f1e8 fix broken link attempt3 2017-08-11 15:35:28 +02:00
Jutho
4cc893e693 fix broken link in README attempt2 2017-08-11 15:34:24 +02:00
Jutho
42df8be35a fix broken link in README 2017-08-11 15:33:57 +02:00
Jutho
9f78c5ded7 Fix Benchmark entry in Readme 2017-08-11 15:33:29 +02:00
Jutho
c47faaf768 README and benchmarks 2017-08-11 15:32:10 +02:00
Jutho
1a974193eb add help and more tests 2017-08-11 12:55:57 +02:00
Jutho
56b02ebcf2 3j and 6j working and tested 2017-08-09 17:12:37 +02:00
Jutho Haegeman
b9eb46d5cd updates 2017-08-09 12:13:46 +02:00
Jutho
46d5624e0f first code 2 2017-08-08 16:57:31 +02:00
Jutho
c0f00d5d61 first code 2017-08-08 16:57:20 +02:00
Jutho
a5395dca5b WignerSymbols.jl generated files.
license:  MIT
    authors:  Jutho
    years:    2017
    user:     jutho

Julia Version 0.7.0-DEV.1283 [4fea203375]
2017-08-08 11:23:18 +02:00
Jutho
3c93b33c80 initial empty commit 2017-08-08 11:23:17 +02:00