Function mat

Build a matrix whose component type and size is inferred from arguments. Arguments must be rows or matrices with consistent column count.

auto mat(Rows...) (
  in Rows rows
);

Example

import gfx.math.vec : dvec;
import std.algorithm : equal;
import std.traits : Unqual;

immutable r1 = dvec(1, 2, 3);
immutable r2 = dvec(4, 5, 6);
immutable m1 = mat(r1, r2);
static assert( is(Unqual!(typeof(m1)) == DMat2x3) );
assert(equal(m1.data, [ 1, 2, 3, 4, 5, 6 ]));

immutable m2 = mat(r2, m1, r1);
static assert( is(Unqual!(typeof(m2)) == DMat4x3) );
assert(equal(m2.data, [ 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]));

// The following would yield an inconsistent column count.
static assert( !__traits(compiles, mat(r1, dvec(1, 2))) );