congeal

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

  1. auto congeal(A mat)
  2. auto congeal(A mat, size_t r, size_t c)
  3. auto congeal(A mat)
    congeal
    (
    A
    )
    (
    auto ref A mat
    )
    if ()

Examples

ditto

scope(failure) {writefln("Unittest failure :%s(%s)", __FILE__, __LINE__); stdout.flush();}
scope(success) {writefln("Unittest success :%s(%s)", __FILE__, __LINE__); stdout.flush();}


static struct D{
    size_t rows;
    size_t cols;

    size_t opIndex(size_t i, size_t j) inout {return i + j;}

    mixin(defaultExprOps!(false));
}
static assert(isNarrowMatrix!D);
static assert(hasDynamicRows!D);
static assert(hasDynamicColumns!D);

D d3x3 = D(3, 3);
auto s3x3 = d3x3.congeal!(3, 3)();
static assert(isNarrowMatrix!(typeof(s3x3)));
static assert(s3x3.rows == 3);
static assert(s3x3.cols == 3);
assert(s3x3[0, 0] == 0); assert(s3x3[1, 0] == 1); assert(s3x3[2, 0] == 2);
assert(s3x3[0, 1] == 1); assert(s3x3[1, 1] == 2); assert(s3x3[2, 1] == 3);
assert(s3x3[0, 2] == 2); assert(s3x3[1, 2] == 3); assert(s3x3[2, 2] == 4);

Meta