#include <pw/core/debug.hpp>
#include <pw/core/matrix.hpp>
#include <pw/core/serialize.hpp>
#include <pw/core/vector.hpp>

#include <print>

auto main() -> int {

    pw::debug::d() << "pixwerx.matrix.test\n";

    auto m22 = pw::matrix<float, 2, 2>{};
    pw::debug::d() << "matrix<2,2>{} -> \n" << pw::serialize::to_string(m22);

    m22[0][0] = 1;
    m22[0][1] = 2;
    m22[1][0] = 3;
    m22[1][1] = 4;

    pw::debug::d() << "matrix<2,2>{1,2,3,4} -> \n"
                   << pw::serialize::to_string(m22);

    auto m22_inv = m22.inverse();

    pw::debug::d() << "matrix<2,2>{1,2,3,4}.inverse() -> \n"
                   << pw::serialize::to_string(m22_inv);

    auto m22_inv_inv = m22_inv.inverse();
    pw::debug::d() << "matrix<2,2>{1,2,3,4}.inverse().inverse() -> \n"
                   << pw::serialize::to_string(m22_inv_inv);

    auto row_1 = m22_inv[1];
    pw::debug::d() << "matrix<2,2>{1,2,3,4}.inverse()[1] -> \n"
                   << pw::serialize::to_string(row_1);

    auto m22_tp = m22.transposed();
    pw::debug::d() << "matrix<2,2>{1,2,3,4}.transposed() -> \n"
                   << pw::serialize::to_string(m22_tp);

    auto m22_tp_col1 = m22_tp.column(1);
    pw::debug::d() << "matrix<2,2>{1,2,3,4}.transposed().column(1) -> \n"
                   << pw::serialize::to_string(m22_tp_col1);

    auto& [r1, r2] = m22_inv;

    auto& [r1_x, r1_y] = r1;

    std::print("r1.x:{} r1.y:{}\n", r1_x, r1_y);
}
