help-octave
[Top][All Lists]
Advanced

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

Rows in DLD functions


From: John W. Eaton
Subject: Rows in DLD functions
Date: Tue, 11 Jan 2000 23:27:04 -0600 (CST)

On 11-Jan-2000, Ben Sapp <address@hidden> wrote:

| Can any one tell me why the following DLD function prints a row vector
| but returns a column vector?   I think it should print and return a
| column vector.  Can you also tell me how I can return a Row vector
| instead of a column vector?   
| 
| rowvec_test.cc
| -------------------------------------------------------------------
| #include <octave/oct.h>
| #include <octave/pager.h>
| 
| DEFUN_DLD(rowvec_test,args, , "\nRow vector test\n"){
| 
|   RowVector the_row = args(0).vector_value();
|   octave_stdout << "The Row vector = \n" << the_row << "\n";
|   return octave_value(the_row);
| }
| -------------------------------------------------------------------
| 
| Run it from octave like this:
| 
| v = [ 1 2 3];
| rowvec_test(v)

I think this is a design bug, but it was not too hard to fix, so in
the current CVS sources (and soon in the next bleeding-edge tar file),
you can write

  #include <octave/oct.h>
  #include <octave/pager.h>

  DEFUN_DLD (rowvec_test, args, ,
   "Row vector test")
  {
    RowVector the_row = args(0).row_vector_value();
    octave_stdout << "The Row vector = \n" << the_row << "\n";
    return the_row;
  }

and have it do what you probably expect.

jwe



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

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



reply via email to

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