Alternate signs in a range
matovitch
camille.brugel at laposte.net
Sun Jan 26 05:33:57 PST 2014
Now DMD compiler segfaulted. Here is my code if you are
interested...
The berstein.d file :
import std.array;
import std.range;
import std.traits;
import std.algorithm;
bool isBernstein(alias K)() {
static if (isArray!(typeof(K)) &&
(K.empty || isNumeric!(typeof(K[0]))))
return true;
return false;
}
struct Bernstein(alias K, int S)
if (isBernstein!(K))
{
immutable typeof(K) kernel = K;
immutable int shift = S;
}
template reverse(alias B)
{
alias reverse = Bernstein!(array(retro(B.kernel)),
- (B.shift +
cast(int)B.kernel.length - 1));
}
template alternate(alias B)
{
alias alternate = Bernstein!(
array(map!(a => a[0] * a[1])(zip(B.kernel, cycle([-1,
1])))),
B.shift);
}
and the berstein_test.d file :
import berstein;
import std.stdio;
import std.range;
import std.algorithm;
void main() {
alternate!(Bernstein!([1.,1.], 0)) haar_scale;
writeln(haar_scale.kernel);
writeln(haar_scale.shift);
}
I get the following error message :
/usr/include/dmd/phobos/std/range.d(4220): Error: Internal
Compiler Error: CTFE literal Tuple(void, void)._expand_field_0
dmd: ctfeexpr.c:359: Expression* copyLiteral(Expression*):
Assertion `0' failed.
Aborted (core dumped)
More information about the Digitalmars-d-learn
mailing list