On 24Jun1998, Wonkoo Kim <
[hidden email]> 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);
 }
Try
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 builtin
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
implemented.
jwe