Split Row and Column into separate files.

Introduce a notion of RowVector (typedef for Matriw with 1 row)
Make row() return a row vector instead of a "column vector"
Introduce operator[] to access elements of row/column vectors uniformly
Remove default arguments in operator(), these were for vectors, now use operator[] instead
This commit is contained in:
Benoit Jacob
2007-10-01 07:45:30 +00:00
parent 3cf6caba1a
commit 96524fc573
6 changed files with 45 additions and 84 deletions

View File

@@ -24,8 +24,8 @@
// License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License.
#ifndef EI_EIGENBASE_H
#define EI_EIGENBASE_H
#ifndef EI_OBJECT_H
#define EI_OBJECT_H
#include "Util.h"
@@ -118,7 +118,7 @@ template<typename Scalar, typename Derived> class EiObject
EiRow<Derived> row(int i);
EiColumn<Derived> col(int i);
EiMinor<Derived> minor(int row, int col);
EiBlock<Derived> block(int startRow, int endRow, int startCol= 0, int endCol = 0);
EiBlock<Derived> block(int startRow, int endRow, int startCol, int endCol);
template<typename OtherDerived>
EiMatrixProduct<Derived, OtherDerived>
@@ -145,12 +145,26 @@ template<typename Scalar, typename Derived> class EiObject
Derived& operator/=(const std::complex<float>& other);
Derived& operator/=(const std::complex<double>& other);
Scalar operator()(int row, int col = 0) const
Scalar operator()(int row, int col) const
{ return read(row, col); }
Scalar& operator()(int row, int col = 0)
Scalar& operator()(int row, int col)
{ return write(row, col); }
Scalar operator[](int index) const
{
assert(RowsAtCompileTime == 1 || ColsAtCompileTime == 1);
if(RowsAtCompileTime == 1) return read(0, index);
else return read(index, 0);
}
Scalar& operator[](int index)
{
assert(RowsAtCompileTime == 1 || ColsAtCompileTime == 1);
if(RowsAtCompileTime == 1) return write(0, index);
else return write(index, 0);
}
EiEval<Derived> eval() const EI_ALWAYS_INLINE;
};
@@ -170,4 +184,4 @@ std::ostream & operator <<
return s;
}
#endif // EI_EIGENBASE_H
#endif // EI_OBJECT_H