title: Operations on Eigen Map sparse objects
body: <p>In my application I have to send <code>Eigen::SparseMatrix&lt;float&gt;</code> objects over the network, which means I need to serialize them and on the other end deserialize them into a <code>Eigen::Map&lt;Eigen::SparseMatrix&lt;float&gt;&gt;</code>, as suggested in <a href="https://stackoverflow.com/q/51939356/209882">this question</a>.</p>
  
  <p>My issue now is that I'd like to perform some operations on the receiving end, namely sum all matrices that arrive.</p>
  
  <p>However when I try to add together two Eigen::Map objects it produces a compiler error. This is true for any operation I try to perform on an Eigen::Map:</p>
  
  <pre><code>// This leads to a compiler error
  Eigen::Map&lt;Eigen::SparseMatrix&lt;float&gt;&gt; recon = SerializedVectorToMappedSparseMatrix(serialized_vec);
  Eigen::Map&lt;Eigen::SparseMatrix&lt;float&gt;&gt; recondouble = recon * 2;
  </code></pre>
  
  <blockquote>
    <p>error: conversion from ‘const type {aka const
    Eigen::SparseMatrix}’ to non-scalar type
    ‘Eigen::Map >’ requested<br>
    Eigen::Map> recondouble = (recon *
    2).eval();</p>
  </blockquote>
  
  <p>However this compiles and works as expected:</p>
  
  <pre><code>Eigen::SparseMatrix&lt;float&gt; recondouble = recon * 2;
  </code></pre>
  
  <p>In my network case I'd like to perform a sum of the existing and incoming Map:</p>
  
  <pre><code>existing_matrix += incoming_matrix;
  </code></pre>
  
  <p>This causes the compiler error:</p>
  
  <blockquote>
    <p>error: no match for ‘operator=’ (operand types are
    ‘Eigen::Map >’ and ‘const
    Eigen::CwiseBinaryOp,
    const Eigen::Map >, const
    Eigen::Map > >’)    return
    derived() = derived() + other.derived();</p>
  </blockquote>
  
  <p>So my question is: Are we supposed to convert Eigen::Map objects to Eigen:Matrix if we are to perform operations between them? <a href="http://eigen.tuxfamily.org/dox/group__TutorialMapClass.html#title2" rel="nofollow noreferrer">The example in the docs</a> seems to suggest otherwise.</p>
  
  <p>Am I doing something wrong in my use of the Eigen::Map container?</p>