58 for(
unsigned i = 0; i < n; i++)
67 for(
unsigned i = 0; i <
_data.
size(); i++)
73 operator const mat<T>()
const
78 for(
unsigned i =0; i <
size();i++)
87 assert(
size() == m.size());
90 for(
unsigned i = 0; i <
size();i++)
92 r(i) = m(
operator()(i));
104 for(
unsigned i = 0; i <
_data.
size(); i++)
109 void swap(
unsigned i,
unsigned j)
115 unsigned& operator()(
unsigned i)
121 unsigned& operator[](
unsigned i)
127 unsigned operator()(
unsigned i)
const
133 unsigned operator[](
unsigned i)
const
145 mat<T> operator*(
const perm_mat& p,
const mat<T>& m)
147 mat<T> r(m.nrows(),m.ncols());
149 for(
unsigned i = 0; i < m.nrows(); i++)
151 for(
unsigned j = 0; j < m.ncols(); j++)
162 mat<T> operator*(
const mat<T>& m,
const perm_mat& p)
164 mat<T> r(m.nrows(),m.ncols());
166 for(
unsigned i = 0; i < m.nrows(); i++)
168 for(
unsigned j = 0; j < m.ncols(); j++)
180 vec<T> operator*(
const perm_mat& p,
const vec<T>& v)
183 for(
unsigned i = 0; i < v.size(); i++)
193 inline perm_mat
transpose(
const perm_mat &p)
203 inline std::ostream&
operator<<(std::ostream& out,
const perm_mat& m)
206 for (
int i=0;i<(int)m.size();++i)
207 out << i <<
"->"<< m(i)<<
"\n";
void resize(unsigned dim)
resize the vector
Definition: vec.h:557
unsigned nrows() const
number of rows
Definition: perm_mat.h:40
Definition: perm_mat.h:13
perm_mat()
standard constructor
Definition: perm_mat.h:18
perm_mat(vec< unsigned > p)
creates a permutation from a given permutation vector
Definition: perm_mat.h:28
perm_mat operator*(const perm_mat &m)
product with another permutation matrix
Definition: perm_mat.h:85
unsigned size() const
number of elements
Definition: vec.h:97
vec< unsigned > _data
internal storage of the permutation
Definition: perm_mat.h:15
unsigned size() const
number of stored elements
Definition: perm_mat.h:34
fmat< T, N, N > transpose(const fmat< T, N, N > &m)
return the transposed of a square matrix
Definition: fmat.h:196
std::ostream & operator<<(std::ostream &out, const diag_mat< T > &m)
output of a diagonal matrix onto an ostream
Definition: diag_mat.h:442
perm_mat(unsigned n)
create an nxn identity permutation matrix (storage is only n)
Definition: perm_mat.h:21
void identity()
set to identity matrix
Definition: perm_mat.h:102
unsigned ncols() const
number of rows
Definition: perm_mat.h:46
void resize(unsigned n)
resize the permutation matrix
Definition: perm_mat.h:55
void transpose()
compute the transpose permutation matrix (equal to inverse permutation)
Definition: perm_mat.h:64
the cgv namespace
Definition: vr_calib.cxx:9