Thread overview
Completly static Laurent's polynomials
Jan 27, 2014
matovitch
Jan 27, 2014
Meta
Jan 27, 2014
matovitch
Jan 27, 2014
matovitch
January 27, 2014
Hello !

Yesterday, I started a project to implement completly static Laurent's polynomials (i.e. polynomials formed by z^n and z^-n monomials).
I thought I could represent these polynomials with an immutable range of Tuple!(numeric_type, int).

I've tried (and failed) to implement the addition here :

    https://github.com/matovitch/StaticLaurent

Is my goal achivable ? How would you do it ?

ps : I am a *total beginner* waiting for any advice(s).
January 27, 2014
On Monday, 27 January 2014 at 11:15:36 UTC, matovitch wrote:
> Hello !
>
> Yesterday, I started a project to implement completly static Laurent's polynomials (i.e. polynomials formed by z^n and z^-n monomials).
> I thought I could represent these polynomials with an immutable range of Tuple!(numeric_type, int).
>
> I've tried (and failed) to implement the addition here :
>
>     https://github.com/matovitch/StaticLaurent
>
> Is my goal achivable ? How would you do it ?
>
> ps : I am a *total beginner* waiting for any advice(s).

Immutable and ranges do not mix very well. Can you include some information on what the exact problem is?
January 27, 2014
On Monday, 27 January 2014 at 13:18:06 UTC, Meta wrote:
> On Monday, 27 January 2014 at 11:15:36 UTC, matovitch wrote:
>> Hello !
>>
>> Yesterday, I started a project to implement completly static Laurent's polynomials (i.e. polynomials formed by z^n and z^-n monomials).
>> I thought I could represent these polynomials with an immutable range of Tuple!(numeric_type, int).
>>
>> I've tried (and failed) to implement the addition here :
>>
>>    https://github.com/matovitch/StaticLaurent
>>
>> Is my goal achivable ? How would you do it ?
>>
>> ps : I am a *total beginner* waiting for any advice(s).
>
> Immutable and ranges do not mix very well. Can you include some information on what the exact problem is?

I noticed ! ^^

filter try to perform a memcpy :

/usr/include/dmd/phobos/std/conv.d(3993): Error: memcpy cannot be interpreted at compile time, because it has no available source code
/usr/include/dmd/phobos/std/range.d(4227):        called from here: emplace(addr, front(this._ranges_field_0))
/usr/include/dmd/phobos/std/algorithm.d(3171):        called from here: this._current.front()
/usr/include/dmd/phobos/std/algorithm.d(1381):        called from here: this._input.front()
/usr/include/dmd/phobos/std/algorithm.d(1381):        called from here: __lambda3(this._input.front())
/usr/include/dmd/phobos/std/algorithm.d(1369):        called from here: (FilterResult!(__lambda3, Result) __ctmp1478 = FilterResult(Result);
 , __ctmp1478).this(rs)
laurent.d(53):        called from here: filter(myCartesianProduct([Tuple(1.00000, 0), Tuple(1.00000, 1)], [Tuple(2.00000, 0), Tuple(0.5, 1)]))
laurent.d(51):        called from here: map(filter(myCartesianProduct([Tuple(1.00000, 0), Tuple(1.00000, 1)], [Tuple(2.00000, 0), Tuple(0.5, 1)])))
laurent_test.d(19): Error: template instance laurent_test.main.add!(p1, p2) error instantiating
January 27, 2014
I just clone phobos so we could agree about the line numbers :

/usr/include/dmd/phobos/std/conv.d(3889): Error: memcpy cannot be interpreted at compile time, because it has no available source code
/usr/include/dmd/phobos/std/range.d(4769):        called from here: emplace(addr, front(this._ranges_field_0))
/usr/include/dmd/phobos/std/algorithm.d(3495):        called from here: this._current.front()
/usr/include/dmd/phobos/std/algorithm.d(1435):        called from here: this._input.front()
/usr/include/dmd/phobos/std/algorithm.d(1435):        called from here: __lambda3(this._input.front())
/usr/include/dmd/phobos/std/algorithm.d(1396):        called from here: (FilterResult!(__lambda3, Result) __ctmp1601 = FilterResult(Result);
 , __ctmp1601).this(rs)
laurent.d(53):        called from here: filter(myCartesianProduct([Tuple(1.00000, 0), Tuple(1.00000, 1)], [Tuple(2.00000, 0), Tuple(0.5, 1)]))
laurent.d(51):        called from here: map(filter(myCartesianProduct([Tuple(1.00000, 0), Tuple(1.00000, 1)], [Tuple(2.00000, 0), Tuple(0.5, 1)])))
laurent_test.d(19): Error: template instance laurent_test.main.add!(p1, p2) error instantiating