mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user