|
Ublas : |
Subject: Re: [ublas] question regarding elementwise matrix product
From: Kaveh Kohan (kaveh.kohan_at_[hidden])
Date: 2009-05-28 15:26:06
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_at_[hidden]>
To: ublas mailing list <ublas_at_[hidden]>
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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
_______________________________________________
ublas mailing list
ublas_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/ublas