Normalize Sparse Matrix along rows in C++ Eigen
I'd put the Eigen headers below the STL headers.  Also, &lt;math.h&gt; should be &lt;cmath&gt;, the latter being the C++ library incorporated into the std namespace.
You can define main() below the other functions, allowing you to save a bit of room by eliminating the function prototypes.
You don't need that flushing with std::endl.  To get just a newline, output a "\n".
main() doesn't need an explicit return 0.  As reaching this point implies success, the compiler will do this return for you.
You shouldn't use an int here:


for(int i = 0; i &lt; weights.size(); ++i)
  {
    sm_weights.insert(i,i) = weights[i];
  }



If you had your compiler warnings up high (and they should be), you should've been told about a type-mismatch here.  The type for i should instead be std::size_type (an unsigned type), which is the return type of size() for each STL container class.
For this for loop:


for (int j = 0; j &lt; sm.row(i).nonZeros(); ++j) 
  {
    my_sum += (*val_ptr * (*val_ptr));
    val_ptr++;
  }



val_ptr++ can still be put into the loop statement:

for (int j = 0; j &lt; sm.row(i).nonZeros(); ++j, val_ptr++) 
{
    my_sum += (*val_ptr * (*val_ptr));
}


I'm also unsure about all the raw pointer use here.  Raw pointers in C++ should be kept to a minimum, so there may be a way to do this without using any of them.
You pass sm by value in both of your functions, however, it doesn't look like you're trying to allow the compiler to perform move semantics.  But you're also using the argument in such a way that it's only being read for writing to other values.  In such a case, you should pass sm by const&amp;.