bugGNU Octave - Bugs: bug #38684, embedded.cc demo of apendix A.3...

 
 

bug #38684: embedded.cc demo of apendix A.3 from manual gives an error

Submitter:  A.R. Burgers <arb>
Submitted:  Mon 08 Apr 2013 06:52:44 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.6.4 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 09 Apr 2013 11:18:01 PM UTC, comment #3: 

I backported the working example from 3.7.2+ to the stable branch (http://hg.savannah.gnu.org/hgweb/octave/rev/27a6bb1a2f74).  The fix will show up in 3.6.5 if there is another stable release or in 3.8.0 if the version number is incremented.

Rik <rik5>
Group administrator
Tue 09 Apr 2013 06:51:36 AM UTC, comment #2: 

The embedded.cc in 3.6.4 manual seems to be outdated.
It is corrected in 3.7.2+ (development source) manual.


embedded.cc in 3.7.2+ (development source) manual

#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>

int
main (void)
{
  string_vector argv (2);
  argv(0) = "embedded";
  argv(1) = "-q";

  octave_main (2, argv.c_str_vec (), 1);

  octave_idx_type n = 2;
  octave_value_list in;

  for (octave_idx_type i = 0; i < n; i++)
    in(i) = octave_value (5 * (i + 1));

  octave_value_list out = feval ("gcd", in, 1);


  if (!error_state && out.length () > 0)
    std::cout << "GCD of ["
              << in(0).int_value ()
              << ", "
              << in(1).int_value ()
              << "] is " << out(0).int_value ()
              << std::endl;
  else
    std::cout << "invalid\n";

  return 0;
}


The above works correctly under 3.6.4.

Tatsuro MATSUOKA <tmacchant>
Mon 08 Apr 2013 10:04:58 PM UTC, comment #1: 

The problem is that the underlying function that is called, gcd, no longer accepts a matrix as input.

The correct resolution for this is to rewrite embedded.cc to use a different function so we can still demonstrate the construction of a matrix and the use of feval.

Rik <rik5>
Group administrator
Mon 08 Apr 2013 06:52:44 PM UTC, original submission:  

The embedded.cc demo build fine, but reports an error on execution.

$ mkoctfile --link-stand-alone embedded.cc -o embedded

user@P7028 ~/tmp
$ ./embedded
GCD of [10, 15] is error: Invalid call to gcd.  Correct usage is:

 -- Loadable Function: G = gcd (A1, A2, ...)
 -- Loadable Function: [G, V1, ...] = gcd (A1, A2, ...)





A.R. Burgers <arb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #27812:  embedded.cc added by arb (898B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arb (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-04-09 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2013-04-08 rik5 Item GroupIncorrect Result Documentation
        StatusNone Confirmed
    2013-04-08 arb Attached File- Added embedded.cc, #27812

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code