#ifndef RTS_MATRIX_H #define RTS_MATRIX_H //#include "rts/vector.h" #include #include #include #include #include namespace stim{ template struct matrix { //the matrix will be stored in column-major order (compatible with OpenGL) T M[N*N]; CUDA_CALLABLE matrix() { for(int r=0; r set(T rhs[N*N]) { memcpy(M, rhs, sizeof(T)*N*N); return *this; } CUDA_CALLABLE T& operator()(int row, int col) { return M[col * N + row]; } CUDA_CALLABLE matrix operator=(T rhs) { int Nsq = N*N; for(int i=0; i vec operator*(vec rhs){ unsigned int N = rhs.size(); vec result; result.resize(N); for(int r=0; r CUDA_CALLABLE vec3 operator*(vec3 rhs){ vec3 result = 0; for(int r=0; r<3; r++) for(int c=0; c<3; c++) result[r] += (*this)(r, c) * rhs[c]; return result; } std::string toStr() { std::stringstream ss; for(int r = 0; r < N; r++) { ss << "| "; for(int c=0; c std::ostream& operator<<(std::ostream& os, stim::matrix M) { os< 3 && __GNUC_MINOR__ > 7 //template using rtsMatrix = rts::matrix; //#endif #endif