Boost logo

Ublas :

Subject: Re: [ublas] Question/request for matrix powers and other stuff
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2008-09-29 17:45:27


Am Freitag, 26. September 2008 09:22 schrieb Daryle Walker:
> 1. I looked around at the Boost uBLAS documentation for this but I
> couldn't find it. Is there a "pow" function or similar that can
> return a given integer power of a square matrix? (It could use
> binary exponentiation to do its work. The exponent could be a type
> given as a type-based template parameter and checked with traits. If
> the exponent value is negative, then find the inverse of the matrix
> and work from there, generating an error of non-invertible matrices.)

Computing an integer power of a matrix efficiently requires an quite
involved algorithm. Thus we decided that uBLAS does not need such a
feature. However it should not be too difficult to write such a
function for positive exponents:

template < class M >
M power(const matrix_expression<M>& A, unsigned int n)
{
   ... square-and-multiply ...
}

> 2. Is there a matrix type with Boolean elements? I worked around
> that my making my own GF(2) representation type and using it with the
> uBLAS class templates. Is using a type that doesn't represent real
> or complex numbers supported? I wonder if there could be such GF(2)
> vector and matrix types, maybe the elements can be compacted into
> single bits.

Actually the target data type for uBLAS is float or double. In order to
provide an efficient implementation of a bit-matrix, one had to create
a new bit_array type, define * and + for bits and slightly modify the
mapping of an index to a storage location.

maybe the boost::dynamic_bitset is a good starting point.

mfg
Gunter