changeset 4343:db5e0814277a

[project @ 2003-02-20 16:44:16 by jwe]
author jwe
date Thu, 20 Feb 2003 16:46:37 +0000
parents 813effe14ee1
children dc5f2b0d81cc
files configure.in doc/ChangeLog libcruft/ChangeLog libcruft/dassl/ddaslv.f src/ov-base.cc src/ov-base.h src/ov-fcn-handle.cc src/ov-fcn-handle.h src/ov-fcn.h src/ov-usr-fcn.cc src/ov-usr-fcn.h src/ov.cc src/ov.h src/parse.y src/pt-fcn-handle.cc src/pt-fcn-handle.h
diffstat 16 files changed, 519 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Thu Feb 20 08:35:55 2003 +0000
+++ b/configure.in	Thu Feb 20 16:46:37 2003 +0000
@@ -22,7 +22,7 @@
 ### 02111-1307, USA. 
 
 AC_INIT
-AC_REVISION($Revision: 1.412 $)
+AC_REVISION($Revision: 1.413 $)
 AC_PREREQ(2.52)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -419,6 +419,29 @@
   AC_DEFINE(HAVE_FFTW, 1, [Define if the FFTW library is available.])
 fi
 
+WITH_MPI=true
+AC_ARG_WITH(mpi,
+  [  --without-mpi           don't use MPI],
+  with_mpi=$withval, with_mpi=yes)
+
+mpi_lib=
+if test "$with_mpi" = yes; then
+  mpi_lib="mpi"
+elif test "$with_mpi" != no; then
+  mpi_lib="$with_mpi"
+fi
+
+MPI_LIBS=
+WITH_MPI=false
+if test -n "$mpi_lib"; then
+  AC_CHECK_LIB($mpi_lib, MPI_Init, [
+    AC_CHECK_HEADERS(mpi.h, [
+      WITH_MPI=true
+      MPI_LIBS="-l$mpi_lib"
+      LIBS="$MPI_LIBS $LIBS"
+      AC_DEFINE(HAVE_MPI, 1, [Define if MPI is available.])])])
+fi
+
 # ----------------------------------------------------------------------
 
 ### We need these before trying to find libf2c.
@@ -1409,6 +1432,7 @@
   BLAS libraries:       $BLAS_LIBS
   FFTW libraries:       $FFTW_LIBS
   HDF5 libraries:       $HDF5_LIBS
+  MPI libraries:        $MPI_LIBS
   LIBS:                 $LIBS
   Default pager:        $DEFAULT_PAGER
   gnuplot:              $GNUPLOT_BINARY
--- a/doc/ChangeLog	Thu Feb 20 08:35:55 2003 +0000
+++ b/doc/ChangeLog	Thu Feb 20 16:46:37 2003 +0000
@@ -1,3 +1,11 @@
+2003-02-19  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* interpreter/Makefile.in (MAN_BASE): Add octave-config.1 to the list.
+
+2003-02-19  Dirk Eddelbuettel <edd@debian.org>
+
+	* octave-config.1: New file.
+
 2003-01-11  Paul Kienzle <pkienzle@users.sf.net>
 
 	* interpreter/Makefile.in (munge-texi$(BUILD_EXEEXT)): Pass
--- a/libcruft/ChangeLog	Thu Feb 20 08:35:55 2003 +0000
+++ b/libcruft/ChangeLog	Thu Feb 20 16:46:37 2003 +0000
@@ -1,3 +1,7 @@
+2003-02-20  Paul Kienzle <pkienzle@users.sf.net>
+
+	* dassl/ddaslv.f: Fortran doesn't use ; in statements.
+
 2003-02-18  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* libcruft/blas/dtbsv.f: New file.
--- a/libcruft/dassl/ddaslv.f	Thu Feb 20 08:35:55 2003 +0000
+++ b/libcruft/dassl/ddaslv.f	Thu Feb 20 16:46:37 2003 +0000
@@ -56,7 +56,7 @@
 C     BANDED MATRIX
 400   MEBAND=2*IWM(LML)+IWM(LMU)+1
       CALL DGBTRS ('N', NEQ, IWM(LML), IWM(LMU), 1, WM(NPD), MEBAND, 
-     *     IWM(LIPVT), DELTA, NEQ, INLPCK);
+     *     IWM(LIPVT), DELTA, NEQ, INLPCK)
       RETURN
 C------END OF SUBROUTINE DDASLV------
       END
