mult_symm__( Matrix A, VecX x, VecZ z ) problem

Hugues Demers <[email protected]> Wed, 4 Feb 2004 10:15:15 -0500
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <20040204151515.GC725@neptune>
Hi,

I would like the opinion of this list about a possible solution for a
compilation problem I encountered with mult.

Let A be a matrix of type 
  typedef mtl::matrix< double, mtl::symmetric<mtl::upper>, mtl::packed<mtl::external>, mtl::row_major >::type Matrix;

defined like
  Matrix A( data, 4, 4 );

where

  double data[] = { ... };

and let x, y and z be of type

  typedef mtl::dense1D< complex<double> > CVector_t;
  
If I do 
  mtl::mult( A, x, y, z );
  

I get this error at compile time (gcc 3.2):

  ../../include/mtl/mtl.h:1613: no match for `double& += std::complex<double>' operator

Function mult_symm__ is defined like this:

1589  template <class Matrix, class VecX, class VecZ>
1590  inline void
1591  mult_symm__(const Matrix& A, const VecX& x, VecZ& z, row_tag)
1592  {
1593    typedef typename matrix_traits<Matrix>::value_type T;
1594    typename Matrix::const_iterator i;
1595    typename Matrix::OneD::const_iterator j, jend;
1596  
1597    for (i = A.begin(); i != A.end(); ++i) {
1598      T tmp = z[i.index()];
1599      j = (*i).begin();
1600      jend = (*i).end();
1601      if (A.is_upper()) {
1602        tmp += *j * x[j.column()];
1603        ++j;
1604      } else
1605        --jend;
1606      for (; j != jend; ++j) {
1607        /* normal side */
1608        tmp += *j * x[j.column()];
1609        /* symmetric side */
1610        z[j.column()] += *j * x[j.row()];
1611      }
1612      if (A.is_lower())
1613        tmp += *j * x[j.column()];
1614      z[i.index()] = tmp;
1615    }
1616  }

The problem arise from the fact that the temporary placeholder tmp is
declared as the same type as matrix A instead of the type of the
resulting vector z (which would seems more logical).

If I change the first line of mult_symm__ for

  typedef typename VecZ::value_type T;

it works. 

Now what would be the consequences of doing this? Changes must also be
done in mult_symm__( ... , column_tag ) and in both rect_mult.

Thanks for any advices,
Hugues Demers
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/