nml::mat2 operator-(nml::mat2 lhs, const nml::mat2& rhs)

Return a mat2 that is the difference between two mat2.

The difference between two mat2 is calculated this way:

\(\begin{bmatrix} lhs.x.x & lhs.y.x \\ lhs.x.y & lhs.y.y \end{bmatrix} - \begin{bmatrix} rhs.x.x & rhs.y.x \\ rhs.x.y & rhs.y.y \end{bmatrix} = \begin{bmatrix} lhs.x.x - rhs.x.x & lhs.y.x - rhs.y.x \\ lhs.x.y - rhs.x.y & lhs.y.y - rhs.y.y \end{bmatrix}\)

Example

#include "include/mat2.h"
#include <iostream>

int main() {
        nml::mat2 a(2.0f, 5.0f, 3.0f, 6.0f);
        nml::mat2 b(1.0f, 2.0f, 3.0f, 4.0f);
        nml::mat2 c = a - b;
        std::cout << nml::to_string(c) << std::endl;

        return 0;
}

Result:

[[1.000000, 3.000000], [0.000000, 2.000000]]