From: Robert Baron on
On Tue, May 6, 2008 at 1:14 PM, H.S. <hs.samix(a)gmail.com> wrote:

> Jordi GutiƩrrez Hermoso wrote:
>
> > On 06/05/2008, H.S. <hs.samix(a)gmail.com> wrote:
> >
> > > In a C++ program I am reading a data file for later processing and
> > > computations. While reading that data file, I want to keep track of
> > > data
> > > items (doubles) read.
> > >
> >
> > Use std::list and other standard data structures.
> >
>
> I am using them where ever I can. In this case however, I am using the
> data with ARPACK libraries and need to put it in a FORTRAN style 2D array..
> Everywhere else though, I am using C++ STL.
>
> It's C++. Don't use C arrays, ugh.
> >
> > If you are comfortable with IRC, I find that ##c++ on Freenode is full
> > of bright people.
> >
> > And what does this have to do with Debian?
> >
>
> er .. ahem .. yeah, sorry about that, should have had OT in the subject.
> But now that you mention this, let me explain a bit why I did not post it in
> C++ newsgroup. If you have visited that, it is full of people who want to
> discuss only the standard. I have had that experience, so gave it a shot
> here.
>
> Will try the IRC. Thanks,
> ->HS
> PS: I just put "OT" in the subject line.


What is so terrible about counting the items as they come in?

The other way to do it is to count up the items in the 2d array (and it
shouldn't matter if it is ..., well whatever).

Trivial.

Rob.
From: H.S. on
Robert Baron wrote:

>
> What is so terrible about counting the items as they come in?


As I mentioned earlier, the issue is how do I count items read in one
line, or before the next EOL? Counting total items is not a problem.

Perhaps a different way to say this is, how do I detect if I have
reached an EOL while reading doubles from a file stream.




--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Jordi GutiƩrrez Hermoso on
On 06/05/2008, H.S. <hs.samix(a)gmail.com> wrote:
> APRACK FORTRAN library needs the input data in a 2D array (the arrays need
> to be arranged in column-major format). But, to answer your query, I don't
> *have* to read it in an array, I could read it in a list and then copy it to
> an array before I call ARPACK routines.

Btw, C++ provides std::valarray precisely with Fortran-like matrices
in mind. However, it seems this is the black sheep of the C++ stdlib,
since it seems C++ implementations are unable to optimise
std::valarray as much as intended (I've never really understood the
details), and I've never seen any project use std::valarray at all.
:-/

But anyways, valarrays store data precisely in the numeric formats
that Fortran expects.

On 06/05/2008, Mark Allums <mark(a)allums.com> wrote:
> (And is also an example of something that is wrong with the C++ standard
> library, when you need the c_str() member of string so often to get any real
> useful work done. Kind of defeats the purpose of having string in the first
> place.)

Yeah, that's because historically the stream classes were written
before the string class. :-/

That's scheduled to be fixed in C++0x. I wish the GNU implementation
of C++ already fixed it, since they do have other fixes (e.g. defining
at() for std::map which is technically non-standard but completely
reasonable).

On 06/05/2008, Mark Allums <mark(a)allums.com> wrote:
> But I would rather statically link to stdio than to iostream

Although it's true that sometimes the C++ Hello World seems bloated to
the C Hello World, the difference becomes negligible in any project of
considerable size beyond Hello World. Embedded devices may be a
different thing, and I understand that it's allowable and encouraged
to write the hackiest code in embedded devices, even liberally
sprinkling your C code with ASM.

So I hear, so I hear...

- Jordi G. H.


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Michael Marsh on
On Tue, May 6, 2008 at 1:50 PM, H.S. <hs.samix(a)gmail.com> wrote:
> As I mentioned earlier, the issue is how do I count items read in one line,
> or before the next EOL? Counting total items is not a problem.
>
> Perhaps a different way to say this is, how do I detect if I have reached
> an EOL while reading doubles from a file stream.

Can you read full lines out into, eg, a stringstream, and parse your
doubles out of that? You'd hit an EOF at the end of each line in that
case. I'm not sure how you'd get stream out line-at-a-time, though
there may be a stream operator that sets the appropriate behavior.

Just a random idea off the top of my head.

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
http://36pints.blogspot.com


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
From: Ron Johnson on
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/06/08 12:50, H.S. wrote:
> Robert Baron wrote:
>
>>
>> What is so terrible about counting the items as they come in?
>
>
> As I mentioned earlier, the issue is how do I count items read in one
> line, or before the next EOL? Counting total items is not a problem.
>
> Perhaps a different way to say this is, how do I detect if I have
> reached an EOL while reading doubles from a file stream.

Is this a binary file or a text file?

- --
Ron Johnson, Jr.
Jefferson LA USA

We want... a Shrubbery!!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIIJ4uS9HxQb37XmcRAjSqAKCLE6X+D5GA0GbuHl04JuhDVMQ1SACfcYzk
3/cqC9ntXmxUBk8Y2SuLCQ8=
=uwVN
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org