7 #ifndef YARP_SIG_MATRIX_H
8 #define YARP_SIG_MATRIX_H
28 YARP_sig_API bool submatrix(
const Matrix &in, Matrix &out,
size_t r1,
size_t r2,
size_t c1,
size_t c2);
55 void updatePointers();
65 Matrix(
size_t r,
size_t c);
106 void resize(
size_t r,
size_t c);
115 {
return matrix[r]; }
124 {
return matrix[r]; }
133 {
return matrix[r][c]; }
142 {
return matrix[r][c]; }
196 ret.resize(r2-r1+1, c2-c1+1);
295 std::string
toString(
int precision=-1,
int width=-1,
const char* endRowStr=
"\n")
const;
302 {
return (nrows>0&&ncols>0)?storage:0;}
308 inline const double *
data()
const
309 {
return (nrows>0&&ncols>0)?storage:0;}
contains the definition of a Vector type
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Matrix removeRows(size_t first_row, size_t how_many)
Modifies the matrix, removing one or more rows from it.
void zero()
Zero the matrix.
Vector getRow(size_t r) const
Get a row of the matrix as a vector.
double * data()
Return a pointer to the first element.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Vector subcol(size_t r, size_t c, size_t size) const
Get a subcolumn of the matrix as a vector.
double * operator[](size_t r)
Single element access, no range check.
Matrix submatrix(size_t r1, size_t r2, size_t c1, size_t c2) const
Extract a submatrix from (r1,c1) to (r2,c2) (extremes included), as in Matlab B=A(r1:r2,...
void resize(size_t r, size_t c)
Resize the matrix, if matrix is not empty preserve old content.
bool operator==(const yarp::sig::Matrix &r) const
True iff all elements of a match all element of b.
Matrix transposed() const
Return the transposed of the matrix.
bool setCol(size_t col, const Vector &c)
Set a column of the matrix copying the values from a vector: the vector length must be equal to the n...
bool setSubrow(const Vector &v, size_t r, size_t c)
Set a portion of a row of this matrix with the values of the specified vector v.
const Matrix & diagonal(const Vector &d)
Build a diagonal matrix, don't resize.
double & operator()(size_t r, size_t c)
Single element access, no range check.
bool setRow(size_t row, const Vector &r)
Set a row of the matrix copying the values from a vector: the vector length must be equal to the numb...
size_t cols() const
Return number of columns.
Vector getCol(size_t c) const
Get a columns of the matrix as a vector.
bool setSubmatrix(const Matrix &m, size_t r, size_t c)
Set a portion of this matrix with the values of the specified matrix m.
bool setSubcol(const Vector &v, size_t r, size_t c)
Set a portion of a column of this matrix with the values of the specified vector v.
const double * operator[](size_t r) const
Single element access, no range check (const version).
bool write(yarp::os::ConnectionWriter &connection) const override
Write vector to a connection.
const Matrix & operator=(const Matrix &r)
Copy operator.
const double * data() const
Return a pointer to the first element (const version).
size_t rows() const
Return number of rows.
Vector subrow(size_t r, size_t c, size_t size) const
Get a subrow of the matrix as a vector.
Matrix removeCols(size_t first_col, size_t how_many)
Modifies the matrix, removing one or more columns from it.
std::string toString(int precision=-1, int width=-1, const char *endRowStr="\n") const
Print matrix to a string.
const Matrix & eye()
Build an identity matrix, don't resize.
const double & operator()(size_t r, size_t c) const
Single element access, no range check.
bool removeRows(const Matrix &in, Matrix &out, size_t first_row, size_t how_many)
bool submatrix(const Matrix &in, Matrix &out, size_t r1, size_t r2, size_t c1, size_t c2)
bool removeCols(const Matrix &in, Matrix &out, size_t first_col, size_t how_many)
The main, catch-all namespace for YARP.