basic function work and are validated against octave output

This commit is contained in:
Hartmut Seichter 2019-01-18 09:34:48 +01:00
parent 54e3b1587e
commit 55b7361717
2 changed files with 123 additions and 24 deletions

View file

@ -7,21 +7,64 @@
#include <pw/core/debug.hpp>
#include <iostream>
#include <sstream>
template <typename T_,typename O_,size_t R,size_t C> inline static
std::basic_ostream<O_>& operator << (std::basic_ostream<O_>& os,
const pw::matrix_<T_,R,C>& m
)
{
for (size_t r = 0; r < R;r++){
for (size_t c = 0;c < C;c++) {
os << m(r,c) << " ";
}
os << std::endl;
}
return os;
}
int main(int argc,char **argv) {
using namespace pw;
matrix2x2f m22; m22.zero();
m22(0,0) = 1; m22(0,1) = 2;
m22(1,0) = 3; m22(1,1) = 4;
vector2f v2;
v2[0] = 1; v2[1] = 3;
vector2f v3(1.f,2.f);
auto m22_inv = m22.inverse();
auto m22_id = m22_inv * m22;
auto v2_t = m22_id * v2;
auto v3_t = m22_id * v3;
auto v2_f = m22 * v2;
auto v2_b = m22_inv * v2_f;
debug::d() << "offset(0,1) col-major " << m22.offset(0,1);
debug::d() << "det " << m22.determinant();
std::cout << "m22 " << m22 << std::endl;
std::cout << "m22-1 " << m22_inv << std::endl;
std::cout << "m22-i " << m22_id << std::endl;
std::cout << "v22_t " << v2_t << std::endl;
std::cout << "v3_t " << v3_t << std::endl;
std::cout << "v2_f " << v2_f << std::endl;
std::cout << "v2_b " << v2_b << std::endl;
// vector2f v2 = m22.slice<2,1>(0,0);
// m22.set_slice<2,1>(v2,0,0);