Boost logo

Ublas :

Subject: [ublas] Matrix Multiplication with Different Result Type
From: Tynan Wilke (tynan.wilke_at_[hidden])
Date: 2010-05-28 14:12:13


I'm trying to get the following code to compile, but am running into
problems which I believe stem from using a different result type than the
types of the matrices being multiplier together. If I "typedef A C" in the
below example, the code compiles fine.

Any hints/suggestions on getting this to compile are greatly appreciated.



namespace ub = boost::numeric::ublas;

struct A {
    A() {}
    A(int) {}
struct B {};
struct C {};
//typedef A C;

// For matrix multiply *
C operator*(const A &a, const B&b) {
    // noop

// For matrix multiply +
C operator+(const C &c1, const C &c2) {
    // noop

// For matrix multiply +=
C operator+=(C &c1, const C &c2) {
    // noop

// Needed for promote_traits<A, B> for result_type (I think)
C operator+(const A &a, const B &b) {
    // noop

int main() {
    ub::matrix<A> mxA(1, 3);
    ub::matrix<B> mxB(3, 3);
    ub::matrix<C> mxC = prod(mxA, mxB);