[Top][All Lists]

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

DLF - returning transposed vector

From: John W. Eaton
Subject: DLF - returning transposed vector
Date: Wed, 24 Jun 1998 00:15:32 -0500 (CDT)

On 24-Jun-1998, Wonkoo Kim <address@hidden> wrote:

| I want to return a row or column vector depending on the vector 
| type of an argument to my DLF (dynamically linked function).
| I declared "ColumnVector y ..." and then computed for y values.
| When returning y to the caller, I wanted to transpose if an input 
| argument was a row vector.  But the following always returned a column
| vector.  I confirmed that 'if' branched correctly according to the 
| input vector type, but either returned the same column vector.  
| What was wrong?  
|     ColumnVector x = args(0).vector_value();
|     ColumnVector y (Ny, 0.0);
|     ...
|     ...
|     if (args(0).matrix_value().cols() > 1) {
|         return octave_value (y.transpose());
|     } else {
|         return octave_value (y);
|     }


  return octave_value (y, args(0).rows() > 1);

instead.  When constructing an octave_value object from a row or
column vector, you can force the result to be a column vector by
providing a second integer argument with a value greater than 0.  If
the value of the second argument is equal to zero, a row vector is
returned.  If the value of the second argument is less than zero, or
if it is missing, the constructor uses the value of the built-in
variable prefer_column_vectors to decide what orientation a row or
column vector should actually have.  Probably this was not really the
best design decision, but that's the way things are currently


reply via email to

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