Re: [eigen] An insistent plea for an input operator |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] An insistent plea for an input operator
- From: Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>
- Date: Tue, 20 Jul 2010 16:06:48 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=41FzyFkNYSBHnIPbdm2aesETsc5QxBI12lgBGYOE/FQ=; b=TpAe5imnpAJL3LTg0rn6jplIXP8fZ4ps/RE+6+t61ZQ7WEqfQycqv6CFudqGN8TASU aJMvm+Eio/nXvYY0DuDr2zcDzcmR7/IULO9lm8sRvIro4UFoOBVPjFRw9O2wyZrHkPVJ 4erJaYIij79PWb7btdJjy1LRqZCsEiSdjptxQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=wDO+s5xXH6t6gnPeXvAQe4zjd5cEbLk9zIdxgxXsnUNXnBIk0ri+p1gEwmevYcM4iK jZ8s5QoCcO4sydHgJYOwt4+fLJksQ45j73Gi8q6apSuPz8pE5MGsc33I/Dg90555iBP5 hHwotl6pvZK8SXpgi3hwMA/Ls0tttpCdwYsxE=
I am not a big fan of this mainly due to safety reasons and
consistency reasons.
Currently, you can even use an ifstream since it is an istream. We
also need to deal with the way in which the data is given. Why should
it be given as 1 2 3 4 ... and not 1,2,3,4 (probably because of the
locale, see my next point).
Also, I am not sure how this is going to work with floats on different
locals. Some systems have '.' as their decimal separator and others
','. You don't recognize this when working in C++ but I think you
will, when you start processing user input.
For me, the inclusion of such an operator must at least be optional,
i.e. not automatically through Dense, Core or Eigen. If it were in the
Eigen namespace, how would I provide my own version? Does it have to
go to another namespace?
- Hauke
On Tue, Jul 20, 2010 at 3:41 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> I'm ok to add it, I cannot see how it could block us in the future to
> support more sophisticated input format.
>
> gael
>
> On Tue, Jul 20, 2010 at 2:48 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
>> ok, my biggest objection was that getting general input right is hard,
>> and that we must then get the API right; but I can agree that in any
>> case we'll end up supporting the very simple stream format that your
>> operator>> is supporting. So, why not.
>>
>> Others?
>>
>> Benoit
>>
>> 2010/7/20 Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>:
>>> Hi,
>>>
>>> I know, I've asked for this feature several month, ago,
>>> but I'm obstinate to ask for it again and again.
>>>
>>> Background: I'm teaching C++ for beginners (mathematicians) and
>>> there should be an easy input operator for matrices and vectors.
>>>
>>> Currently, I have to patch Eigen (2 or 3) by adding
>>>
>>> namespace Eigen {
>>> template<typename Derived>
>>> std::istream & operator >>(std::istream & Inp, MatrixBase<Derived> & m)
>>> {
>>> for (int i = 0; i < m.rows(); ++i)
>>> for (int j = 0; j < m.cols(); j++)
>>> Inp >> m(i,j);
>>>
>>> return Inp;
>>> }
>>>
>>> }
>>>
>>> to make the following simple program run
>>>
>>>
>>> int main() {
>>> Eigen::MatrixXi A(2,3);
>>> std::cerr << "intput 2x3 matrix:\n";
>>> std::cin >> A;
>>> std::cout << "I've got:\n" << A << std::endl;
>>> }
>>>
>>> I've never understood the objections against adding this.
>>> Pardon for being such obstinate,
>>> Helmut.
>>>
>>> My problem is, that students download Eigen themselves and forget about
>>> adding these few lines.
>>>
>>> --
>>> Helmut Jarausch
>>>
>>> Lehrstuhl fuer Numerische Mathematik
>>> RWTH - Aachen University
>>> D 52056 Aachen, Germany
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>