Boost logo

Ublas :

Subject: Re: [ublas] [uBlas] Fastest way to change sing of matrix
From: Rhys Ulerich (rhys.ulerich_at_[hidden])
Date: 2013-04-16 09:51:24


> I didn't say anything about the type, I would expect a single way to be
> fastest for all matrix types.

The quickest way I can imagine would be to carry around a scalar, e.g.
    double changesign = 1;
and then, if you need to negative your matrix, set
    changesign *= -1;
and then include changesign in some later multiplication or
accumulation operation. Presumably it could be rolled into some other
scalar multiplicative factor.

In this scheme, you pay exactly one FLOP regardless of the
type/size/anything of A.

- Rhys