Re: some questions about mtl
"Paul C. Leopardi" <[email protected]>
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <[email protected]> |
Zhang Yan,
The following code for kron is derived from GluCat ( http://glucat.sf.net )
It is quite short, so I have included it inline.
Best regards
/// Kronecker tensor product of matrices - as per Matlab kron
template< class M >
void
kron(const M& x, const M& y, M& z)
{
const int rx = x.nrows();
const int cx = x.ncols();
const int ry = y.nrows();
const int cy = y.ncols();
z = M(rx*ry, cx*cy);
mtl::set(z, 0);
for ( typename M::const_iterator i =cx.begin();
i != x.end(); ++i)
for ( typename M::Row::const_iterator j = (*i).begin();
j != (*i).end(); ++j)
for ( typename M::const_iterator k = y.begin();
k != y.end(); ++k)
for (typename M::Row::const_iterator l = (*k).begin();
l != (*k).end(); ++l)
z(j.row()*ry + l.row(), j.column()*cy + l.column()) = (*j) * (*l);
}
On Tue, 3 Dec 2002 21:31, #ZHANG YAN# wrote:
> First of all, many thanks for the sharing of great MTL. In using the
package, I found that the library does not support kronecker product/sum, is
this right? and I will be appreciated if you could please show me where I can
find related library.
_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/