|Re: [eigen] documentation|
[ Thread 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.
or (in this case) simply
Eigen::Matrix<double,Dynamic,Dynamic> eMat(n, n);
for (int i=0; i<n; i++)
for (int j=0; j<n; j++)
This does not work. To access element (i,j) use eMat(i,j).
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:
This page has a bit more information:
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
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
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:
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:
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
Not sure what you mean by that question. You can basically use copy
constructors and assignment operators intuitively.
Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Tel: +49 (421) 218-64252