octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Graphics and memory opinions


From: Jaroslav Hajek
Subject: Re: Graphics and memory opinions
Date: Sun, 14 Dec 2008 19:34:45 +0100

On Sun, Dec 14, 2008 at 7:22 PM, Jordi Gutiérrez Hermoso
<address@hidden> wrote:
> 2008/12/14 Daniel J Sebald <address@hidden>:
>> John W. Eaton wrote:
>>>
>>> On 14-Dec-2008, Jordi Gutiérrez Hermoso wrote:
>>>
>>> | Right, std::list triples the storage size. Clearly std::deque or
>>>
>>> I don't see how a deque helps, it is just another variant of a list, with
>>> overhead for each element.
>>>
>>> | std::vector are the ones to use here.
>>>
>>> Then you will just have to copy them into an Octave Array<> object. So why
>>> not just use that to begin with?  If you are going to use an array/vector
>>> object then trick is efficiently approximating the the size of the matrix so
>>> you can minimize the number of times you have
>>> to resize and copy.
>>>
>>> | Give me a clue on what function I should play with... It is |
>>> read_ascii_data(...), right?
>>>
>>> Look at the functions in ls-mat-ascii.cc.
>>
>> Yeah, this can't be very fast.  Things are done one character at a time.
>>  That's taking the object oriented paradigm to too granular of a level.
>>  (OOP is great, but...)  In particular
>
> I don't think C++ or OOP are to blame here. I have implemented reading
> matrices from ASCII files in my own code using std::list op>> for
> matrices[1], using as much of the stdlib as I could, and it's
> reasonably fast, quite faster than current Octave, and probably I
> could make it faster if I used std::vector instead of std::list.
> Things like stringstreams can greatly help with the parsing, and it's
> not done one character at at time. Memory usage is a problem right now
> with my own code (because of std::list and because I create
> temporaries and copy them), but I think I can fix that too. I'm
> basically trying to think of how to transplant this idea to Octave.
>
> - Jordi G. H.
>
> [1] 
> http://inversethought.com/jordi/rbf-doc/namespacelinalg.html#7c9337265246bee3e732da05240af7dc
>
>

Just to add my 2 cents:
Maybe the best STL way to read a sequence of numbers of unknown length
into a vector (or other container) is:

vector<int> V;
copy(istream_iterator<int>(cin), istream_iterator<int>(),
     back_inserter(V));

I don't have the time now to look whether somthing like this can be
utilized for Octave, but stream iterators + standard algorithms are
usually worth considering.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]