Go to the documentation of this file.
44 #ifndef GNSSTK_MATRIX_HPP
45 #define GNSSTK_MATRIX_HPP
97 template <
class BaseClass>
103 template <
class BaseClass>
108 for(i = 0; i <
r; i++)
109 for(j = 0; j <
c; j++)
110 (*
this)(i,j) = mat(i, j);
114 template <
class BaseClass>
116 size_t topCol,
size_t numRows,
size_t numCols)
117 :
v((size_t)0),
r(0),
c(0),
s(0)
120 if ( (topCol > mat.
cols()) ||
121 (topRow > mat.
rows()) ||
122 ((topRow + numRows) > mat.
rows()) ||
123 ((topCol + numCols) > mat.
cols()) )
125 MatrixException e(
"Invalid dimensions or size for Matrix(MatrixBase)");
135 for(i = 0; i <
r; i++)
136 for(j = 0; j <
c; j++)
137 (*
this)(i,j) = mat(topRow + i, topCol + j);
157 bool empty()
const {
return s == 0; }
165 inline size_t rows()
const {
return r; }
167 inline size_t cols()
const {
return c; }
188 {
return v(rowNum + colNum *
r); }
191 {
return v(rowNum + colNum *
r); }
197 {
return row(rowNum);}
204 const T initialValue);
221 {
v = mat.
v;
r = mat.
r;
c = mat.
c;
s = mat.
s;
return *
this; }
223 template <
class BaseClass>
226 v.resize(mat.
size());
233 template <
class BaseClass>
267 const std::slice& colSlice)
276 size_t numRows,
size_t numCols)
277 :
m(&mat),
rSlice(
std::slice(topRow, numRows, 1)),
363 const std::slice& colSlice)
372 size_t numRows,
size_t numCols)
373 :
m(&mat),
rSlice(
std::slice(topRow, numRows, 1)),
424 this->matSliceCheck(mat.
rows(), mat.
cols());
432 this->matSliceCheck(mat.
rows(), mat.
cols());
438 {
return this->assignFrom(x); }
443 {
return this->assignFrom(x); }
446 {
return this->assignFrom(x); }
449 {
return this->assignFrom(x); }
452 {
return this->assignFrom(x); }
477 size_t cols()
const {
return 1;}
519 { this->matSliceCheck(mat.
rows(), mat.
cols()); }
528 this->matSliceCheck(mat.
rows(), mat.
cols());
545 size_t cols()
const {
return 1;}
584 { this->matSliceCheck(mat.
rows(), mat.
cols()); }
592 this->matSliceCheck(mat.
rows(), mat.
cols());
598 {
return this->assignFrom(x); }
602 {
return this->assignFrom(x); }
605 {
return this->assignFrom(x); }
608 {
return this->assignFrom(x); }
611 {
return this->assignFrom(x); }
633 size_t rows()
const {
return 1;}
675 { this->matSliceCheck(mat.
rows(), mat.
cols()); }
683 this->matSliceCheck(mat.
rows(), mat.
cols());
698 size_t rows()
const {
return 1;}
Vector< T >::iterator iterator
STL iterator type.
size_t colStart() const
returns the starting row in the base matrix of this slice
size_t rows() const
returns the number of rows in the slice
size_t colSize() const
returns the number of columns in this slice
const Matrix< T > * m
the matrix this slice refers to
MatrixColSlice & operator=(const T x)
assigns this column to x
Base class for an unmodifiable matrix slice.
MatrixRowSlice & operator=(const ConstVectorBase< T, V > &x)
assigns this row to x.
size_t colSize() const
returns the number of columns in this slice
std::slice rSlice
a slice down the rows
size_t size() const
returns the overall size of the slice
size_t rows() const
the number of rows in the slice
size_t r
the row of the slice
size_t size() const
returns the size of this slice
MatrixRowSlice< T > rowRef(size_t rowNum, const std::slice &s)
A reference slice of a row with a given std::slice.
Matrix & resize(size_t rows, size_t cols)
T * iterator
STL iterator type.
ConstMatrixSlice(const Matrix< T > &mat, const std::slice &rowSlice, const std::slice &colSlice)
makes a slice given std::slices for rows and columns
size_t size() const
returns the size of the slice
size_t colSize() const
returns the number of columns in this slice
bool empty() const
STL empty.
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
size_t rows() const
returns the number of rows in the slice
Vector< T > v
the matrix stored in column major order
ConstMatrixColSlice< T > col(size_t colNum, const std::slice &s) const
A const reference column with a given slice.
iterator begin()
STL begin.
Matrix & operator=(const ConstVectorBase< T, BaseClass > &mat)
Copies from any vector.
size_t rowStart() const
returns the starting row in the base matrix of this slice
MatrixColSlice(Matrix< T > &mat, size_t col, const std::slice &s)
Matrix(size_t rows, size_t cols, const ConstVectorBase< T, BaseClass > &vec)
copies out the contents of vec to initialize the matrix
MatrixSlice & operator=(const ConstVectorBase< T, V > &x)
Copies from x to (*this).
T operator[](size_t i) const
returns the i'th element of the slice
MatrixColSlice()
default constructor
std::slice cSlice
the slice of the row's columns
value_type front()
STL front.
Vector< T >::reference reference
STL reference type.
size_t colSize() const
returns the number of columns in this slice
size_t cols() const
The number of columns in the matrix.
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
size_t rowStart() const
returns the starting row in the base matrix of this slice
size_t colSize() const
returns the number of columns in this slice
size_t max_size() const
STL max size.
size_t c
the column this slice is for
size_t colSize() const
returns the number of columns in this slice
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
size_t rows() const
The number of rows in the matrix.
MatrixRowSlice & operator=(const ConstMatrixBase< T, V > &x)
assigns this row to x.
T & operator()(size_t i, size_t j)
returns the (i,j) element of the slice.
Vector< T >::const_iterator const_iterator
STL const iterator type.
MatrixRowSlice< T > operator[](size_t row)
operator[] that returns a row slice
size_t colStart() const
returns the starting row in the base matrix of this slice
T value_type
STL value type.
size_t c
the column this slice refers to
size_t r
the number of rows
const_iterator begin() const
STL const begin.
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
size_t cols() const
returns the number of columns in the slice
MatrixSlice(Matrix< T > &mat, size_t topRow, size_t topCol, size_t numRows, size_t numCols)
Submatrix slice.
Vector< T >::value_type value_type
STL value_type.
T & operator[](size_t i)
returns the i'th element of the column, non-const
size_t size() const
the size of the slice
T operator()(size_t i) const
returns the i'th element of the slice
T operator()(size_t i) const
returns the i'th element of the column slice
Matrix(const ConstMatrixBase< T, BaseClass > &mat)
constructor for a ConstMatrixBase object
size_t rowStart() const
returns the starting row in the base matrix of this slice
size_t rowStart() const
returns the starting row in the base matrix of this slice
size_t rowSize() const
returns the number of rows in this slice
size_t size() const
the rows()*cols() size of the matrix.
T & operator()(size_t rowNum, size_t colNum)
Non-const matrix operator(row,col)
Base class for a modifiable matrix slice.
size_t cols() const
returns the number of columns in the slice
std::slice rSlice
the row slice
std::slice cSlice
the column slice
ConstMatrixSlice(const Matrix< T > &mat)
makes a const slice of the whole matrix
size_t size() const
STL size.
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
MatrixRowSlice & operator=(const std::valarray< T > &x)
assigns this row to x.
size_t rows() const
the number of rows in the matrix
void matSliceCheck(size_t sourceRowSize, size_t sourceColSize) const
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
size_t r
the row of the slice
Matrix()
default constructor
MatrixColSlice & operator=(const ConstMatrixBase< T, V > &x)
assigns this column to x
size_t cols() const
the number of columns in the matrix
size_t colStart() const
returns the starting row in the base matrix of this slice
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
const_iterator end() const
STL const end.
size_t size() const
returns the overall size of the slice
ConstMatrixSlice(const Matrix< T > &mat, size_t topRow, size_t topCol, size_t numRows, size_t numCols)
submatrix slice
ConstMatrixColSlice(const Matrix< T > &mat, size_t col)
constructor taking a slice of column col from the matrix.
MatrixSlice & operator=(const ConstMatrixBase< T, V > &x)
Copies from x to (*this).
size_t rows() const
returns the number of rows in the slice
Matrix & operator=(const T t)
Assigns all elements of the matrix to t.
ConstMatrixSlice(void)
default constructor
MatrixSlice()
default constructor
MatrixSlice(Matrix< T > &mat, const std::slice &rowSlice, const std::slice &colSlice)
Makes a partial slice of a matrix.
MatrixColSlice & operator=(const std::valarray< T > &x)
assigns this column to x
MatrixSlice & operator=(const T x)
Copies from x to (*this).
size_t rowStart() const
returns the starting row in the base matrix of this slice
Matrix & operator=(const Matrix &mat)
Copies the other matrix.
MatrixRowSlice & operator=(const T x)
assigns this row to x.
size_t rows() const
returns the number of rows in the row slice
size_t rowSize() const
returns the number of rows in this slice
ConstMatrixRowSlice()
default constructor
size_t size() const
returns the size of the slice
MatrixSlice(Matrix< T > &mat)
Makes a slice of the whole matrix.
size_t c
the number of columns
T operator()(size_t i, size_t j) const
the (i,j) element of the slice, const.
Matrix & operator=(const T *array)
size_t colStart() const
returns the starting row in the base matrix of this slice
ConstMatrixColSlice()
default constructor
MatrixRowSlice(Matrix< T > &mat, size_t row)
makes a slice of row row from the matrix.
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
Matrix(const ConstMatrixBase< T, BaseClass > &mat, size_t topRow, size_t topCol, size_t numRows, size_t numCols)
submatrix constructor
T & reference
STL reference type.
std::slice rSlice
slice down the rows
size_t cols() const
returns the size of the slice in columns
std::slice rSlice
a row slice
MatrixRowSlice & operator=(const T *x)
assigns this row to x.
T & operator[](size_t j)
returns the j'th element of the slice, non-const
ConstMatrixRowSlice(const Matrix< T > &mat, size_t row)
makes a const row slice from the matrix
MatrixColSlice & operator=(const T *x)
assigns this column to x
size_t rowSize() const
returns the number of rows in this slice
MatrixRowSlice(Matrix< T > &mat, size_t row, const std::slice &s)
makes a slice of row row from the matrix, slicing it by s.
Matrix< T > * m
the matrix this slice refers to.
T & operator()(size_t j)
returns the j'th element of the slice, non-const
Vector< T >::const_reference const_reference
STL const reference type.
T & operator()(size_t i)
returns the i'th element of the column, non-const
const Matrix< T > * m
the matrix this slice refers to.
size_t cols() const
the number of columns in the slice
MatrixSlice & operator=(const std::valarray< T > &x)
Copies from x to (*this).
size_t colStart() const
returns the starting row in the base matrix of this slice
size_t colStart() const
returns the starting row in the base matrix of this slice
size_t rowSize() const
returns the number of rows in this slice
T operator[](size_t i) const
returns the i'th element of the column slice
MatrixColSlice< T > colRef(size_t colNum, const std::slice &s)
A reference column with a given slice.
#define GNSSTK_THROW(exc)
size_t cols() const
returns the number of columns in the slice
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
size_t rowStride() const
returns the number of elements between the i'th and i+1'th row
ConstMatrixRowSlice(const Matrix< T > &mat, size_t row, const std::slice &s)
makes a const row slice from the matrix, slicing that row by s.
size_t rows() const
returns the size of the slice in rows
std::slice cSlice
a column slice
size_t rowSize() const
returns the number of rows in this slice
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
size_t colStride() const
returns the number of elements between the i'th and i+1'th row
std::slice cSlice
the column slice of the row.
Matrix< T > & assignFrom(const ConstMatrixBase< T, E > &x)
MatrixSlice & operator=(const T *x)
Copies from x to (*this).
Matrix & operator=(const ConstMatrixBase< T, BaseClass > &mat)
Copies from any matrix.
size_t rowStart() const
returns the starting row in the base matrix of this slice
const Matrix< T > * m
the matrix this slice refers to
Matrix< T > * m
the matrix this slice refers to.
size_t s
the size of the slice
Matrix & operator=(const std::valarray< T > array)
MatrixRowSlice()
default constructor
ConstMatrixColSlice(const Matrix< T > &mat, size_t col, const std::slice &s)
MatrixColSlice(Matrix< T > &mat, size_t col)
makes a slice of the column col from matrix mat.
size_t cols() const
returns the number of columns in the row slice
Matrix< T > * m
The matrix this slice refers to.
ConstMatrixRowSlice< T > row(size_t rowNum, const std::slice &s) const
A const reference slice of a row with a given std::slice.
MatrixColSlice & operator=(const ConstVectorBase< T, V > &x)
assigns this column to x
size_t rowSize() const
returns the number of rows in this slice
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39