<div dir="ltr"><div><span style="font-size:12.8px">Nasos,</span></div><div><br></div><span style="font-size:12.8px">&gt; In line 850 I see:</span><br style="font-size:12.8px"><span style="font-size:12.8px">&gt; index( ) - it.index()</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">The error is referring the branch </span><a href="https://github.com/jdurancomas/ublas/tree/warning_promoted_types" style="font-size:12.8px" target="_blank">https://github.com/jdurancomas/ublas/tree/warning_promoted_types</a><span style="font-size:12.8px">.</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">&gt; The change you propose may have far reaching consequences. It would be preferable to find another way around it, but I am afraid we may need to mess with the type definitions of the iterators.</span><br style="font-size:12.8px"></div><div><span style="font-size:12.8px"><br></span></div>Yes, there is another option. As the definitions of value_type in E1, E2 could be different of value_type definitions in vector_binary so the local variables that stores values of E1 or E2 should be defined as E1::value_type or E2:value_type. Review the commit <a href="https://github.com/jdurancomas/ublas/commit/bc211a890595790c421055cc47d5c3be160183f7">https://github.com/jdurancomas/ublas/commit/bc211a890595790c421055cc47d5c3be160183f7</a>.<div><br>&gt; Can you please check, that promote_type&lt;char, char&gt;::promote_type is an int (as well as the unsigned char, short, unsigned short), after applying this change?<br><br></div><div>No, the change was introduced to force that when two operands of the same type was promoted then the promoted type was the same as the original one. That is:</div><div><br></div><div>promote_type&lt;char, char&gt;::promote_type is char</div><div>promote_type&lt;short, short&gt;::promote_type is short</div><div>..... </div><div><br></div><div>Thanks and Best Regards,<br>Joaquim Duran<div><span style="font-size:12.8px"><br></span></div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-04 16:09 GMT+01:00 Nasos Iliopoulos <span dir="ltr">&lt;<a href="mailto:nasos_i@hotmail.com" target="_blank">nasos_i@hotmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Joaquim,<br>
    <br>
    In line 850 I see:<br>
    index( ) - it.index()<br>
    <br>
    Based on the line numbers of the warning text, I cannot trace how
    the difference operator is called or how the promote_type is called
    in the vector_expression.hpp in ublas/develop for the particular
    case. <br>
    <br>
    The change you propose may have far reaching consequences. It would
    be preferable to find another way around it, but I am afraid we may
    need to mess with the type definitions of the iterators.<br>
    <br>
    Can you please check, that promote_type&lt;char,
    char&gt;::promote_type is an int (as well as the unsigned char,
    short, unsigned short), after applying this change?<br>
    <br>
    <br>
    In any case I think there is an issue with the  promote_traits that
    are trying to deal with both cases of numerical essence (like as
    elements of a matrix) and size_types. <br>
    In the numerical sense the promote_traits should be able to deal
    with:<br>
    1. Subtracting two unsigned integral types should return the proper
    result (i.e. a signed value)<br>
    2. The promoted type should be able to hold the full range of the
    unpromotted types<br>
    <br>
    No. 2 cannot be satisfied in general (for example for the case of
    unsigned ints, unless an 128-bit is used as the promotion type).
    This is reflected by the choice that the unsigned int promotions is
    also an unsigned int instead of just an int.<br>
    <br>
    -Nasos<div><div><br>
    <br>
    <br>
    <div>On 01/03/2016 08:43 PM, Joaquim Duran
      Comas wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div>
      <div dir="ltr">
        <div>Hello,</div>
        <div><br>
        </div>
        <div>I&#39;m trying to fix a warning that it is shown when the test
          test_matrix_vector is compiled with mscv with all warnings
          enabled. The text of the warning is the following:</div>
        <div><br>
        </div>
        <div><b>&lt;warning text&gt;</b></div>
        <div>c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/vector_expression.hpp(850)
          : warning C4244: &#39;argument&#39; : conversion from &#39;int&#39; to &#39;const
          char&#39;, possible loss of data</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/vector_expression.hpp(813)
          : while compiling class template member function &#39;int
          boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;::const_iterator::dereference(boost::numeric::ublas::sparse_bidirectional_iterator_tag)
          const&#39;</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          E1=boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;&gt;</div>
        <div>,          
 E2=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>,          
           F=boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/vector_expression.hpp(884)
          : see reference to function template instantiation &#39;int
          boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;::const_iterator::dereference(boost::numeric::ublas::sparse_bidirectional_iterator_tag)
          const&#39; being compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          E1=boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;&gt;</div>
        <div>,          
 E2=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>,          
           F=boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/vector_expression.hpp(1538)
          : see reference to class template instantiation
          &#39;boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;::const_iterator&#39;
          being compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          E1=boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;&gt;</div>
        <div>,          
 E2=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>,          
           F=boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/vector_expression.hpp(1647)
          : see reference to class template instantiation
          &#39;boost::numeric::ublas::vector_scalar_unary&lt;E,F&gt;&#39; being
          compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          E=boost::numeric::ublas::vector_binary&lt;boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
