/*
 * Mesa 3-D graphics library
 * Version:  6.5
 *
 * Copyright (C) 2006  Brian Paul   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

//
// Constructors and operators introduced in GLSL 1.20 - mostly on new
// (non-square) types of matrices.
//
// One important change in the language is that when a matrix is used
// as an argument to a matrix constructor, it must be the only argument
// for the constructor. The compiler takes care of it by itself and
// here we only care to re-introduce constructors for old (square)
// types of matrices.
//

//
// From Shader Spec, ver. 1.20, rev. 6
//

//// mat2x3: 2 columns of vec3

mat2x3 __constructor(const float f00, const float f10, const float f20,
                     const float f01, const float f11, const float f21)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[0].z = f20;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[1].z = f21;
}

mat2x3 __constructor(const float f)
{
   __retVal = mat2x3(  f, 0.0, 0.0,
                     0.0,   f, 0.0);
}

mat2x3 __constructor(const int  i)
{
   const float f = float(i);
   __retVal = mat2x3(f);
}

mat2x3 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat2x3(f);
}

mat2x3 __constructor(const vec3 c0, const vec3 c1)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
}



//// mat2x4: 2 columns of vec4

mat2x4 __constructor(const float f00, const float f10, const float f20, const float f30,
                     const float f01, const float f11, const float f21, const float f31)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[0].z = f20;
   __retVal[0].w = f30;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[1].z = f21;
   __retVal[1].w = f31;
}

mat2x4 __constructor(const float f)
{
   __retVal = mat2x4(  f, 0.0, 0.0, 0.0,
                     0.0,   f, 0.0, 0.0);
}

mat2x4 __constructor(const int i)
{
   const float f = float(i);
   __retVal = mat2x4(f);
}

mat2x4 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat2x4(f);
}

mat2x4 __constructor(const vec4 c0, const vec4 c1)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
}



//// mat3x2: 3 columns of vec2

mat3x2 __constructor(const float f00, const float f10,
                     const float f01, const float f11,
                     const float f02, const float f12)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[2].x = f02;
   __retVal[2].y = f12;
}

mat3x2 __constructor(const float f)
{
   __retVal = mat3x2(  f, 0.0,
                     0.0,   f,
                     0.0, 0.0);
}

mat3x2 __constructor(const int i)
{
   const float f = float(i);
   __retVal = mat3x2(f);
}

mat3x2 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat3x2(f);
}

mat3x2 __constructor(const vec2 c0, const vec2 c1, const vec2 c2)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
   __retVal[2] = c2;
}



//// mat3x4: 3 columns of vec4

mat3x4 __constructor(const float f00, const float f10, const float f20, const float f30,
                     const float f01, const float f11, const float f21, const float f31,
		     const float f02, const float f12, const float f22, const float f32)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[0].z = f20;
   __retVal[0].w = f30;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[1].z = f21;
   __retVal[1].w = f31;
   __retVal[2].x = f02;
   __retVal[2].y = f12;
   __retVal[2].z = f22;
   __retVal[2].w = f32;
}

mat3x4 __constructor(const float f)
{
   __retVal = mat3x4(  f, 0.0, 0.0, 0.0,
                     0.0,   f, 0.0, 0.0,
                     0.0, 0.0,   f, 0.0);
}

mat3x4 __constructor(const int i)
{
   const float f = float(i);
   __retVal = mat3x4(f);
}

mat3x4 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat3x4(f);
}

mat3x4 __constructor(const vec4 c0, const vec4 c1, const vec4 c2)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
   __retVal[2] = c2;
}



//// mat4x2: 4 columns of vec2

mat4x2 __constructor(const float f00, const float f10,
                     const float f01, const float f11,
		     const float f02, const float f12,
		     const float f03, const float f13)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[2].x = f02;
   __retVal[2].y = f12;
   __retVal[3].x = f03;
   __retVal[3].y = f13;
}

mat4x2 __constructor(const float f)
{
   __retVal = mat4x2(  f, 0.0,
                     0.0,   4,
                     0.0, 0.0,
                     0.0, 0.0);
}

mat4x2 __constructor(const int i)
{
   const float f = float(i);
   __retVal = mat4x2(f);
}

mat4x2 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat4x2(f);
}

mat4x2 __constructor(const vec2 c0, const vec2 c1, const vec2 c2, const vec2 c3)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
   __retVal[2] = c2;
   __retVal[3] = c3;
}



//// mat4x3: 4 columns of vec3

mat4x3 __constructor(const float f00, const float f10, const float f20,
                     const float f01, const float f11, const float f21,
		     const float f02, const float f12, const float f22,
		     const float f03, const float f13, const float f23)
{
   __retVal[0].x = f00;
   __retVal[0].y = f10;
   __retVal[0].z = f20;
   __retVal[1].x = f01;
   __retVal[1].y = f11;
   __retVal[1].z = f21;
   __retVal[2].x = f02;
   __retVal[2].y = f12;
   __retVal[2].z = f22;
   __retVal[3].x = f03;
   __retVal[3].y = f13;
   __retVal[3].z = f23;
}

mat4x3 __constructor(const float f)
{
   __retVal = mat4x3(  f, 0.0, 0.0,
                     0.0,   f, 0.0,
                     0.0, 0.0,   f,
                     0.0, 0.0, 0.0);
}

mat4x3 __constructor(const int i)
{
   const float f = float(i);
   __retVal = mat4x3(f);
}

mat4x3 __constructor(const bool b)
{
   const float f = float(b);
   __retVal = mat4x3(f);
}

mat4x3 __constructor(const vec3 c0, const vec3 c1, const vec3 c2, const vec3 c3)
{
   __retVal[0] = c0;
   __retVal[1] = c1;
   __retVal[2] = c2;
   __retVal[3] = c3;
}



//// misc assorted matrix constructors

mat2 __constructor(const mat2 m)
{
   __retVal = m;
}

mat2 __constructor(const mat3x2 m)
{
   __retVal = mat2(m[0], m[1]);
}

mat2 __constructor(const mat4x2 m)
{
   __retVal = mat2(m[0], m[1]);
}

mat2 __constructor(const mat2x3 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}

mat2 __constructor(const mat2x4 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}

mat2 __constructor(const mat3 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}

mat2 __constructor(const mat3x4 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}

mat2 __constructor(const mat4x3 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}

mat2 __constructor(const mat4 m)
{
   __retVal = mat2(m[0].xy, m[1].xy);
}



mat2x3 __constructor(const mat2x3 m)
{
   __retVal = m;
}

mat2x3 __constructor(const mat3 m)
{
   __retVal = mat2x3(m[0], m[1]);
}

mat2x3 __constructor(const mat4x3 m)
{
   __retVal = mat2x3(m[0], m[1]);
}

mat2x3 __constructor(const mat2x4 m)
{
   __retVal = mat2x3(m[0].xyz, m[1].xyz);
}

mat2x3 __constructor(const mat3x4 m)
{
   __retVal = mat2x3(m[0].xyz, m[1].xyz);
}

mat2x3 __constructor(const mat4 m)
{
   __retVal = mat2x3(m[0].xyz, m[1].xyz);
}

mat2x3 __constructor(const mat2 m)
{
   __retVal = mat2x3(m[0].x, m[0].y, 0.0,
                     m[1].x, m[1].y, 0.0);
}

mat2x3 __constructor(const mat3x2 m)
{
   __retVal = mat2x3(m[0].x, m[0].y, 0.0,
                     m[1].x, m[1].y, 0.0);
}

mat2x3 __constructor(const mat4x2 m)
{
   __retVal = mat2x3(m[0].x, m[0].y, 0.0,
                     m[1].x, m[1].y, 0.0);
}



mat2x4 __constructor(const mat2x4 m)
{
   __retVal = m;
}

mat2x4 __constructor(const mat3x4 m)
{
   __retVal = mat2x4(m[0], m[1]);
}

mat2x4 __constructor(const mat4 m)
{
   __retVal = mat2x4(m[0], m[1]);
}

mat2x4 __constructor(const mat2x3 m)
{
   __retVal = mat2x4(m[0].x, m[0].y, m[0].z, 0.0,
                     m[1].x, m[1].y, m[1].z, 0.0);
}

mat2x4 __constructor(const mat3 m)
{
   __retVal = mat2x4(m[0].x, m[0].y, m[0].z, 0.0,
                     m[1].x, m[1].y, m[1].z, 0.0);
}

mat2x4 __constructor(const mat4x3 m)
{
   __retVal = mat2x4(m[0].x, m[0].y, m[0].z, 0.0,
                     m[1].x, m[1].y, m[1].z, 0.0);
}

mat2x4 __constructor(const mat2 m)
{
   __retVal = mat2x4(m[0].x, m[1].y, 0.0, 0.0,
                     m[1].x, m[1].y, 0.0, 0.0);
}

mat2x4 __constructor(const mat3x2 m)
{
   __retVal = mat2x4(m[0].x, m[0].y, 0.0, 0.0,
                     m[1].x, m[1].y, 0.0, 0.0);
}

mat2x4 __constructor(const mat4x2 m)
{
   __retVal = mat2x4(m[0].x, m[0].y, 0.0, 0.0,
                     m[1].x, m[1].y, 0.0, 0.0);
}



mat3x2 __constructor(const mat3x2 m)
{
   __retVal = m;
}

mat3x2 __constructor(const mat4x2 m)
{
   __retVal = mat3x2(m[0], m[1], m[2]);
}

mat3x2 __constructor(const mat3 m)
{
   __retVal = mat3x2(m[0], m[1], m[2]);
}

mat3x2 __constructor(const mat3x4 m)
{
   __retVal = mat3x2(m[0].x, m[0].y,
                     m[1].x, m[1].y,
                     m[2].x, m[2].y);
}

mat3x2 __constructor(const mat4x3 m)
{
   __retVal = mat3x2(m[0].x, m[0].y,
                     m[1].x, m[1].y,
                     m[2].x, m[2].y);
}

mat3x2 __constructor(const mat4 m)
{
   __retVal = mat3x2(m[0].x, m[0].y,
                     m[1].x, m[1].y,
                        0.0,    0.0);
}

mat3x2 __constructor(const mat2 m)
{
   __retVal = mat3x2(m[0], m[1], vec2(0.0));
}

mat3x2 __constructor(const mat2x3 m)
{
   __retVal = mat3x2(m[0].x, m[0].y,
                     m[1].x, m[1].y,
                        0.0,    0.0);
}

mat3x2 __constructor(const mat2x4 m)
{
   __retVal = mat3x2(m[0].x, m[0].y,
                     m[1].x, m[1].y,
                        0.0,    0.0);
}




mat3 __constructor(const mat3 m)
{
   __retVal = m;
}

mat3 __constructor(const mat4x3 m)
{
   __retVal = mat3 (
        m[0],
        m[1],
        m[2]
    );
}

mat3 __constructor(const mat3x4 m)
{
   __retVal = mat3 (
        m[0].xyz,
        m[1].xyz,
        m[2].xyz
    );
}

mat3 __constructor(const mat4 m)
{
   __retVal = mat3 (
        m[0].xyz,
        m[1].xyz,
        m[2].xyz
    );
}

mat3 __constructor(const mat2x3 m)
{
   __retVal = mat3 (
        m[0],
        m[1],
        0., 0., 1.
    );
}

mat3 __constructor(const mat2x4 m)
{
   __retVal = mat3 (
        m[0].xyz,
        m[1].xyz,
        0., 0., 1.
    );
}

mat3 __constructor(const mat3x2 m)
{
   __retVal = mat3 (
        m[0], 0.,
        m[1], 0.,
        m[2], 1.
    );
}

mat3 __constructor(const mat4x2 m)
{
   __retVal = mat3 (
        m[0], 0.,
        m[1], 0.,
        m[2], 1.
    );
}

mat3 __constructor(const mat2 m)
{
   __retVal = mat3 (
        m[0], 0.,
        m[1], 0.,
        0., 0., 1.
    );
}


mat3x4 __constructor(const mat3x4 m)
{
   __retVal = m;
}

mat3x4 __constructor(const mat4 m)
{
   __retVal = mat3x4 (
        m[0],
        m[1],
        m[2]
    );
}

mat3x4 __constructor(const mat3 m)
{
   __retVal = mat3x4 (
        m[0], 0.,
        m[1], 0.,
        m[2], 0.
    );
}

mat3x4 __constructor(const mat4x3 m)
{
   __retVal = mat3x4 (
        m[0], 0.,
        m[1], 0.,
        m[2], 0.
    );
}

mat3x4 __constructor(const mat2x4 m)
{
   __retVal = mat3x4 (
        m[0],
        m[1],
        0., 0., 1., 0.
    );
}

mat3x4 __constructor(const mat2x3 m)
{
   __retVal = mat3x4 (
        m[0], 0.,
        m[1], 0.,
        0., 0., 1., 0.
    );
}

mat3x4 __constructor(const mat3x2 m)
{
   __retVal = mat3x4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        m[2], 1., 0.
    );
}

mat3x4 __constructor(const mat4x2 m)
{
   __retVal = mat3x4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        m[2], 1., 0.
    );
}

mat3x4 __constructor(const mat2 m)
{
   __retVal = mat3x4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        0., 0., 1., 0.
    );
}


mat4x2 __constructor(const mat4x2 m)
{
   __retVal = m;
}

mat4x2 __constructor(const mat4x3 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        m[2].xy,
        m[3].xy
    );
}

mat4x2 __constructor(const mat4 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        m[2].xy,
        m[3].xy
    );
}

mat4x2 __constructor(const mat3x2 m)
{
   __retVal = mat4x2 (
        m[0],
        m[1],
        0., 0.
    );
}

mat4x2 __constructor(const mat3 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        m[2].xy,
        0., 0.
    );
}

mat4x2 __constructor(const mat3x4 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        m[2].xy,
        0., 0.
    );
}

mat4x2 __constructor(const mat2 m)
{
   __retVal = mat4x2 (
        m[0],
        m[1],
        0., 0.,
        0., 0.
    );
}

mat4x2 __constructor(const mat2x3 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        0., 0.,
        0., 0.
    );
}

mat4x2 __constructor(const mat2x4 m)
{
   __retVal = mat4x2 (
        m[0].xy,
        m[1].xy,
        0., 0.,
        0., 0.
    );
}


mat4x3 __constructor(const mat4x3 m)
{
   __retVal = m;
}

mat4x3 __constructor(const mat4 m)
{
   __retVal = mat4x3 (
        m[0].xyz,
        m[1].xyz,
        m[2].xyz,
        m[3].xyz
    );
}

mat4x3 __constructor(const mat3 m)
{
   __retVal = mat4x3 (
        m[0],
        m[1],
        m[2],
        0., 0., 0.
    );
}

mat4x3 __constructor(const mat3x4 m)
{
   __retVal = mat4x3 (
        m[0].xyz,
        m[1].xyz,
        m[2].xyz,
        0., 0., 0.
    );
}

mat4x3 __constructor(const mat4x2 m)
{
   __retVal = mat4x3 (
        m[0], 0.,
        m[1], 0.,
        m[2], 1.,
        m[3], 0.
    );
}

mat4x3 __constructor(const mat2x3 m)
{
   __retVal = mat4x3 (
        m[0],
        m[1],
        0., 0., 1.,
        0., 0., 0.
    );
}

mat4x3 __constructor(const mat3x2 m)
{
   __retVal = mat4x3 (
        m[0], 0.,
        m[1], 0.,
        m[2], 1.,
        0., 0., 0.
    );
}

mat4x3 __constructor(const mat2x4 m)
{
   __retVal = mat4x3 (
        m[0].xyz,
        m[1].xyz,
        0., 0., 1.,
        0., 0., 0.
    );
}

mat4x3 __constructor(const mat2 m)
{
   __retVal = mat4x3 (
        m[0], 0.,
        m[1], 0.,
        0., 0., 1.,
        0., 0., 0.
    );
}


mat4 __constructor(const mat4 m)
{
   __retVal = m;
}

mat4 __constructor(const mat3x4 m)
{
   __retVal = mat4 (
        m[0],
        m[1],
        m[2],
        0., 0., 0., 1.
    );
}

mat4 __constructor(const mat4x3 m)
{
   __retVal = mat4 (
        m[0], 0.,
        m[1], 0.,
        m[2], 0.,
        m[3], 1.
    );
}

mat4 __constructor(const mat2x4 m)
{
   __retVal = mat4 (
        m[0],
        m[1],
        0., 0., 1., 0.,
        0., 0., 0., 1.
    );
}

mat4 __constructor(const mat4x2 m)
{
   __retVal = mat4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        m[2], 1., 0.,
        m[3], 0., 1.
    );
}

mat4 __constructor(const mat3 m)
{
   __retVal = mat4 (
        m[0], 0.,
        m[1], 0.,
        m[2], 0.,
        0., 0., 0., 1.
    );
}

mat4 __constructor(const mat2x3 m)
{
   __retVal = mat4 (
        m[0], 0.,
        m[1], 0.,
        0., 0., 1., 0.,
        0., 0., 0., 1.
    );
}

mat4 __constructor(const mat3x2 m)
{
   __retVal = mat4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        m[2], 1., 0.,
        0., 0., 0., 1.
    );
}

mat4 __constructor(const mat2 m)
{
   __retVal = mat4 (
        m[0], 0., 0.,
        m[1], 0., 0.,
        0., 0., 1., 0.,
        0., 0., 0., 1.
    );
}


void __operator += (inout mat2x3 m, const mat2x3 n) {
    m[0] += n[0];
    m[1] += n[1];
}

void __operator += (inout mat2x4 m, const mat2x4 n) {
    m[0] += n[0];
    m[1] += n[1];
}

void __operator += (inout mat3x2 m, const mat3x2 n) {
    m[0] += n[0];
    m[1] += n[1];
    m[2] += n[2];
}

void __operator += (inout mat3x4 m, const mat3x4 n) {
    m[0] += n[0];
    m[1] += n[1];
    m[2] += n[2];
}

void __operator += (inout mat4x2 m, const mat4x2 n) {
    m[0] += n[0];
    m[1] += n[1];
    m[2] += n[2];
    m[3] += n[3];
}

void __operator += (inout mat4x3 m, const mat4x3 n) {
    m[0] += n[0];
    m[1] += n[1];
    m[2] += n[2];
    m[3] += n[3];
}


void __operator -= (inout mat2x3 m, const mat2x3 n) {
    m[0] -= n[0];
    m[1] -= n[1];
}

void __operator -= (inout mat2x4 m, const mat2x4 n) {
    m[0] -= n[0];
    m[1] -= n[1];
}

void __operator -= (inout mat3x2 m, const mat3x2 n) {
    m[0] -= n[0];
    m[1] -= n[1];
    m[2] -= n[2];
}

void __operator -= (inout mat3x4 m, const mat3x4 n) {
    m[0] -= n[0];
    m[1] -= n[1];
    m[2] -= n[2];
}

void __operator -= (inout mat4x2 m, const mat4x2 n) {
    m[0] -= n[0];
    m[1] -= n[1];
    m[2] -= n[2];
    m[3] -= n[3];
}

void __operator -= (inout mat4x3 m, const mat4x3 n) {
    m[0] -= n[0];
    m[1] -= n[1];
    m[2] -= n[2];
    m[3] -= n[3];
}


void __operator /= (inout mat2x3 m, const mat2x3 n) {
    m[0] /= n[0];
    m[1] /= n[1];
}

void __operator /= (inout mat2x4 m, const mat2x4 n) {
    m[0] /= n[0];
    m[1] /= n[1];
}

void __operator /= (inout mat3x2 m, const mat3x2 n) {
    m[0] /= n[0];
    m[1] /= n[1];
    m[2] /= n[2];
}

void __operator /= (inout mat3x4 m, const mat3x4 n) {
    m[0] /= n[0];
    m[1] /= n[1];
    m[2] /= n[2];
}

void __operator /= (inout mat4x2 m, const mat4x2 n) {
    m[0] /= n[0];
    m[1] /= n[1];
    m[2] /= n[2];
    m[3] /= n[3];
}

void __operator /= (inout mat4x3 m, const mat4x3 n) {
    m[0] /= n[0];
    m[1] /= n[1];
    m[2] /= n[2];
    m[3] /= n[3];
}


vec3 __operator * (const mat2x3 m, const vec2 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y;
   __retVal.z = v.x * m[0].z + v.y * m[1].z;
}

vec4 __operator * (const mat2x4 m, const vec2 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y;
   __retVal.z = v.x * m[0].z + v.y * m[1].z;
   __retVal.w = v.x * m[0].w + v.y * m[1].w;
}

vec2 __operator * (const mat3x2 m, const vec3 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y;
}

vec4 __operator * (const mat3x4 m, const vec3 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y;
   __retVal.z = v.x * m[0].z + v.y * m[1].z + v.z * m[2].z;
   __retVal.w = v.x * m[0].w + v.y * m[1].w + v.z * m[2].w;
}

vec2 __operator * (const mat4x2 m, const vec4 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y;
}

vec3 __operator * (const mat4x3 m, const vec4 v)
{
   __retVal.x = v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x;
   __retVal.y = v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y;
   __retVal.z = v.x * m[0].z + v.y * m[1].z + v.z * m[2].z + v.w * m[3].z;
}


mat3x2 __operator * (const mat2 m, const mat3x2 n)
{
   //return mat3x2 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4x2 __operator * (const mat2 m, const mat4x2 n)
{
   //return mat4x2 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x3 __operator * (const mat2x3 m, const mat2 n)
{
   //return mat2x3 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3 __operator * (const mat2x3 m, const mat3x2 n)
{
   //return mat3 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4x3 __operator * (const mat2x3 m, const mat4x2 n)
{
   //return mat4x3 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x4 __operator * (const mat2x4 m, const mat2 n)
{
   //return mat2x4 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3x4 __operator * (const mat2x4 m, const mat3x2 n)
{
   //return mat3x4 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4 __operator * (const mat2x4 m, const mat4x2 n)
{
   //return mat4 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2 __operator * (const mat3x2 m, const mat2x3 n)
{
   //return mat2 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3x2 __operator * (const mat3x2 m, const mat3 n)
{
   //return mat3x2 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4x2 __operator * (const mat3x2 m, const mat4x3 n)
{
   //return mat4x2 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x3 __operator * (const mat3 m, const mat2x3 n)
{
   //return mat2x3 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat4x3 __operator * (const mat3 m, const mat4x3 n)
{
   //return mat4x3 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x4 __operator * (const mat3x4 m, const mat2x3 n)
{
   //return mat2x4 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3x4 __operator * (const mat3x4 m, const mat3 n)
{
   //return mat3x4 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4 __operator * (const mat3x4 m, const mat4x3 n)
{
   //return mat4 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2 __operator * (const mat4x2 m, const mat2x4 n)
{
   //return = mat2 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3x2 __operator * (const mat4x2 m, const mat3x4 n)
{
   //return mat3x2 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4x2 __operator * (const mat4x2 m, const mat4 n)
{
   //return mat4x2 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x3 __operator * (const mat4x3 m, const mat2x4 n)
{
   //return mat2x3 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3 __operator * (const mat4x3 m, const mat3x4 n)
{
   //return mat3 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}

mat4x3 __operator * (const mat4x3 m, const mat4 n)
{
   //return mat4x3 (m * n[0], m * n[1], m * n[2], m * n[3]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
   __retVal[3] = m * n[3];
}


mat2x4 __operator * (const mat4 m, const mat2x4 n)
{
   //return mat2x4 (m * n[0], m * n[1]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
}

mat3x4 __operator * (const mat4 m, const mat3x4 n)
{
   //return mat3x4 (m * n[0], m * n[1], m * n[2]);
   __retVal[0] = m * n[0];
   __retVal[1] = m * n[1];
   __retVal[2] = m * n[2];
}


void __operator *= (inout mat2x3 m, const mat2 n) {
    m = m * n;
}

void __operator *= (inout mat2x4 m, const mat2 n) {
    m = m * n;
}

void __operator *= (inout mat3x2 m, const mat3 n) {
    m = m * n;
}

void __operator *= (inout mat3x4 m, const mat3 n) {
    m = m * n;
}

void __operator *= (inout mat4x2 m, const mat4 n) {
    m = m * n;
}

void __operator *= (inout mat4x3 m, const mat4 n) {
    m = m * n;
}


vec3 __operator * (const vec2 v, const mat3x2 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
   __retVal.z = dot(v, m[2]);
}

vec4 __operator * (const vec2 v, const mat4x2 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
   __retVal.z = dot(v, m[2]);
   __retVal.w = dot(v, m[3]);
}

vec2 __operator * (const vec3 v, const mat2x3 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
}

vec4 __operator * (const vec3 v, const mat4x3 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
   __retVal.z = dot(v, m[2]);
   __retVal.w = dot(v, m[3]);
}

vec2 __operator * (const vec4 v, const mat2x4 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
}

vec3 __operator * (const vec4 v, const mat3x4 m)
{
   __retVal.x = dot(v, m[0]);
   __retVal.y = dot(v, m[1]);
   __retVal.z = dot(v, m[2]);
}


void __operator += (inout mat2x3 m, const float a) {
    m[0] += a;
    m[1] += a;
}

void __operator += (inout mat2x4 m, const float a) {
    m[0] += a;
    m[1] += a;
}

void __operator += (inout mat3x2 m, const float a) {
    m[0] += a;
    m[1] += a;
    m[2] += a;
}

void __operator += (inout mat3x4 m, const float a) {
    m[0] += a;
    m[1] += a;
    m[2] += a;
}

void __operator += (inout mat4x2 m, const float a) {
    m[0] += a;
    m[1] += a;
    m[2] += a;
    m[3] += a;
}

void __operator += (inout mat4x3 m, const float a) {
    m[0] += a;
    m[1] += a;
    m[2] += a;
    m[3] += a;
}


void __operator -= (inout mat2x3 m, const float a) {
    m[0] -= a;
    m[1] -= a;
}

void __operator -= (inout mat2x4 m, const float a) {
    m[0] -= a;
    m[1] -= a;
}

void __operator -= (inout mat3x2 m, const float a) {
    m[0] -= a;
    m[1] -= a;
    m[2] -= a;
}

void __operator -= (inout mat3x4 m, const float a) {
    m[0] -= a;
    m[1] -= a;
    m[2] -= a;
}

void __operator -= (inout mat4x2 m, const float a) {
    m[0] -= a;
    m[1] -= a;
    m[2] -= a;
    m[3] -= a;
}

void __operator -= (inout mat4x3 m, const float a) {
    m[0] -= a;
    m[1] -= a;
    m[2] -= a;
    m[3] -= a;
}


void __operator *= (inout mat2x3 m, const float a) {
    m[0] *= a;
    m[1] *= a;
}

void __operator *= (inout mat2x4 m, const float a) {
    m[0] *= a;
    m[1] *= a;
}

void __operator *= (inout mat3x2 m, const float a) {
    m[0] *= a;
    m[1] *= a;
    m[2] *= a;
}

void __operator *= (inout mat3x4 m, const float a) {
    m[0] *= a;
    m[1] *= a;
    m[2] *= a;
}

void __operator *= (inout mat4x2 m, const float a) {
    m[0] *= a;
    m[1] *= a;
    m[2] *= a;
    m[3] *= a;
}

void __operator *= (inout mat4x3 m, const float a) {
    m[0] *= a;
    m[1] *= a;
    m[2] *= a;
    m[3] *= a;
}


void __operator /= (inout mat2x3 m, const float a) {
    m[0] /= a;
    m[1] /= a;
}

void __operator /= (inout mat2x4 m, const float a) {
    m[0] /= a;
    m[1] /= a;
}

void __operator /= (inout mat3x2 m, const float a) {
    m[0] /= a;
    m[1] /= a;
    m[2] /= a;
}

void __operator /= (inout mat3x4 m, const float a) {
    m[0] /= a;
    m[1] /= a;
    m[2] /= a;
}

void __operator /= (inout mat4x2 m, const float a) {
    m[0] /= a;
    m[1] /= a;
    m[2] /= a;
    m[3] /= a;
}

void __operator /= (inout mat4x3 m, const float a) {
    m[0] /= a;
    m[1] /= a;
    m[2] /= a;
    m[3] /= a;
}


mat2x3 __operator + (const mat2x3 m, const mat2x3 n) {
    return mat2x3 (m[0] + n[0], m[1] + n[1]);
}

mat2x4 __operator + (const mat2x4 m, const mat2x4 n) {
    return mat2x4 (m[0] + n[0], m[1] + n[1]);
}

mat3x2 __operator + (const mat3x2 m, const mat3x2 n) {
    return mat3x2 (m[0] + n[0], m[1] + n[1], m[2] + n[2]);
}

mat3x4 __operator + (const mat3x4 m, const mat3x4 n) {
    return mat3x4 (m[0] + n[0], m[1] + n[1], m[2] + n[2]);
}

mat4x2 __operator + (const mat4x2 m, const mat4x2 n) {
    return mat4x2 (m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3] + n[3]);
}

mat4x3 __operator + (const mat4x3 m, const mat4x3 n) {
    return mat4x3 (m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3] + n[3]);
}


mat2x3 __operator - (const mat2x3 m, const mat2x3 n) {
    return mat2x3 (m[0] - n[0], m[1] - n[1]);
}

mat2x4 __operator - (const mat2x4 m, const mat2x4 n) {
    return mat2x4 (m[0] - n[0], m[1] - n[1]);
}

mat3x2 __operator - (const mat3x2 m, const mat3x2 n) {
    return mat3x2 (m[0] - n[0], m[1] - n[1], m[2] - n[2]);
}

mat3x4 __operator - (const mat3x4 m, const mat3x4 n) {
    return mat3x4 (m[0] - n[0], m[1] - n[1], m[2] - n[2]);
}

mat4x2 __operator - (const mat4x2 m, const mat4x2 n) {
    return mat4x2 (m[0] - n[0], m[1] - n[1], m[2] - n[2], m[3] - n[3]);
}

mat4x3 __operator - (const mat4x3 m, const mat4x3 n) {
    return mat4x3 (m[0] - n[0], m[1] - n[1], m[2] - n[2], m[3] - n[3]);
}


mat2x3 __operator / (const mat2x3 m, const mat2x3 n) {
    return mat2x3 (m[0] / n[0], m[1] / n[1]);
}

mat2x4 __operator / (const mat2x4 m, const mat2x4 n) {
    return mat2x4 (m[0] / n[0], m[1] / n[1]);
}

mat3x2 __operator / (const mat3x2 m, const mat3x2 n) {
    return mat3x2 (m[0] / n[0], m[1] / n[1], m[2] / n[2]);
}

mat3x4 __operator / (const mat3x4 m, const mat3x4 n) {
    return mat3x4 (m[0] / n[0], m[1] / n[1], m[2] / n[2]);
}

mat4x2 __operator / (const mat4x2 m, const mat4x2 n) {
    return mat4x2 (m[0] / n[0], m[1] / n[1], m[2] / n[2], m[3] / n[3]);
}

mat4x3 __operator / (const mat4x3 m, const mat4x3 n) {
    return mat4x3 (m[0] / n[0], m[1] / n[1], m[2] / n[2], m[3] / n[3]);
}


mat2x3 __operator + (const float a, const mat2x3 n) {
    return mat2x3 (a + n[0], a + n[1]);
}

mat2x3 __operator + (const mat2x3 m, const float b) {
    return mat2x3 (m[0] + b, m[1] + b);
}

mat2x4 __operator + (const float a, const mat2x4 n) {
    return mat2x4 (a + n[0], a + n[1]);
}

mat2x4 __operator + (const mat2x4 m, const float b) {
    return mat2x4 (m[0] + b, m[1] + b);
}

mat3x2 __operator + (const float a, const mat3x2 n) {
    return mat3x2 (a + n[0], a + n[1], a + n[2]);
}

mat3x2 __operator + (const mat3x2 m, const float b) {
    return mat3x2 (m[0] + b, m[1] + b, m[2] + b);
}

mat3x4 __operator + (const float a, const mat3x4 n) {
    return mat3x4 (a + n[0], a + n[1], a + n[2]);
}

mat3x4 __operator + (const mat3x4 m, const float b) {
    return mat3x4 (m[0] + b, m[1] + b, m[2] + b);
}

mat4x2 __operator + (const mat4x2 m, const float b) {
    return mat4x2 (m[0] + b, m[1] + b, m[2] + b, m[3] + b);
}

mat4x2 __operator + (const float a, const mat4x2 n) {
    return mat4x2 (a + n[0], a + n[1], a + n[2], a + n[3]);
}

mat4x3 __operator + (const mat4x3 m, const float b) {
    return mat4x3 (m[0] + b, m[1] + b, m[2] + b, m[3] + b);
}

mat4x3 __operator + (const float a, const mat4x3 n) {
    return mat4x3 (a + n[0], a + n[1], a + n[2], a + n[3]);
}


mat2x3 __operator - (const float a, const mat2x3 n) {
    return mat2x3 (a - n[0], a - n[1]);
}

mat2x3 __operator - (const mat2x3 m, const float b) {
    return mat2x3 (m[0] - b, m[1] - b);
}

mat2x4 __operator - (const float a, const mat2x4 n) {
    return mat2x4 (a - n[0], a - n[1]);
}

mat2x4 __operator - (const mat2x4 m, const float b) {
    return mat2x4 (m[0] - b, m[1] - b);
}

mat3x2 __operator - (const float a, const mat3x2 n) {
    return mat3x2 (a - n[0], a - n[1], a - n[2]);
}

mat3x2 __operator - (const mat3x2 m, const float b) {
    return mat3x2 (m[0] - b, m[1] - b, m[2] - b);
}

mat3x4 __operator - (const float a, const mat3x4 n) {
    return mat3x4 (a - n[0], a - n[1], a - n[2]);
}

mat3x4 __operator - (const mat3x4 m, const float b) {
    return mat3x4 (m[0] - b, m[1] - b, m[2] - b);
}

mat4x2 __operator - (const mat4x2 m, const float b) {
    return mat4x2 (m[0] - b, m[1] - b, m[2] - b, m[3] - b);
}

mat4x2 __operator - (const float a, const mat4x2 n) {
    return mat4x2 (a - n[0], a - n[1], a - n[2], a - n[3]);
}

mat4x3 __operator - (const mat4x3 m, const float b) {
    return mat4x3 (m[0] - b, m[1] - b, m[2] - b, m[3] - b);
}

mat4x3 __operator - (const float a, const mat4x3 n) {
    return mat4x3 (a - n[0], a - n[1], a - n[2], a - n[3]);
}


mat2x3 __operator * (const float a, const mat2x3 n)
{
   //return mat2x3 (a * n[0], a * n[1]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
}

mat2x3 __operator * (const mat2x3 m, const float b)
{
   //return mat2x3 (m[0] * b, m[1] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
}

mat2x4 __operator * (const float a, const mat2x4 n)
{
   //return mat2x4 (a * n[0], a * n[1]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
}

mat2x4 __operator * (const mat2x4 m, const float b)
{
   //return mat2x4 (m[0] * b, m[1] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
}

mat3x2 __operator * (const float a, const mat3x2 n)
{
   //return mat3x2 (a * n[0], a * n[1], a * n[2]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
   __retVal[2] = a * n[2];
}

mat3x2 __operator * (const mat3x2 m, const float b)
{
   //return mat3x2 (m[0] * b, m[1] * b, m[2] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
   __retVal[2] = m[2] * b;
}

mat3x4 __operator * (const float a, const mat3x4 n)
{
   //return mat3x4 (a * n[0], a * n[1], a * n[2]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
   __retVal[2] = a * n[2];
}

mat3x4 __operator * (const mat3x4 m, const float b)
{
   //return mat3x4 (m[0] * b, m[1] * b, m[2] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
   __retVal[2] = m[2] * b;
}

mat4x2 __operator * (const mat4x2 m, const float b)
{
   //return mat4x2 (m[0] * b, m[1] * b, m[2] * b, m[3] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
   __retVal[2] = m[2] * b;
   __retVal[3] = m[3] * b;
}

mat4x2 __operator * (const float a, const mat4x2 n)
{
   //return mat4x2 (a * n[0], a * n[1], a * n[2], a * n[3]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
   __retVal[2] = a * n[2];
   __retVal[3] = a * n[3];
}

mat4x3 __operator * (const mat4x3 m, const float b)
{
   //return mat4x3 (m[0] * b, m[1] * b, m[2] * b, m[3] * b);
   __retVal[0] = m[0] * b;
   __retVal[1] = m[1] * b;
   __retVal[2] = m[2] * b;
   __retVal[3] = m[3] * b;
}

mat4x3 __operator * (const float a, const mat4x3 n)
{
   //return mat4x3 (a * n[0], a * n[1], a * n[2], a * n[3]);
   __retVal[0] = a * n[0];
   __retVal[1] = a * n[1];
   __retVal[2] = a * n[2];
   __retVal[3] = a * n[3];
}


mat2x3 __operator / (const float a, const mat2x3 n)
{
   //return mat2x3 (a / n[0], a / n[1]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
}

mat2x3 __operator / (const mat2x3 m, const float b)
{
   //return mat2x3 (m[0] / b, m[1] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
}

mat2x4 __operator / (const float a, const mat2x4 n)
{
   //return mat2x4 (a / n[0], a / n[1]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
}

mat2x4 __operator / (const mat2x4 m, const float b)
{
   //return mat2x4 (m[0] / b, m[1] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
}

mat3x2 __operator / (const float a, const mat3x2 n)
{
   //return mat3x2 (a / n[0], a / n[1], a / n[2]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
   __retVal[2] = inv * n[2];
}

mat3x2 __operator / (const mat3x2 m, const float b)
{
   //return mat3x2 (m[0] / b, m[1] / b, m[2] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
   __retVal[2] = m[2] * inv;
}

mat3x4 __operator / (const float a, const mat3x4 n)
{
   //return mat3x4 (a / n[0], a / n[1], a / n[2]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
   __retVal[2] = inv * n[2];
}

mat3x4 __operator / (const mat3x4 m, const float b)
{
   //return mat3x4 (m[0] / b, m[1] / b, m[2] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
   __retVal[2] = m[2] * inv;
}

mat4x2 __operator / (const mat4x2 m, const float b)
{
   //return mat4x2 (m[0] / b, m[1] / b, m[2] / b, m[3] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
   __retVal[2] = m[2] * inv;
   __retVal[3] = m[3] * inv;
}

mat4x2 __operator / (const float a, const mat4x2 n)
{
   //return mat4x2 (a / n[0], a / n[1], a / n[2], a / n[3]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
   __retVal[2] = inv * n[2];
   __retVal[3] = inv * n[3];
}

mat4x3 __operator / (const mat4x3 m, const float b)
{
   //return mat4x3 (m[0] / b, m[1] / b, m[2] / b, m[3] / b);
   const float inv = 1.0 / b;
   __retVal[0] = m[0] * inv;
   __retVal[1] = m[1] * inv;
   __retVal[2] = m[2] * inv;
   __retVal[3] = m[3] * inv;
}

mat4x3 __operator / (const float a, const mat4x3 n)
{
   //return mat4x3 (a / n[0], a / n[1], a / n[2], a / n[3]);
   const float inv = 1.0 / a;
   __retVal[0] = inv * n[0];
   __retVal[1] = inv * n[1];
   __retVal[2] = inv * n[2];
   __retVal[3] = inv * n[3];
}


mat2x3 __operator - (const mat2x3 m) {
    return mat2x3 (-m[0], -m[1]);
}

mat2x4 __operator - (const mat2x4 m) {
    return mat2x4 (-m[0], -m[1]);
}

mat3x2 __operator - (const mat3x2 m) {
    return mat3x2 (-m[0], -m[1], -m[2]);
}

mat3x4 __operator - (const mat3x4 m) {
    return mat3x4 (-m[0], -m[1], -m[2]);
}

mat4x2 __operator - (const mat4x2 m) {
    return mat4x2 (-m[0], -m[1], -m[2], -m[3]);
}

mat4x3 __operator - (const mat4x3 m) {
    return mat4x3 (-m[0], -m[1], -m[2], -m[3]);
}


void __operator -- (inout mat2x3 m) {
    --m[0];
    --m[1];
}

void __operator -- (inout mat2x4 m) {
    --m[0];
    --m[1];
}

void __operator -- (inout mat3x2 m) {
    --m[0];
    --m[1];
    --m[2];
}

void __operator -- (inout mat3x4 m) {
    --m[0];
    --m[1];
    --m[2];
}

void __operator -- (inout mat4x2 m) {
    --m[0];
    --m[1];
    --m[2];
    --m[3];
}

void __operator -- (inout mat4x3 m) {
    --m[0];
    --m[1];
    --m[2];
    --m[3];
}


void __operator ++ (inout mat2x3 m) {
    ++m[0];
    ++m[1];
}

void __operator ++ (inout mat2x4 m) {
    ++m[0];
    ++m[1];
}

void __operator ++ (inout mat3x2 m) {
    ++m[0];
    ++m[1];
    ++m[2];
}

void __operator ++ (inout mat3x4 m) {
    ++m[0];
    ++m[1];
    ++m[2];
}

void __operator ++ (inout mat4x2 m) {
    ++m[0];
    ++m[1];
    ++m[2];
    ++m[3];
}

void __operator ++ (inout mat4x3 m) {
    ++m[0];
    ++m[1];
    ++m[2];
    ++m[3];
}


mat2x3 __operator -- (inout mat2x3 m, const int) {
    return mat2x3 (m[0]--, m[1]--);
}

mat2x4 __operator -- (inout mat2x4 m, const int) {
    return mat2x4 (m[0]--, m[1]--);
}

mat3x2 __operator -- (inout mat3x2 m, const int) {
    return mat3x2 (m[0]--, m[1]--, m[2]--);
}

mat3x4 __operator -- (inout mat3x4 m, const int) {
    return mat3x4 (m[0]--, m[1]--, m[2]--);
}

mat4x2 __operator -- (inout mat4x2 m, const int) {
    return mat4x2 (m[0]--, m[1]--, m[2]--, m[3]--);
}

mat4x3 __operator -- (inout mat4x3 m, const int) {
    return mat4x3 (m[0]--, m[1]--, m[2]--, m[3]--);
}


mat2x3 __operator ++ (inout mat2x3 m, const int) {
    return mat2x3 (m[0]++, m[1]++);
}

mat2x4 __operator ++ (inout mat2x4 m, const int) {
    return mat2x4 (m[0]++, m[1]++);
}

mat3x2 __operator ++ (inout mat3x2 m, const int) {
    return mat3x2 (m[0]++, m[1]++, m[2]++);
}

mat3x4 __operator ++ (inout mat3x4 m, const int) {
    return mat3x4 (m[0]++, m[1]++, m[2]++);
}

mat4x2 __operator ++ (inout mat4x2 m, const int) {
    return mat4x2 (m[0]++, m[1]++, m[2]++, m[3]++);
}

mat4x3 __operator ++ (inout mat4x3 m, const int) {
    return mat4x3 (m[0]++, m[1]++, m[2]++, m[3]++);
}

