transpose

////////////// Transpose /// //////////////

nothrow @nogc pure nothrow @nogc @safe
transpose
(
M
)
(
M mat
)
if (
isMatrix!M &&
M.cols == M.rows
)

Examples

Unittest transpose

mat2 m2 = mat2( 1.0f );
assert( m2.transpose.data == mat2( 1.0f ).data );

assert( m2.transpose.data  ==  [[ 1.0f, 0.0f ],
                                [ 0.0f, 1.0f ]] );
assert( m2.data == mat2.identity.data );

mat3 m3 = mat3( 1.1f, 1.2f, 1.3f,
                2.1f, 2.2f, 2.3f,
                3.1f, 3.2f, 3.3f );
m3 = m3.transpose;
assert( m3.data == [[ 1.1f, 2.1f, 3.1f ],
                    [ 1.2f, 2.2f, 3.2f ],
                    [ 1.3f, 2.3f, 3.3f ]] );

mat4 m4 = mat4( 2.0f );
assert( m4.transpose.data == mat4( 2.0f ).data );

Meta