[Top][All Lists]

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

DLFs and C++ classes.

From: John W. Eaton
Subject: DLFs and C++ classes.
Date: Tue, 7 May 2002 11:15:52 -0500

On  7-May-2002, Sven Khatri <address@hidden> wrote:

| This may be a silly question and I think this is the right forum --
| Anyhow I'm trying to build a DLF with a variable that is a
| ColumnVector of ints and constructed from one of the args passed
| by octave. How do I do this

You can't make a ColumnVector of ints (ColumnVectors are doubles).
You can make an Array<int> object, but you have to do it by hand.
Something like

  DEFUN (foo, args, nargout,
    "foo doc string")
    octave_value_list retval;

    // ...

    Array<double> tmp (args(0).vector_value ());

    if (error_state)
        error ("some useful message if arg conversion failed");
        return retval;

    int n = tmp.length ();
    Array<int> itmp (n);
    for (int i = 0; i < n; i++)
        // Maybe check to see that integer values were really passed in?
        // Maybe you'd like to round to nearest?  If so, see NINT,
        // declared in lo-utils.h.
        itmp(i) = static_cast<int> (tmp(i));

    // ...

    return retval;

But maybe there should be

  Array<int> int_array_value (...) const;
  Array<int> nint_array_value (...) const;

member functions in the octave_value class?  (Contributions welcome.)

| Is there decent documentation on
| the C++ classes provided by octave or should I go read the 
| source code?

The latter.



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

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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