Boost logo

Boost :

Subject: [boost] [gsoc18] [Boost.Real] Competency Test
From: Parth Mittal (parth15069_at_[hidden])
Date: 2018-03-01 21:40:05


Hi

My name is Parth Mittal, and I'm a third year computer science undergraduate.

Here is my attempt at the competency test:
(wrt the first, second, and third bullet on the project page)

1. I uploaded my code here
(https://github.com/parthmittal/boost_competency_test);
I'm not sure how much of it is required to be functional but (of
course) I can write more code if required. The current code uses an
std::pair of the chosen rational type to represent intervals, it is
probably more sensible to replace this with a dedicated type for
intervals.
Also I have two different ideas for dealing with integers in the
binary operators:
(i) Wrap them into a "real" number (with an approximation function
that always returns the exact value and an error term of 0).
(ii) Add a facility for additive and multiplicative rational factors
to the class.

2. For sure there is no way to be sure two numbers are equal in finite
time, so while checking if a and b are equal, we should pass an
integer parameter, say K, and then for every pair of integers i, j
between 1 and K, we should check if a(i) = b(j) (of course a(i) = b(j)
iff the intervals share a point).
This feels somewhat inefficient (it would be nice to eliminate the
quadratic runtime with K), but since we don't have a guarantee that
a(i + 1) is a subset of a(i), I don't see any obvious way to improve
this.

3. To be honest, I had to google for "Small String Optimization" - and
the analogue I can see is to store as an array the values of a(k) for
all k <= K for some small constant K. I'm not sure how to implement
this at compile time; it makes sense that the approximation
function(s) for the real number involved be constexpr, but I've never
written any code which is constexpr.

Perhaps my code in (1) already makes this clear, but I'm not very
experienced at writing C++;
I've written probably 100k+ lines while doing programming contests,
but this was rather simple code which was written once and read never.
I can fill in the gaps in my knowledge of the language on an ad-hoc
basis (or using the time until the SoC officially begins).

Thank you for reading
Parth Mittal


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk