
Ublas : 
Subject: Re: [ublas] Question/request for matrix powers and other stuff
From: Daryle Walker (darylew_at_[hidden])
Date: 20081021 10:30:13
On Sep 29, 2008, at 5:45 PM, Gunter Winkler wrote:
> 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 typebased 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 noninvertible 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:
If it's so complicated, isn't that more reason to centralize the
routine so a bunch of people don't try and fail to write the function
effectively?
> template < class M >
> M power(const matrix_expression<M>& A, unsigned int n)
> {
> ... squareandmultiply ...
> }
>
>> 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 bitmatrix, 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.
Well, I originally had such a compact matrix type. But I realized
that a GF(2) matrix type is not the focus of my work, so I should
just do the minimum that works and optimize later. I just need to
know if the uBLAS vectors and matrices will work on any ring/field
type, even if it's not representative of real or complex numbers.
> maybe the boost::dynamic_bitset is a good starting point.
Maybe I'll try that later.
 Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com