view examples/embedded.cc @ 14690:ca733a66be7a gui

Fixed bug with not opening the editor when clicking a file from the file browser. Implemented watching the file on disk. * MainWindow: Simplified opening file request calls. * FileEditor: Added new slot that closes tabs without and index and made FileEditorTabs connect to it. * FileEditorTab: Added QFileSystemWatcher and fixed bug with setting modified status on m_modified. Implemented message boxes for the cases that a file has been removed, renamed und modified from outside.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Fri, 25 May 2012 23:56:31 +0200
parents db1f49eaba6b
children 3c5e6971064c 27a6bb1a2f74
line wrap: on
line source

#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;
  Matrix a_matrix = Matrix (1, 2);

  std::cout << "GCD of [";
  for (octave_idx_type i = 0; i < n; i++)
    {
      a_matrix (i) = 5 * (i + 1);
      if (i != 0)
        std::cout << ", " << 5 * (i + 2);
      else
        std::cout << 5 * (i + 2);
    }
  std::cout << "] is ";

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

  if (!error_state && out.length () > 0)
    {
      a_matrix = out(0).matrix_value ();
      if (a_matrix.numel () == 1)
        std::cout << a_matrix(0) << "\n";
      else
        std::cout << "invalid\n";
    }
  else
    std::cout << "invalid\n";

  return 0;
}