size_t,char&gt;&gt;&gt;&gt;&gt;,boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;,boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;&gt;</div>
        <div>,          
           F=boost::numeric::ublas::vector_norm_inf&lt;boost::numeric::ublas::vector_binary&lt;boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
size_t,char&gt;&gt;&gt;&gt;&gt;,boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;,boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;&gt;&gt;</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/detail/vector_assign.hpp(33)
          : see reference to function template instantiation &#39;int
          boost::numeric::ublas::norm_inf&lt;boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;&gt;(const
          boost::numeric::ublas::vector_expression&lt;boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;&gt;
          &amp;)&#39; being compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          E1=boost::numeric::ublas::matrix_column&lt;boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;&gt;</div>
        <div>,          
 E2=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>,          
           F=boost::numeric::ublas::scalar_minus&lt;char,value_type&gt;</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/detail/vector_assign.hpp(42)
          : see reference to function template instantiation &#39;bool
          boost::numeric::ublas::detail::equals&lt;boost::numeric::ublas::matrix_column&lt;Matrix&gt;,C,int&gt;(const
          boost::numeric::ublas::vector_expression&lt;boost::numeric::ublas::matrix_column&lt;Matrix&gt;&gt;
          &amp;,const boost::numeric::ublas::vector_expression&lt;C&gt;
          &amp;,S,S)&#39; being compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          Matrix=boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;</div>
        <div>,          
 C=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>,            S=int</div>
        <div>        ]</div>
        <div>       
          c:\Users\qduran\Documents\development\modular-boost\boost/numeric/ublas/detail/vector_assign.hpp(436)
          : see reference to function template instantiation &#39;bool
          boost::numeric::ublas::detail::expression_type_check&lt;boost::numeric::ublas::matrix_column&lt;Matrix&gt;,C&gt;(const
          boost::numeric::ublas::vector_expression&lt;boost::numeric::ublas::matrix_column&lt;Matrix&gt;&gt;
          &amp;,const boost::numeric::ublas::vector_expression&lt;C&gt;
          &amp;)&#39; being compiled</div>
        <div>        with</div>
        <div>        [</div>
        <div>           
          Matrix=boost::numeric::ublas::mapped_matrix&lt;char,boost::numeric::ublas::row_major,boost::numeric::ublas::map_std&lt;size_t,char,std::allocator&lt;std::pair&lt;const
          size_t,char&gt;&gt;&gt;&gt;</div>
        <div>,          
 C=boost::numeric::ublas::vector&lt;value_type,boost::numeric::ublas::unbounded_array&lt;value_type,std::allocator&lt;char&gt;&gt;&gt;</div>
        <div>        ]</div>
        <div><b>&lt;/warning text&gt;</b></div>
        <div><br>
        </div>
        <div>The warning is detected in the function
          &#39;boost::numeric::ublas::vector_binary&lt;E1,E2,F&gt;::const_iterator::dereference&#39;,
          when the binary function is called (line of code: return
          static_cast&lt;value_type&gt;(functor_type::apply (t1, t2));).
          The binary function requires two parameters of type char,
          however two parameters of type integer are provided to he
          function. The parameters provided to the binary function
          (named t1 and t2, of type integer) are declared with the type
          vector_binary::const_iterator::value_type.</div>
        <div>This type is defined from vector_binary::value_type, and
          this type is defined from F::result_type, where F is the
          template parameter of the class vector_binary that specifies
          the functor implementing the binary function. The functor
          scalar_minus defines the result_type as &#39;typedef typename
          promote_traits&lt;T1, T2&gt;::promote_type result_type;&#39;,
          where T1 and T2 are template parameters that specifies the
          types of the parameters of the binary function.</div>
        <div><br>
        </div>
        <div>The problem is located at promote_type struct, in which the
          promoted type of two chars, two unsigned chars, two shorts or
          two unsigned shorts is an integer and not the same type of the
          template parameters. Following, there are the debug traces of
          promote_traits (located at file vector_expression.hpp):</div>
        <div><br>
        </div>
        <div>promote_traits&lt;char, char&gt;::promote_type: int</div>
        <div>promote_traits&lt;unsigned char, unsigned
          char&gt;::promote_type: int</div>
        <div>promote_traits&lt;short, short&gt;::promote_type: int</div>
        <div>promote_traits&lt;unsigned short, unsigned
          short&gt;::promote_type: int</div>
        <div>promote_traits&lt;int, int&gt;::promote_type: int</div>
        <div>promote_traits&lt;unsigned int, unsigned
          int&gt;::promote_type: unsigned int</div>
        <div>promote_traits&lt;float, float&gt;::promote_type: float</div>
        <div>promote_traits&lt;double, double&gt;::promote_type: double</div>
        <div><br>
        </div>
        <div>I could fix the warning by adding the following template
          specialization of promote_traits in the file traits.hpp:</div>
        <div><br>
        </div>
        <div>template&lt;class X&gt;</div>
        <div>struct promote_traits&lt;X, X&gt; {</div>
        <div>    typedef typename X promote_type;</div>
        <div>};</div>
        <div><br>
        </div>
        <div>I would like to know if the template specialization is the
          right way to fix the problem of the promote_type struct should
          be revised.</div>
        <div><br>
        </div>
        <div>To test it, I&#39;ve created a reduced version of file
          test_matrix_vector.cpp.</div>
        <div><br>
        </div>
        <div>All these changes could be downloaded from the branch <a href="https://github.com/jdurancomas/ublas/tree/warning_promoted_types" target="_blank"></a><a href="https://github.com/jdurancomas/ublas/tree/warning_promoted_types" target="_blank">https://github.com/jdurancomas/ublas/tree/warning_promoted_types</a>.</div>
        <div><br>
        </div>
        <div>Thanks and Best Regards,</div>
        <div>Joaquim Duran</div>
        <div><br>
        </div>
      </div>
      <div>
        <table style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(170,171,182);margin-top:10px">
          <tbody>
            <tr>
              <td style="width:105px;padding-top:15px"> <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/logo-avast-v1.png" style="width: 90px; min-height: 33px;"></a> </td>
              <td style="width:470px;padding-top:20px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Este
                correo electrónico se ha enviado desde un equipo libre
                de virus y protegido por Avast. <br>
                <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
