Merge WrapArray into FromArray. Less code. The downside is that we're using one more

const_cast. But I think that anyway trying to maintain const strictness in Eigen2 is not
worth the hassle.

Konstantin: so the code snippet I sent you won't work anymore, replace wrapArray with fromArray.

CCMAIL:konst.heil@stud.uni-heidelberg.de
This commit is contained in:
Benoit Jacob
2007-10-14 18:02:16 +00:00
parent a94a8c68e8
commit f355ef2df0
7 changed files with 17 additions and 85 deletions

View File

@@ -36,11 +36,13 @@ template<typename MatrixType> class FromArray
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
FromArray(int rows, int cols, const Scalar* array) : m_rows(rows), m_cols(cols), m_array(array)
FromArray(int rows, int cols, Scalar* array) : m_rows(rows), m_cols(cols), m_array(array)
{
assert(rows > 0 && cols > 0);
}
EI_INHERIT_ASSIGNMENT_OPERATORS(FromArray)
private:
FromArray& _ref() { return *this; }
const FromArray& _constRef() const { return *this; }
@@ -52,15 +54,20 @@ template<typename MatrixType> class FromArray
return m_array[row + col * m_rows];
}
Scalar& _write(int row, int col)
{
return m_array[row + col * m_rows];
}
protected:
int m_rows, m_cols;
const Scalar* m_array;
Scalar* m_array;
};
template<typename Scalar, typename Derived>
FromArray<Derived> Object<Scalar, Derived>::fromArray(const Scalar* array, int rows, int cols)
{
return FromArray<Derived>(rows, cols, array);
return FromArray<Derived>(rows, cols, const_cast<Scalar*>(array));
}
#endif // EI_FROMARRAY_H