[Top][All Lists]

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

DLF - function call (2)

From: Wonkoo Kim
Subject: DLF - function call (2)
Date: Thu, 25 Jun 98 05:24:31 -0400

Sorry for another question. (Octave C++ class lib is wonderful, but
I have yet to learn many things.)

In a DLF file, I want to define a function foo() to be called in the 
main DLF.  I want to pass either a row or a column vector to foo() from 
the main DLF code, and I want a return value of the same vector type.
Say Y = foo(X), where both X and Y should be row vectors, otherwise
both column vectors.  I thought either 
  ColumnVector foo(const ColumnVector &x)
  RowVector foo(const RowVector &x)
would fail for the other vector type.  However, in my tests,
there seem to be less limitation on vector types.

I thought (ColumnVector + RowVector) would be a nonsense, but the
following worked without errors:
  ColumnVector x = ...;
  RowVector y = ...;
  ColumnVector z = x + y;

It seems like I don't have to worry about vector types in many 
operations or in function arguments or return values.  Is this
correct?  Are variables promoted (changed) to either row or column
vectors before an operation if types are mismatched?  (Of course, 
I know an assignment sets the data type, but couldn't imagine an
addition of row and column vectors would be possible without
transposing or type casting.)  If so, it would be handy when I write
DLFs and functions as I don't have to transpose to match vector types
in many cases.


// Wonkoo Kim (address@hidden)

reply via email to

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