--- a/src/ov-base.cc	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov-base.cc	Thu Feb 20 16:46:37 2003 +0000
@@ -50,6 +50,7 @@
 #include "ov-re-mat.h"
 #include "ov-scalar.h"
 #include "ov-str-mat.h"
+#include "ov-fcn-handle.h"
 #include "variables.h"
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, "<unknown type>");
@@ -402,6 +403,17 @@
   return retval;
 }
 
+octave_fcn_handle
+octave_base_value::fcn_handle_value (bool silent)
+{
+  octave_fcn_handle retval;
+
+  if (! silent)
+    gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()",
+			  type_name ());
+  return retval;
+}
+
 octave_value_list
 octave_base_value::list_value (void) const
 {
--- a/src/ov-base.h	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov-base.h	Thu Feb 20 16:46:37 2003 +0000
@@ -211,6 +211,8 @@
 
   octave_function *function_value (bool silent);
 
+  octave_fcn_handle fcn_handle_value (bool silent);
+
   octave_value_list list_value (void) const;
 
   bool bool_value (void) const;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ov-fcn-handle.cc	Thu Feb 20 16:46:37 2003 +0000
@@ -0,0 +1,177 @@
+/*
+
+Copyright (C) 2003 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
+#pragma implementation
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+#include "defun.h"
+#include "oct-map.h"
+#include "ov-base.h"
+#include "ov-fcn-handle.h"
+#include "pr-output.h"
+#include "variables.h"
+
+DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle);
+
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, "function handle");
+
+void
+octave_fcn_handle::print (std::ostream& os, bool pr_as_read_syntax) const
+{
+  print_raw (os, pr_as_read_syntax);
+  newline (os);
+}
+
+void
+octave_fcn_handle::print_raw (std::ostream& os, bool pr_as_read_syntax) const
+{
+  indent (os);
+  os << "@" << name ();
+}
+
+octave_value
+make_fcn_handle (const std::string& nm)
+{
+  octave_value retval;
+
+  octave_function *f = lookup_function (nm);
+
+  if (f)
+    {
+      octave_fcn_handle fh (f, nm);
+
+      retval = octave_value (fh);
+    }
+  else
+    error ("error creating function handle \"@%s\"", nm.c_str ());
+
+  return retval;
+}
+
+DEFUN (functions, args, ,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} functions (@var{fcn_handle})\n\
+Return a struct containing information about the function handle\n\
+@var{fcn_handle}.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () == 1)
+    {
+      octave_fcn_handle fh = args(0).fcn_handle_value ();
+
+      if (! error_state)
+	{
+	  octave_function *fcn = fh.function_value (true);
+
+	  if (fcn)
+	    {
+	      Octave_map m;
+
+	      m ["function"](0) = fh.name ();
+
+	      if (fcn->is_nested_function ())
+		m ["type"](0) = "subfunction";
+	      else
+		m ["type"](0) = "simple";
+
+	      std::string nm = fcn->fcn_file_name ();
+
+	      if (nm.empty ())
+		m ["file"](0) = "built-in function";
+	      else
+		m ["file"](0) = nm;
+
+	      retval = m;
+	    }
+	  else
+	    error ("functions: invalid function handle object");
+	}
+      else
+	error ("functions: argument must be a function handle object");
+    }
+  else
+    print_usage ("functions");
+
+  return retval;
+}
+
+DEFUN (func2str, args, ,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} func2str (@var{fcn_handle})\n\
+Return a string containing the name of the function referenced by\n\
+the function handle @var{fcn_handle}.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () == 1)
+    {
+      octave_fcn_handle fh = args(0).fcn_handle_value ();
+
+      if (! error_state)
+	retval = fh.name ();
+      else
+	error ("func2str: expecting function handle as first argument");
+    }
+  else
+    print_usage ("func2str");
+
+  return retval;
+}
+
+DEFUN (str2func, args, ,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} str2func (@var{fcn_name})\n\
+Return a function handle constructed from the string @var{fcn_name}.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () == 1)
+    {
+      std::string nm = args(0).string_value ();
+
+      if (! error_state)
+	retval = make_fcn_handle (nm);
+      else
+	error ("str2func: expecting string as first argument");
+    }
+  else
+    print_usage ("str2func");
+
+  return retval;
+}
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ov-fcn-handle.h	Thu Feb 20 16:46:37 2003 +0000
@@ -0,0 +1,101 @@
+/*
+
+Copyright (C) 2003 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_fcn_handle_h)
+#define octave_fcn_handle_h 1
+
+#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
+#pragma interface
+#endif
+
+#include <iostream>
+#include <string>
+
+#include "oct-alloc.h"
+
+#include "ov-base.h"
+#include "ov-fcn.h"
+#include "symtab.h"
+
+// Function handles.
+
+class
+octave_fcn_handle : public octave_base_value
+{
+public:
+
+  octave_fcn_handle (octave_function *f = 0,
+		     const std::string& n = std::string ())
+    : fcn (f), nm (n) { }
+
+  octave_fcn_handle (const octave_fcn_handle& fh)
+    : fcn (fh.fcn), nm (fh.nm) { }
+
+  octave_fcn_handle& operator = (const octave_fcn_handle& fh)
+    {
+      if (this != &fh)
+	{
+	  fcn = fh.fcn;
+	  nm  = fh.nm;
+	}
+
+      return *this;
+    }
+
+  ~octave_fcn_handle (void) { }
+
+  bool is_defined (void) const { return fcn; }
+
+  octave_function *function_value (bool) { return fcn; }
+
+  octave_fcn_handle fcn_handle_value (bool) { return *this; }
+
+  bool print_as_scalar (void) const { return true; }
+
+  void print (std::ostream& os, bool pr_as_read_syntax = false) const;
+
+  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
+
+  std::string name (void) const { return nm; }
+
+private:
+
+  // The function we are handling.
+  octave_function *fcn;
+
+  // The name of the handle.
+  std::string nm;
+
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+
+  DECLARE_OCTAVE_ALLOCATOR
+};
+
+extern octave_value make_fcn_handle (const std::string& nm);
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- a/src/ov-fcn.h	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov-fcn.h	Thu Feb 20 16:46:37 2003 +0000
@@ -71,6 +71,8 @@
   virtual octave_time time_checked (void) const
     { return octave_time (static_cast<time_t> (0)); }
 
+  virtual bool is_nested_function (void) const { return false; }
+
   std::string name (void) const { return my_name; }
 
   std::string doc_string (void) const { return doc; }
--- a/src/ov-usr-fcn.cc	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov-usr-fcn.cc	Thu Feb 20 16:46:37 2003 +0000
@@ -119,12 +119,9 @@
 }
 
 void
-octave_user_function::stash_fcn_file_name (void)
+octave_user_function::stash_fcn_file_name (const std::string& nm)
 {
-  if (fcn_name.empty ())
-    file_name = "";
-  else
-    file_name = fcn_file_in_path (fcn_name);
+  file_name = nm;
 }
 
 void
--- a/src/ov-usr-fcn.h	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov-usr-fcn.h	Thu Feb 20 16:46:37 2003 +0000
@@ -67,7 +67,7 @@
 
   octave_user_function *define_ret_list (tree_parameter_list *t);
 
-  void stash_fcn_file_name (void);
+  void stash_fcn_file_name (const std::string& nm);
 
   void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; }
 
--- a/src/ov.cc	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov.cc	Thu Feb 20 16:46:37 2003 +0000
@@ -801,6 +801,12 @@
   return rep->function_value (silent);
 }
 
+octave_fcn_handle
+octave_value::fcn_handle_value (bool silent)
+{
+  return rep->fcn_handle_value (silent);
+}
+
 octave_value_list
 octave_value::list_value (void) const
 {
--- a/src/ov.h	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/ov.h	Thu Feb 20 16:46:37 2003 +0000
@@ -484,6 +484,8 @@
 
   virtual octave_function *function_value (bool silent = false);
 
+  virtual octave_fcn_handle fcn_handle_value (bool silent = false);
+
   virtual octave_value_list list_value (void) const;
 
   virtual bool bool_value (void) const
--- a/src/parse.y	Thu Feb 20 08:35:55 2003 +0000
+++ b/src/parse.y	Thu Feb 20 16:46:37 2003 +0000
@@ -2583,7 +2583,7 @@
       octave_time now;
 
       fcn->stash_function_name (id_name);
-      fcn->stash_fcn_file_name ();
+      fcn->stash_fcn_file_name (curr_fcn_file_full_name);
       fcn->stash_fcn_file_time (now);
       fcn->mark_as_system_fcn_file ();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pt-fcn-handle.cc	Thu Feb 20 16:46:37 2003 +0000
@@ -0,0 +1,86 @@
+/*
+
+Copyright (C) 2003 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
+#pragma implementation
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <iostream>
+
+#include "error.h"
+#include "oct-obj.h"
+#include "ov-fcn-handle.h"
+#include "pt-fcn-handle.h"
+#include "pager.h"
+#include "pt-walk.h"
+
+void
+tree_fcn_handle::print (std::ostream& os, bool pr_as_read_syntax,
+			bool pr_orig_text)
+{
+  print_raw (os, pr_as_read_syntax, pr_orig_text);
+}
+
+void
+tree_fcn_handle::print_raw (std::ostream& os, bool pr_as_read_syntax,
+			    bool pr_orig_text) 
+{
+  os << ((pr_as_read_syntax || pr_orig_text) ? "@" : "") << nm;
+}
+
+octave_value
+tree_fcn_handle::rvalue (void)
+{
+  MAYBE_DO_BREAKPOINT;
+
+  return make_fcn_handle (nm);
+}
+
+
+octave_value_list
+tree_fcn_handle::rvalue (int nargout)
+{
+  octave_value_list retval;
+
+  if (nargout > 1)
+    error ("invalid number of output arguments for function handle expression");
+  else
+    retval = rvalue ();
+
+  return retval;
+}
+
+void
+tree_fcn_handle::accept (tree_walker& tw)
+{
+  tw.visit_fcn_handle (*this);
+}
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pt-fcn-handle.h	Thu Feb 20 16:46:37 2003 +0000
@@ -0,0 +1,89 @@
+/*
+
+Copyright (C) 2003 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_tree_fcn_handle_h)
+#define octave_fcn_handle_h 1
+
+#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
+#pragma interface
+#endif
+
+#include <iostream>
+#include <string>
+
+#include "pt-bp.h"
+#include "pt-exp.h"
+
+class octave_value_list;
+
+class tree_walker;
+
+#include "ov.h"
+
+class
+tree_fcn_handle : public tree_expression
+{
+public:
+
+  tree_fcn_handle (int l = -1, int c = -1)
+    : tree_expression (l, c), nm () { }
+
+  tree_fcn_handle (const std::string& n, int l = -1, int c = -1)
+    : tree_expression (l, c), nm (n) { }
+
+  ~tree_fcn_handle (void) { }
+
+  bool has_magic_end (void) const { return false; }
+
+  void print (std::ostream& os, bool pr_as_read_syntax = false,
+	      bool pr_orig_txt = true);
+
+  void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
+		  bool pr_orig_txt = true);
+
+  bool rvalue_ok (void) const { return true; }
+
+  octave_value rvalue (void);
+
+  octave_value_list rvalue (int nargout);
+
+  void accept (tree_walker& tw);
+
+private:
+
+  // The name of this function handle.
+  std::string nm;
+
+  // No copying!
+
+  tree_fcn_handle (const tree_fcn_handle&);
+
+  tree_fcn_handle& operator = (const tree_fcn_handle&);
+};
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/