Hi Kim,

Thank you for your reply.
I am sorry if my questions sounds naive. I ran into a problem compiling this program. Do I need to have a specific version of phoenix or spirit to compile this program. Since in my system, phoenix.hpp is located in  "boost/spirit/phoenix.hpp", I changed your program to the following:

# include <boost/numeric/ublas/symmetric.hpp>
# include <boost/numeric/ublas/io.hpp>
# include <boost/spirit/phoenix.hpp>

# include <vector>
# include <algorithm>

using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace boost::numeric::ublas;

int main () {

  symmetric_matrix<double,lower> m(3, 3), n(3,3), u(3,3);
  generate(arg1, lambda[val(1.0)] )(m.data());
  generate(arg1, lambda[val(2.0)] )(n.data());
  transform(arg1,n.data().begin(),u.data().begin(),lambda[arg1/arg2])(m.data());

  std::cout << u << std::endl;
}


when I try to compile it with:

g++ Hadamard_test.cpp -o Hadamard_test -Wall -O3 -DNDEBUG

I get:

Hadamard_test.cpp:8: error: ‘phoenix’ is not a namespace-name
Hadamard_test.cpp:8: error: expected namespace-name before ‘;’ token
Hadamard_test.cpp:9: error: ‘boost::phoenix’ has not been declared
Hadamard_test.cpp:9: error: ‘arg_names’ is not a namespace-name
Hadamard_test.cpp:9: error: expected namespace-name before ‘;’ token
Hadamard_test.cpp: In function ‘int main()’:
Hadamard_test.cpp:15: error: ‘arg1’ was not declared in this scope
Hadamard_test.cpp:15: error: ‘lambda’ was not declared in this scope
Hadamard_test.cpp:15: error: ‘val’ was not declared in this scope
Hadamard_test.cpp:15: error: ‘generate’ was not declared in this scope
Hadamard_test.cpp:17: error: ‘arg2’ was not declared in this scope
Hadamard_test.cpp:17: error: ‘transform’ was not declared in this scope

Plus can you explain a little what it does because notation-wise, it is very confusing for me. Definitely ignorance frommy side but I would appreciate if you describe it a little bit.

Thanks,
Kaveh


From: Kim Kuen Tang <kuentang@vodafone.de>
To: ublas mailing list <ublas@lists.boost.org>
Sent: Tuesday, May 26, 2009 3:17:45 PM
Subject: Re: [ublas] question regarding elementwise matrix product

Hi Kaveh,

hth:

# include <boost/numeric/ublas/symmetric.hpp>
# include <boost/numeric/ublas/io.hpp>
# include <boost/spirit/include/phoenix.hpp>

# include <vector>
# include <algorithm>

using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace boost::numeric::ublas;

int main () {

  symmetric_matrix<double,lower> m(3, 3), n(3,3), u(3,3);
  generate(arg1, lambda[val(1.0)] )(m.data());
  generate(arg1, lambda[val(2.0)] )(n.data());
  transform(arg1,n.data().begin(),u.data().begin(),lambda[arg1/arg2])(m.data());

  std::cout << u << std::endl;
}

Best regards,
Kim

Kaveh Kohan schrieb:
> Hi everybody,
>
> Would you please somebody tell me what is the most efficient way to do element-wise matrix multiplication or division? I guess using the iterator is the most efficient way but is there any cache issue or something like that? This kind of matrix product is Hadamard matrix product. Some blas vendors like sgi has optimized version of blas in which Hadamard product is implemented:
>
> http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/p_man/cat3/SCSL/DHAD.z <http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/p_man/cat3/SCSL/DHAD.z>
>
> I was wondering can ublas interface with those of course with some scarification on performance or it is not possible? If it is not possible what is the best approach to perform Hadamard product or element-wise matrix product.
>
>
> Regards,
> Kaveh
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ublas mailing list
> ublas@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/ublas


_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas