help-octave
[Top][All Lists]
Advanced

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

Re: Appending to a ColumnVector


From: Søren Hauberg
Subject: Re: Appending to a ColumnVector
Date: Fri, 03 Jun 2005 17:43:17 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050404)

Hi, sorry about the late reply...

John W. Eaton wrote:
On 25-May-2005, Søren Hauberg wrote:

| Michael Creel wrote:
| [snip]
| > From | > http://pareto.uab.es/mcreel/OctaveClassReference/html/classColumnVector.html | > there is the entry
| > ColumnVector ColumnVector::stack   (   const ColumnVector &   a    )    
const
| > which looks like it might help. I don't see any resize_and_fill operation | > anywhere - does this work with more or less current versions of Octave?
| > M.
| I'm assuming that stack concatenates two ColumnVectors, which seems a | bit overkill since I simply want to append one value. The function | resize_and_fill is part of the Array class, so ColumnVector inherits | this operation.

There should probably also be functions like

  ColumnVector ColumnVector::append (double val) const;
I'm not very familiar with C++ (I'm a C-man) but shouldn't this return a ColumnVector& ?
  ColumnVector& ColumnVector::append (double val);
Anyway, as I'm not really used to working with the "core" of Octave, I have to ask: Is this what you're looking for?

ColumnVector&
ColumnVector::append (const double val)
{
  const int len = length();
  ColumnVector &c = *new ColumnVector(len+1);

  for (int i = 0; i < len; i++)
    c(i) = xelem(i);

  c(len) = val;
  return c;
}

/Søren

Likewise for RowVector.  P
erhaps also a prepend function.

Would you like to provide a patch?

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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