congeal

DynamicMatrixをある大きさへ固定します。

  1. auto congeal(A mat)
  2. auto congeal(auto ref A mat, size_t r, size_t c)
  3. auto congeal(auto ref A mat)
    congeal
    (
    Msize_t rs
    Msize_t cs
    A
    )
    (
    auto ref A mat
    )
    if ()
    in { assert (mat.rows == rs); assert (mat.cols == cs); }

Examples

ditto

1 scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
2 scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}
3 
4 
5 static struct D{
6     size_t rows;
7     size_t cols;
8 
9     size_t opIndex(size_t i, size_t j) inout {return i + j;}
10 
11     mixin(defaultExprOps!(false));
12 }
13 static assert(isNarrowMatrix!D);
14 static assert(hasDynamicRows!D);
15 static assert(hasDynamicColumns!D);
16 
17 D d3x3 = D(3, 3);
18 auto s3x3 = d3x3.congeal!(3, 3)();
19 static assert(isNarrowMatrix!(typeof(s3x3)));
20 static assert(s3x3.rows == 3);
21 static assert(s3x3.cols == 3);
22 assert(s3x3[0, 0] == 0); assert(s3x3[1, 0] == 1); assert(s3x3[2, 0] == 2);
23 assert(s3x3[0, 1] == 1); assert(s3x3[1, 1] == 2); assert(s3x3[2, 1] == 3);
24 assert(s3x3[0, 2] == 2); assert(s3x3[1, 2] == 3); assert(s3x3[2, 2] == 4);

Meta