title: Using Eigen Array-of-Arrays for RGB images
body: <p>I'm trying to use the Eigen library for some simple image processing. I'd use Array3f for an RGB triple and an Array to hold an RGB image. This seems to work partially, and I can conveniently do component-wise addition, multiplication and division of images. But certain operations (specifically involving subtraction or negation) seem to create compile errors. Here is a minimal example:</p>
  
  <pre><code>#include &lt;Eigen/Core&gt;
  
  using namespace Eigen;
  
  int main(void)
  {
      typedef Array&lt;Array3f, Dynamic, Dynamic&gt; MyArray;
      MyArray m(2,2);
  
      // all of the following should have the same mathematical effect
  
      Array3f v = -Array3f(5.0f);             // this compiles
  
      MyArray a = m + v;                      // this compiles
      MyArray b = m + Array3f(-5.0f);         // this compiles
      MyArray c = m + (-Array3f(5.0f));       // this doesn't compile
      MyArray d = m - Array3f(5.0f);          // this doesn't compile
  }
  </code></pre>
  
  <p>The above code gives me three errors:</p>
  
  <pre><code>./Eigen/src/Core/CwiseBinaryOp.h:128:7: error: no member named
        'YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY' in
        'Eigen::internal::static_assertion&lt;false&gt;'
        EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);
  ...
  
  ./Eigen/src/Core/CwiseBinaryOp.h:187:14: error: no matching function for call to object of type 'const
        Eigen::internal::scalar_sum_op&lt;Eigen::Array&lt;float, 3, 1, 0, 3, 1&gt; &gt;'
        return derived().functor()(derived().lhs().coeff(index),
  ...
  
  ./Eigen/src/Core/../plugins/ArrayCwiseBinaryOps.h:208:10: error: no viable conversion from 'const
        CwiseBinaryOp&lt;internal::scalar_sum_op&lt;Scalar&gt;, const Eigen::Array&lt;Eigen::Array&lt;float, 3, 1, 0, 3, 1&gt;, -1, -1, 0, -1, -1&gt;, const
        Eigen::CwiseUnaryOp&lt;Eigen::internal::scalar_opposite_op&lt;float&gt;, const Eigen::Array&lt;float, 3, 1, 0, 3, 1&gt; &gt; &gt;' to 'const
        CwiseUnaryOp&lt;internal::scalar_add_op&lt;Scalar&gt;, const Eigen::Array&lt;Eigen::Array&lt;float, 3, 1, 0, 3, 1&gt;, -1, -1, 0, -1, -1&gt; &gt;'
    return *this + (-scalar);
  ...
  </code></pre>