Boost logo

Ublas :

Subject: Re: [ublas] Fast small matrices / homogeneous matrices with uBlas
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2010-08-09 08:21:39


Riccardo,
Excluding product (*) and division (/) operators I suppose it would work, as it already does. If matrix product is implemented with operator * overloading, this would be working also.

I don't know though how this can be interpreted, and atm I doubt it can be cast to a full matrix (it can be converted though). I think the fixed matrix container should allow a cast to a block matrix.What do you have in mind, some kind of algebra, or block matrix construction of some sort?

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

using namespace boost::numeric::ublas;

int main(int argc, char *argv[])
{
    matrix<matrix<double> > AA(3,3), BB(3,3); // or matrix<matrix<double> > AA(3,3,0), BB(3,3,0);

    matrix<double> CC(3,3);
    for (unsigned int i=0; i!=3; i++)
        for (unsigned int j=0; j!=3; j++)
            CC(i,j) = i + j + 1 + i*j;

    std::cout << CC << std::endl;

    AA(0,0)=CC;
    AA(1,1)=CC;
    AA(2,2)=CC;
    
    std::cout << AA << std::endl;

    for (unsigned int i=0; i!=3; i++)
        for (unsigned int j=0; j!=3; j++)
            CC(i,j) = 2*i + 0.1*j + 0.75 + i*j*i*0.22;

    BB(0,0)=CC;
    BB(1,1)=CC;
    BB(2,2)=CC;

    std::cout << BB << std::endl;
    std::cout << AA+BB << std::endl;

    return 0;
}

Best
Nasos

> From: rrossi_at_[hidden]
> To: ublas_at_[hidden]
> Date: Mon, 9 Aug 2010 13:24:04 +0200
> Subject: Re: [ublas] Fast small matrices / homogeneous matrices with uBlas
>
> Dear Nasos,
>
> just to add my cent to the discussion ... do you believe there is
> any hope that the tiny matrix and vectors can be used as "scalar types"
> in the construction of matrices and vectors?
>
> for example
> matrix < TinyMatrix<3,3> >
>
> i know there was long ago a discussion on this issue, but i guess the
> new design would give the right opportunity to think about this
> possibility...
>
> anyway
> thank you for the attention
> Riccardo
>
> --
> ________________________________________________________________
> Riccardo Rossi, Ph.D, Civil Engineer
> member of the Kratos Group: kratos.cimne.upc.es
> Centro Internacional de Métodos Numéricos en Ingeniería (CIMNE)
> Universidad Politécnica de Cataluña (UPC)
> Edificio C-1, campus Norte UPC
> Gran Capitan, s/n
> 08034 Barcelona, España
> Tel. (+34) 93 401 73 99
> ________________________________________________________________
>
> AVISO IMPORTANTE
>
> Los datos de carácter personal contenidos en el mensaje, se registrarán
> en un fichero para facilitar la gestión de las comunicaciones de CIMNE.
> Se pueden ejercitar los derechos de acceso, rectificación, cancelación y
> oposición por escrito, dirigiéndose a nuestras oficinas de CIMNE, Gran
> Capitán s/n, Edificio C1 - Campus Norte UPC, 08034 Barcelona, España.
>
> AVÍS IMPORTANT
>
> Les dades de caràcter personal contingudes en aquest missatge es
> registraran en un fitxer per facilitar la gestió de les comunicacions
> del CIMNE. Es poden exercir els drets d'accés, rectificació,
> cancel·lació i oposició, per escrit a les nostres oficines del CIMNE,
> Gran Capità s/n, Edifici C1, Campus Nord UPC, 08034 Barcelona, Espanya.
>
> IMPORTANT NOTICE
>
> All personal data contained in this mail will be processed
> confidentially and stored in a file property of CIMNE in order to manage
> corporate communications. You may exercise the right of access,
> rectification, deletion and objection by letter sent to CIMNE, Gran
> Capitán, Edificio C1 - Campus Norte UPC, 08034 Barcelona, Spain.
>
>
>
>
>
> On Mon, 2010-08-09 at 07:20 -0400, Nasos Iliopoulos wrote:
> > Thomas,
> > There is an active discussion and a proposal that will bring fixed
> > vector and fixed matrices (appropriate for small containers) into
> > uBlas. My feeling is that it is getting to a good shape and will
> > probably make it into the next release. Follow this post for some
> > code:
> >
> > http://lists.boost.org/MailArchives/ublas/2010/07/4500.php
> >
> > > And secondly, it cannot use the matrices structure such as the fact
> > > that the last line of an homogenous
> > > matrix never changes.
> >
> > Although this is the case with some applications (and even some
> > graphics API providers, like AMD), there are applications that fixing
> > the last row is not desirable (i.e. when you do projections and expect
> > to use the w component of your 4 vector prior to perspective
> > division). I suppose uBlas will support fixed containers in the
> > future, but I find unlikely that it will make any assumptions like
> > homogeneity (in which case you just need to divide by the last
> > element, if you mean to retrieve 3D points).
> >
> > Best
> > Nasos
> >
> >
> > > Date: Mon, 9 Aug 2010 11:32:27 +0900
> > > From: thomas.moulard_at_[hidden]
> > > To: ublas_at_[hidden]
> > > CC: fbleibel_at_[hidden]; florent_at_[hidden]
> > > Subject: [ublas] Fast small matrices / homogeneous matrices with
> > uBlas
> > >
> > > Hello everyone,
> > > I am currently evaluating the possibility for uBlas to have a better
> > > support for small matrices.
> > > In particular, 3d transformation matrices represented by homogenous
> > matrices.
> > >
> > > First, I have seen that uBlas is slower than libraries specifically
> > > targeted for small matrices like tvmet.
> > > And secondly, it cannot use the matrices structure such as the fact
> > > that the last line of an homogenous
> > > matrix never changes.
> > >
> > > I was wondering if anyone here would have tried to tackle these
> > problems?
> > >
> > > Any advice would be greatly appreciated,
> > > --
> > > Thomas Moulard
> > > _______________________________________________
> > > ublas mailing list
> > > ublas_at_[hidden]
> > > http://lists.boost.org/mailman/listinfo.cgi/ublas
> > > Sent to: nasos_i_at_[hidden]
> > _______________________________________________
> > ublas mailing list
> > ublas_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/ublas
> > Sent to: rrossi_at_[hidden]
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: nasos_i_at_[hidden]