Re: [eigen] documentation

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 22.11.2014 09:26, Mathieu Dutour wrote:
Q1: How to write a function that returns a matrix?
the following code does not compile:
Eigen::Matrix<double> HilbertMatrix(int const& n)
  ^-------------------^
That's not a valid Eigen type. You have to specify the dimension at compile time (which can be Dynamic,Dynamic), as you did two lines below.
  Eigen::Matrix<double,Dynamic,Dynamic>
or (in this case) simply
  Eigen::MatrixXd

{
   Eigen::Matrix<double,Dynamic,Dynamic> eMat(n, n);
   for (int i=0; i<n; i++)
     for (int j=0; j<n; j++)
       eMat[i][j]=double(1)/(double(i+j+1));
             ^----^
This does not work. To access element (i,j) use eMat(i,j).

   return eMat;
}

Q2: What is the list of individual operations? I imagine
inverses function should be different between a floating
point type and an exact number theoretic type. How can
I acces exact inverse functions?

Here is a list of most operations:
  http://eigen.tuxfamily.org/dox/AsciiQuickReference.txt
This page has a bit more information:
  http://eigen.tuxfamily.org/dox/group__QuickRefPage.html

We don't have specialized methods for exact/number theoretic types at the moment. LU-decomposition should work out-of-the box (I assume). For other things, contributions are welcome
http://eigen.tuxfamily.org/index.php?title=Contributing_to_Eigen

Q3: For the number theoretic operations, the technique
is to do Gauss rows and columns operations. I understand
Gauss elimination is out of consideration for floating
point operations. But for number theory this is what is

Gauss elimination (or LU decomposition) with full pivoting is in many cases the method of choice for floating point operations -- and that is what .inverse() uses internally.

needed. Can we have access to operation like
  Ci <----- >Ci - a Cj ?

If you want to manipulate your matrix manually, you can directly do things like:
  C.row(i) -= a* C.row(j);
The same is possible with col(i), of course. Pay attention when mixing row() with col():
  C.row(1) = C.col(0);  // Possible aliasing effects!

Q4: I sometimes need higher dimensional containers.
I wrote one inspired by "MyMatrix". Is there something
similar in Eigen? I guess no, just asking.

There is the (unsupported) Tensor module in the dev-branch:

http://eigen.tuxfamily.org/dox-devel/unsupported/group__CXX11__Tensor__Module.html


Q5: There are many examples of use eigen in the code
but they are all more or less of the same kind.
    a) Could we get examples that use template parameters?
double and float are fine but that is not what all there is

Look here on how to use custom types:
http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html#title2

    b) Could we get examples with variable matrix size?

There are lots of examples with dynamic sized matrices. Most of the time the usage is not too different from fixed sized matrices.

    c) Could we get use of copy constructors and assignment
operators?

Not sure what you mean by that question. You can basically use copy constructors and assignment operators intuitively.


Christoph

--
----------------------------------------------
Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252
----------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/