dMatrix transpose(dMatrix m){ dMatrix t(m[0].size(), dVector(m.size())); for (int i = 0; i < m.size(); i++){ for( int j = 0; j < m[0].size(); j++){ t[i][j] = m[j][i]; } } return t; }
dMatrix multiplicacaoNN(const dMatrix m1, const dMatrix m2) { int m1l = m1.size(), m1c = m1[0].size(), m2l=m2.size(), m2c = m2[0].size(); dMatrix matrix(m1l, dVector(m2c, 0)); for (int l = 0; l < m1l; l++){ for (int c = 0; c < m1c; c++){ for (int k = 0; k < m1c; k++){ matrix[l][c] += m1[l][k] * m2[k][c]; } } } return matrix; }
dVector multiplicacaoN1(const dMatrix &m1, const dVector &v2) { dVector vetor (m1[0].size()); for (int i = 0; i < m1.size(); ++i) for (int j = 0; j < m1[0].size(); ++j) vetor[i] += m1[i][j] * v2[j]; return vetor; }
dMatrix getRotationNN(dMatrix m){ dMatrix t(m.size(), dVector(m.size())); for (int i = 0; i < m.size()-1; i++){ for (int j = 0; j < m.size()-1; j++){ t[i][j] = m[i][j]; } } t[m.size() - 1][m.size() - 1] = 1; return t; }