ublas mailing list
<a href="mailto:ublas@lists.boost.org" target="_blank">ublas@lists.boost.org</a>
<a href="http://lists.boost.org/mailman/listinfo.cgi/ublas" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/ublas</a>
Sent to: <a href="mailto:athanasios.iliopoulos.ctr.gr@nrl.navy.mil" target="_blank">athanasios.iliopoulos.ctr.gr@nrl.navy.mil</a></pre>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
ublas mailing list<br>
<a href="mailto:ublas@lists.boost.org" target="_blank">ublas@lists.boost.org</a><br>
<a href="http://lists.boost.org/mailman/listinfo.cgi/ublas" rel="noreferrer" target="_blank">http://lists.boost.org/mailman/listinfo.cgi/ublas</a><br>
Sent to: <a href="mailto:jdurancomas@gmail.com" target="_blank">jdurancomas@gmail.com</a><br></blockquote></div><br></div></div><div><table style="border-top-width:1px;border-top-style:solid;border-top-color:rgb(170,171,182);margin-top:10px">
	<tbody><tr>
		<td style="width:105px;padding-top:15px">
			<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/logo-avast-v1.png" style="width: 90px; min-height: 33px;"></a>
		</td>
		<td style="width:470px;padding-top:20px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Este correo electrónico se ha enviado desde un equipo libre de virus y protegido por Avast. <br><a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=webmail" style="color:rgb(68,83,234)" target="_blank">www.avast.com</a> 		</td>
	</tr>
</tbody></table>
<a href="#1520f0a4bca92457_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div></div>