Boost logo

Boost :

Subject: Re: [boost] [gsoc18] [Boost.Real] Competency Test
From: Damian Vicino (damian_at_[hidden])
Date: 2018-03-02 03:41:32


Hi,
The code does not have to be functional at all. I like to focus in the
interface in this particular project because it is the more complex part
of the project.

In general, I like the way you approached it.
It would be nice if you could explain the details a little. For example why
using rational intervals and not integers for example? What are the
restriction for those rationals. What is the function you define about.
Why do you use std::function<std::pair<rational_t, rational_t>(int)> op1,
op2; and not a lambda or a class/functor?

About the interaction with other datatypes, you could consider a lazy
evaluation approach using Tuples. Let say:
Real r1 = ...;
Real r2 = ...;
int i = 3;

Real result = r1+r2+i;

Then
result has a property which the tuple {r1.alg, r2.alg, 3}
You only need to get the digits for them to do comparizons or printing
them, not for operating. So, addition is O(tuple::concat)

2018-03-01 16:40 GMT-05:00 Parth Mittal via Boost <boost_at_[hidden]>:

> 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
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/
> mailman/listinfo.cgi/boost
>


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