aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-05 18:21:44 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-05 18:21:44 +0000
commit85515054365e62c757cc5395619f73652c4556fa (patch)
tree22ed411b03d04ec34f8df514cfba5afc59c229a7
parent1b8804288050f92dd6da3ff98c9ecece5953d717 (diff)
problem solved, we really want public inheritance and it is only
automatic when the _child_ class is a struct.
-rw-r--r--Eigen/src/Core/Matrix.h2
-rw-r--r--Eigen/src/Core/util/Memory.h4
-rw-r--r--doc/UnalignedArrayAssert.dox24
3 files changed, 15 insertions, 15 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 260e8c0ff..bfff6cc4c 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -132,7 +132,7 @@ class Matrix
protected:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
- public: // FIXME should this be public? I'd say yes but I still don't understand then why at other places we've been having private new and delete operators.
+ public:
enum { NeedsToAlign = (Options&Matrix_AutoAlign) == Matrix_AutoAlign
&& SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 };
typedef typename ei_meta_if<NeedsToAlign, ei_byte_forcing_aligned_malloc, char>::ret ByteAlignedAsNeeded;
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index e4b3bc39c..c8341dae4 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -173,7 +173,7 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
* overloading the operator new to return aligned data when the vectorization is enabled.
* Here is a similar safe example:
* \code
- * struct Foo : WithAlignedOperatorNew {
+ * struct Foo : public WithAlignedOperatorNew {
* char dummy;
* Vector4f some_vector;
* };
@@ -201,7 +201,7 @@ struct WithAlignedOperatorNew
template<typename T, int SizeAtCompileTime,
bool NeedsToAlign = (SizeAtCompileTime!=Dynamic) && ((sizeof(T)*SizeAtCompileTime)%16==0)>
-struct ei_with_aligned_operator_new : WithAlignedOperatorNew {};
+struct ei_with_aligned_operator_new : public WithAlignedOperatorNew {};
template<typename T, int SizeAtCompileTime>
struct ei_with_aligned_operator_new<T,SizeAtCompileTime,false> {};
diff --git a/doc/UnalignedArrayAssert.dox b/doc/UnalignedArrayAssert.dox
index a0fb0b314..dddd00bb6 100644
--- a/doc/UnalignedArrayAssert.dox
+++ b/doc/UnalignedArrayAssert.dox
@@ -16,7 +16,7 @@ namespace Eigen {
If you saw the assertion failure that links to this page, then you probably have done something like that in your code:
\code
-struct Foo
+class Foo
{
...
Eigen::Vector2d v;
@@ -28,7 +28,7 @@ struct Foo
Foo *foo = new Foo;
\endcode
-In other words: you have probably in your code a structure that has as a member a vectorizable fixed-size Eigen object, and you then dynamically allocated an object of that structure.
+In other words: you have probably in your code a class that has as a member a vectorizable fixed-size Eigen object, and you then dynamically allocated an object of that class.
By "vectorizable fixed-size Eigen object" we mean an Eigen matrix or vector of fixed size, and whose size is a multiple of 128 bits. Examples include:
\li Eigen::Vector2d
@@ -43,10 +43,10 @@ By "vectorizable fixed-size Eigen object" we mean an Eigen matrix or vector of f
\section how How to fix this bug?
-Very easy, you just need to let your struct Foo inherit Eigen::WithAlignedOperatorNew, like this:
+Very easy, you just need to let your class Foo publicly inherit Eigen::WithAlignedOperatorNew, like this:
\code
-struct Foo : Eigen::WithAlignedOperatorNew
+class Foo : public Eigen::WithAlignedOperatorNew
{
...
Eigen::Vector2d v;
@@ -65,7 +65,7 @@ With this, you should be out of trouble.
OK let's say that your code looks like this:
\code
-struct Foo
+class Foo
{
...
Eigen::Vector2d v;
@@ -85,18 +85,18 @@ For this reason, Eigen takes care by itself to require 128-bit alignment for Eig
Thus, normally, you don't have to worry about anything, Eigen handles alignment for you...
-... except in one case. When you have a struct Foo like above, and you dynamically allocate a new Foo as above, then, since Foo doesn't have aligned "operator new", the returned pointer foo is not necessarily 128-bit aligned.
+... except in one case. When you have a class Foo like above, and you dynamically allocate a new Foo as above, then, since Foo doesn't have aligned "operator new", the returned pointer foo is not necessarily 128-bit aligned.
-The alignment attribute of the member v is then relative to the start of the struct, foo. If the foo pointer wasn't aligned, then foo->v won't be aligned either!
+The alignment attribute of the member v is then relative to the start of the class, foo. If the foo pointer wasn't aligned, then foo->v won't be aligned either!
-The solution is to let struct Foo have an aligned "operator new", as we showed in the previous section.
+The solution is to let class Foo have an aligned "operator new", as we showed in the previous section.
-\section movetotop Should I then put all the members of Eigen types at the beginning of my struct?
+\section movetotop Should I then put all the members of Eigen types at the beginning of my class?
-No, that's not needed. Since Eigen takes care of declaring 128-bit alignment, all members that need it are automatically 128-bit aligned relatively to the struct. So when you have code like
+No, that's not needed. Since Eigen takes care of declaring 128-bit alignment, all members that need it are automatically 128-bit aligned relatively to the class. So when you have code like
\code
-struct Foo : Eigen::WithAlignedOperatorNew
+class Foo : public Eigen::WithAlignedOperatorNew
{
double x;
Eigen::Vector2d v;
@@ -106,7 +106,7 @@ struct Foo : Eigen::WithAlignedOperatorNew
it will work just fine. You do \b not need to rewrite it as
\code
-struct Foo : Eigen::WithAlignedOperatorNew
+class Foo : public Eigen::WithAlignedOperatorNew
{
Eigen::Vector2d v;
double x;