This list is closed, nobody may subscribe to it.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(5) |
Sep
(3) |
Oct
(41) |
Nov
(41) |
Dec
(33) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(75) |
Feb
(10) |
Mar
(170) |
Apr
(174) |
May
(66) |
Jun
(11) |
Jul
(10) |
Aug
(44) |
Sep
(73) |
Oct
(28) |
Nov
(139) |
Dec
(52) |
2003 |
Jan
(35) |
Feb
(93) |
Mar
(62) |
Apr
(10) |
May
(55) |
Jun
(70) |
Jul
(37) |
Aug
(16) |
Sep
(56) |
Oct
(31) |
Nov
(57) |
Dec
(83) |
2004 |
Jan
(85) |
Feb
(67) |
Mar
(27) |
Apr
(37) |
May
(75) |
Jun
(85) |
Jul
(160) |
Aug
(68) |
Sep
(104) |
Oct
(25) |
Nov
(39) |
Dec
(23) |
2005 |
Jan
(10) |
Feb
(45) |
Mar
(43) |
Apr
(19) |
May
(108) |
Jun
(31) |
Jul
(41) |
Aug
(23) |
Sep
(65) |
Oct
(58) |
Nov
(44) |
Dec
(54) |
2006 |
Jan
(96) |
Feb
(27) |
Mar
(69) |
Apr
(59) |
May
(67) |
Jun
(35) |
Jul
(13) |
Aug
(461) |
Sep
(160) |
Oct
(399) |
Nov
(32) |
Dec
(72) |
2007 |
Jan
(316) |
Feb
(305) |
Mar
(318) |
Apr
(54) |
May
(194) |
Jun
(173) |
Jul
(282) |
Aug
(91) |
Sep
(227) |
Oct
(365) |
Nov
(168) |
Dec
(18) |
2008 |
Jan
(71) |
Feb
(111) |
Mar
(155) |
Apr
(173) |
May
(70) |
Jun
(67) |
Jul
(55) |
Aug
(83) |
Sep
(32) |
Oct
(68) |
Nov
(80) |
Dec
(29) |
2009 |
Jan
(46) |
Feb
(18) |
Mar
(95) |
Apr
(76) |
May
(140) |
Jun
(98) |
Jul
(84) |
Aug
(123) |
Sep
(94) |
Oct
(131) |
Nov
(142) |
Dec
(125) |
2010 |
Jan
(128) |
Feb
(158) |
Mar
(172) |
Apr
(134) |
May
(94) |
Jun
(84) |
Jul
(32) |
Aug
(127) |
Sep
(167) |
Oct
(109) |
Nov
(69) |
Dec
(78) |
2011 |
Jan
(39) |
Feb
(58) |
Mar
(52) |
Apr
(47) |
May
(56) |
Jun
(76) |
Jul
(55) |
Aug
(54) |
Sep
(165) |
Oct
(255) |
Nov
(328) |
Dec
(263) |
2012 |
Jan
(82) |
Feb
(147) |
Mar
(400) |
Apr
(216) |
May
(209) |
Jun
(160) |
Jul
(86) |
Aug
(141) |
Sep
(156) |
Oct
(6) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(2) |
2016 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(4) |
Jun
(8) |
Jul
(2) |
Aug
(5) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
From: <i7...@us...> - 2012-03-25 09:00:10
|
Revision: 10048 http://octave.svn.sourceforge.net/octave/?rev=10048&view=rev Author: i7tiol Date: 2012-03-25 08:59:59 +0000 (Sun, 25 Mar 2012) Log Message: ----------- structcat accepts argument to set value of missing fields Modified Paths: -------------- trunk/octave-forge/main/struct/src/structcat.cc Modified: trunk/octave-forge/main/struct/src/structcat.cc =================================================================== --- trunk/octave-forge/main/struct/src/structcat.cc 2012-03-24 21:59:22 UTC (rev 10047) +++ trunk/octave-forge/main/struct/src/structcat.cc 2012-03-25 08:59:59 UTC (rev 10048) @@ -1,8 +1,6 @@ /* -Copyright (C) 2009 John W. Eaton -Copyright (C) 2009 Jaroslav Hajek <hi...@gm...> -Copyright (C) 2010, 2011 Olaf Till +Copyright (C) 2010, 2011, 2012 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,37 +17,38 @@ */ -// This code and the comments are taken and slightly modified from -// Octave-3.2.4, src/data.cc (do_cat()), src/ov.cc (do_cat_op ()), -// src/OPERATORS/op-struct.cc, src/ops.h, and oct-map.cc -// (Octave_map::concat ()). +// Code of the files of Octave-3.2.4 src/data.cc (do_cat()), src/ov.cc +// (do_cat_op ()), src/OPERATORS/op-struct.cc, src/ops.h, and +// oct-map.cc (Octave_map::concat ()) has been studied and initially +// re-used, but in the end it has been made differently here. #include <octave/oct.h> #include <octave/ov-struct.h> -static octave_value -structcat_cat_op_fcn (const octave_value& v1, const octave_value& v2, - const Array<octave_idx_type>& ra_idx) +static Octave_map +structcat_op_fcn (const Octave_map& m1, const Octave_map& m2, + const dim_vector& dv, + const Array<octave_idx_type>& ra_idx, + const octave_value& fillv) { - Octave_map m1 = v1.map_value (); - Octave_map m2 = v2.map_value (); + Octave_map retval (dv); - dim_vector dv1 (m1.dims ()); + Cell c2 (m2.dims (), fillv); - Octave_map retval (dv1); - - Cell c2 (m2.dims ()); - for (Octave_map::const_iterator pa = m1.begin (); pa != m1.end (); pa++) { + Cell c (dv); + + c.insert (m1.contents(pa), 0, 0); + Octave_map::const_iterator pb = m2.seek (m1.key(pa)); if (pb == m2.end ()) - retval.assign (m1.key(pa), - m1.contents(pa).insert (c2, ra_idx)); + c.insert (c2, ra_idx); else - retval.assign (m1.key(pa), - m1.contents(pa).insert (m2.contents(pb), ra_idx)); + c.insert (m2.contents(pb), ra_idx); + + retval.assign (m1.key(pa), c); } for (Octave_map::const_iterator pa = m2.begin (); pa != m2.end (); pa++) @@ -58,9 +57,10 @@ if (pb == m1.end ()) { - Cell c1 (dv1); + Cell c (dv, fillv); + retval.assign (m2.key(pa), - c1.insert (m2.contents(pa), ra_idx)); + c.insert (m2.contents(pa), ra_idx)); } } @@ -71,115 +71,81 @@ DEFUN_DLD (structcat, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} structcat (@var{dim}, @var{struct1}, @dots{}, @var{structn})\n\ -Return the concatenation of N-d structures @var{struct1}, @dots{}, @var{structn} along dimension @var{dim}. Differently to @code{cat}, fields need not match --- missing fields get an empty matrix value. Without structure arguments, an empty structure array is returned.\n\ +@deftypefnx {Loadable Function} {} structcat (@var{dim}, @var{default}, @var{struct1}, @dots{}, @var{structn})\n\ +Return the concatenation of N-d structures @var{struct1}, @dots{}, @var{structn} along dimension @var{dim}. Differently to @code{cat}, fields need not match --- missing fields get an empty matrix value. Without structure arguments, an empty structure array is returned. If a scalar argument @var{default} is given, missing fields get its value instead of an empty matrix value.\n\ +\n\ +@seealso{structcat_default}\n\ @end deftypefn") { std::string fname ("structcat"); - octave_value retval; + Octave_map retval; - int n_args = args.length (); + octave_idx_type n_args = args.length (); - if (n_args == 1) - retval = Octave_map (); - else if (n_args == 2) - retval = args(1).map_value (); - else if (n_args > 2) + if (n_args == 0) + print_usage (); + else { octave_idx_type dim = args(0).int_value () - 1; - if (error_state) + if (error_state || dim < 0) { - error ("%s: expecting first argument to be a integer", + error ("%s: first argument must be a positive integer", fname.c_str ()); - return retval; + return octave_value (); } - - if (dim >= 0) + + octave_idx_type m1_id; + octave_value fillv; + + if (n_args > 1 && args(1).is_scalar_type ()) { - dim_vector dv = args(1).dims (); - std::string result_type ("struct"); + m1_id = 2; - for (int i = 2; i < args.length (); i++) - { - // Construct a dimension vector which holds the - // dimensions of the final array after concatenation. - - if (! dv.concat (args(i).dims (), dim)) - { - // Dimensions do not match. - error ("%s: dimension mismatch", fname.c_str ()); - return retval; - } - - if (args(i).class_name () != result_type) - { - error ("%s: some argument not a structure", - fname.c_str ()); - return retval; - } - } + fillv = args(1); + } + else + { + m1_id = 1; - // The lines below might seem crazy, since we take a - // copy of the first argument, resize it to be empty and - // then resize it to be full. This is done since it - // means that there is no recopying of data, as would - // happen if we used a single resize. It should be - // noted that resize operation is also significantly - // slower than the do_cat_op function, so it makes sense - // to have an empty matrix and copy all data. - // - // We might also start with a empty octave_value using - // tmp = octave_value_typeinfo::lookup_type - // (args(1).type_name()); - // and then directly resize. However, for some types there might - // be some additional setup needed, and so this should be avoided. + fillv = Matrix (); + } - octave_value tmp = args (1); - tmp = tmp.resize (dim_vector (0, 0)).resize (dv); + dim_vector dv; - if (error_state) - return retval; + octave_idx_type idx_len = dv.length (); - int dv_len = dv.length (); - Array<octave_idx_type> ra_idx (dim_vector (dv_len, 1), 0); + if (dim >= idx_len) idx_len = dim + 1; - for (int j = 1; j < n_args; j++) + Array<octave_idx_type> ra_idx (dim_vector (idx_len, 1), 0); + + for (octave_idx_type i = m1_id; i < n_args; i++) + { + if (! args(i).is_map ()) { - dim_vector dv_tmp = args (j).dims (); + error ("%s: some argument not a structure", fname.c_str ()); - if (! dv_tmp.all_zero ()) - { - tmp = structcat_cat_op_fcn (tmp, args(j), ra_idx); + return octave_value (); + } - if (error_state) - return retval; + dim_vector dvi = args(i).dims (), old_dv = dv; - if (dim >= dv_len) - { - if (j > 1) - error ("%s: indexing error", fname.c_str ()); - break; - } - else - ra_idx (dim) += (dim < dv_tmp.length () ? - dv_tmp (dim) : 1); - } + if (! dv.concat (dvi, dim)) + { + error ("%s: dimension mismatch", fname.c_str ()); + + return octave_value (); } - retval = tmp; - if (! error_state) + if (! dvi.all_zero ()) { - // Reshape, chopping trailing singleton dimensions - dv.chop_trailing_singletons (); - retval = retval.reshape (dv); + retval = structcat_op_fcn (retval, args(i).map_value (), + dv, ra_idx, fillv); + + ra_idx(dim) += (dim < dvi.length () ? dvi(dim) : 1); } - } - else - error ("%s: invalid dimension argument", fname.c_str ()); + } } - else - print_usage (); - - return retval; + return octave_value (retval); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 21:59:29
|
Revision: 10047 http://octave.svn.sourceforge.net/octave/?rev=10047&view=rev Author: carandraug Date: 2012-03-24 21:59:22 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous: bump version, new release made Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/DESCRIPTION trunk/octave-forge/main/miscellaneous/inst/infoskeleton.m Modified: trunk/octave-forge/main/miscellaneous/DESCRIPTION =================================================================== --- trunk/octave-forge/main/miscellaneous/DESCRIPTION 2012-03-24 20:16:29 UTC (rev 10046) +++ trunk/octave-forge/main/miscellaneous/DESCRIPTION 2012-03-24 21:59:22 UTC (rev 10047) @@ -1,6 +1,6 @@ Name: Miscellaneous -Version: 1.0.11 -Date: 2011-12-11 +Version: 1.1.0 +Date: 2012-03-24 Author: various authors Maintainer: Octave-Forge community <oct...@li...> Title: Miscellaneous functions Modified: trunk/octave-forge/main/miscellaneous/inst/infoskeleton.m =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/infoskeleton.m 2012-03-24 20:16:29 UTC (rev 10046) +++ trunk/octave-forge/main/miscellaneous/inst/infoskeleton.m 2012-03-24 21:59:22 UTC (rev 10047) @@ -15,11 +15,10 @@ ##-*- texinfo -*- ## @deftypefn{Function File} infoskeleton(@var{prototype}, @var{index_str}, @var{see_also}) -## @cindex infoskeleton -## The function @var{infoskeleton} generates TeXinfo skeleton documentation of the -## given @var{prototype}. Optionally @var{index_str} and @var{see_also} -## can be specified. +## Generate TeXinfo skeleton documentation of @var{prototype}. ## +## Optionally @var{index_str} and @var{see_also} can be specified. +## ## Usage of this function is typically, ## @example ## infoskeleton('[V,Q] = eig( A )','linear algebra','eigs, chol, qr, det') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 20:16:35
|
Revision: 10046 http://octave.svn.sourceforge.net/octave/?rev=10046&view=rev Author: carandraug Date: 2012-03-24 20:16:29 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous: update INDEX Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/INDEX Modified: trunk/octave-forge/main/miscellaneous/INDEX =================================================================== --- trunk/octave-forge/main/miscellaneous/INDEX 2012-03-24 20:02:32 UTC (rev 10045) +++ trunk/octave-forge/main/miscellaneous/INDEX 2012-03-24 20:16:29 UTC (rev 10046) @@ -3,10 +3,6 @@ apply asci cell2cell - cell2csv - csv2cell - csvconcat - csvexplode chebyshevpoly clip colorboard @@ -34,8 +30,6 @@ temp_name text_waitbar units - xmlread - xmlwrite zagzig z_curve zigzag This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 20:02:43
|
Revision: 10045 http://octave.svn.sourceforge.net/octave/?rev=10045&view=rev Author: carandraug Date: 2012-03-24 20:02:32 +0000 (Sat, 24 Mar 2012) Log Message: ----------- cell2cell: replace tabs per spaces Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/src/cell2cell.cc Modified: trunk/octave-forge/main/miscellaneous/src/cell2cell.cc =================================================================== --- trunk/octave-forge/main/miscellaneous/src/cell2cell.cc 2012-03-24 19:54:57 UTC (rev 10044) +++ trunk/octave-forge/main/miscellaneous/src/cell2cell.cc 2012-03-24 20:02:32 UTC (rev 10045) @@ -18,7 +18,9 @@ DEFUN_DLD (cell2cell, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} cell2cell (@var{c}, @var{dim})\n\ -Return a one-dimensional cell array, extending along dimension @var{dim}, which contains the slices of cell array @var{c} vertical to dimension @var{dim}.\n\ +Return a one-dimensional cell array, extending along dimension @var{dim},\n\ +which contains the slices of cell array @var{c} vertical to dimension\n\ +@var{dim}.\n\ @end deftypefn") { std::string fname ("cell2cell"); @@ -40,7 +42,7 @@ if (error_state) { error ("%s: second argument must be an integer", - fname.c_str ()); + fname.c_str ()); return octave_value_list (); } @@ -57,16 +59,16 @@ if (n_cdims >= dim && cdims(dim - 1) > 1) { if (dim == 1) - { - rdims.resize (2); + { + rdims.resize (2); - rdims(1) = 1; - } + rdims(1) = 1; + } else - rdims.resize (dim); + rdims.resize (dim); for (i = 0; i < dim - 1; i++) - rdims(i) = 1; + rdims(i) = 1; rdims(dim - 1) = (nr = cdims(dim - 1)); @@ -109,16 +111,16 @@ cursor = 0; for (j = 0; j < nt; j++) - { - t(j) = c(origin + cursor++); + { + t(j) = c(origin + cursor++); - if (cursor == skip_count) - { - cursor = 0; + if (cursor == skip_count) + { + cursor = 0; - origin += skip; - } - } + origin += skip; + } + } retval(i) = t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 19:55:09
|
Revision: 10044 http://octave.svn.sourceforge.net/octave/?rev=10044&view=rev Author: carandraug Date: 2012-03-24 19:54:57 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous: simpler Makefile Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/src/Makefile Removed Paths: ------------- trunk/octave-forge/main/miscellaneous/src/Makeconf.in trunk/octave-forge/main/miscellaneous/src/autogen.sh trunk/octave-forge/main/miscellaneous/src/configure.base Deleted: trunk/octave-forge/main/miscellaneous/src/Makeconf.in =================================================================== --- trunk/octave-forge/main/miscellaneous/src/Makeconf.in 2012-03-24 19:53:23 UTC (rev 10043) +++ trunk/octave-forge/main/miscellaneous/src/Makeconf.in 2012-03-24 19:54:57 UTC (rev 10044) @@ -1,71 +0,0 @@ - -## Makeconf is automatically generated from Makeconf.base and Makeconf.add -## in the various subdirectories. To regenerate, use ./autogen.sh to -## create a new ./Makeconf.in, then use ./configure to generate a new -## Makeconf. - -OCTAVE_FORGE = 1 - -SHELL = @SHELL@ - -canonical_host_type = @canonical_host_type@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = @bindir@ -mandir = @mandir@ -libdir = @libdir@ -datadir = @datadir@ -infodir = @infodir@ -includedir = @includedir@ -datarootdir = @datarootdir@ -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALLOCT=octinst.sh - -DESTDIR = - -RANLIB = @RANLIB@ -STRIP = @STRIP@ -LN_S = @LN_S@ - -AWK = @AWK@ - -# Most octave programs will be compiled with $(MKOCTFILE). Those which -# cannot use mkoctfile directly can request the flags that mkoctfile -# would use as follows: -# FLAG = $(shell $(MKOCTFILE) -p FLAG) -# The following flags are for compiling programs that are independent -# of Octave. How confusing. -CC = @CC@ -CFLAGS = @CFLAGS@ -CPPFLAGS = @CPPFLAGS@ -CPICFLAG = @CPICFLAG@ -CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -CXXPICFLAG = @CXXPICFLAG@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -FPICFLAG = @FPICFLAG@ - -OCTAVE = @OCTAVE@ -OCTAVE_VERSION = @OCTAVE_VERSION@ -MKOCTFILE = @MKOCTFILE@ -DHAVE_OCTAVE_$(ver) -v -SHLEXT = @SHLEXT@ - -ver = @ver@ -MPATH = @mpath@ -OPATH = @opath@ -XPATH = @xpath@ -ALTMPATH = @altmpath@ -ALTOPATH = @altopath@ - -HAVE_LIB_TERMCAP = @HAVE_LIB_TERMCAP@ -MISCDEFS = @MISCDEFS@ -HAVE_FORK = @have_fork@ - -%.o: %.c ; $(MKOCTFILE) -c $< -%.o: %.f ; $(MKOCTFILE) -c $< -%.o: %.cc ; $(MKOCTFILE) -c $< -%.oct: %.cc ; $(MKOCTFILE) $< Modified: trunk/octave-forge/main/miscellaneous/src/Makefile =================================================================== --- trunk/octave-forge/main/miscellaneous/src/Makefile 2012-03-24 19:53:23 UTC (rev 10043) +++ trunk/octave-forge/main/miscellaneous/src/Makefile 2012-03-24 19:54:57 UTC (rev 10044) @@ -1,35 +1,9 @@ -sinclude Makeconf +all: cell2cell.oct partarray.oct sample.oct text_waitbar.oct -ifdef HAVE_LIB_TERMCAP - TERM_LIB=-ltermcap -endif +MKOCTFILE = mkoctfile -Wall -TARGETS=text_waitbar.oct $(LISTEN) cell2cell.oct sample.oct partarray.oct +%.oct: %.cc + $(MKOCTFILE) $< -all: $(TARGETS) - -text_waitbar.oct: text_waitbar.cc - $(MKOCTFILE) $(MISCDEFS) text_waitbar.cc $(TERM_LIB) - -server.oct: server.o listencanfork.o stringmatch.o - $(MKOCTFILE) server.o listencanfork.o stringmatch.o - -server.o: server.cc - $(MKOCTFILE) -c $(MISCDEFS) server.cc - -listencanfork.o: listencanfork.c - $(MKOCTFILE) -c listencanfork.c - -stringmatch.o: stringmatch.c - $(MKOCTFILE) -c stringmatch.c - -cell2cell.oct: cell2cell.cc - $(MKOCTFILE) $(MISCDEFS) $< - -partarray.oct: partarray.cc - $(MKOCTFILE) $(MISCDEFS) $< - -sample.oct: sample.cc - $(MKOCTFILE) $(MISCDEFS) $< - -clean: ; -$(RM) *.o octave-core core *.oct *~ $(t2.1.58) +clean: + rm -f *.o octave-core core *.oct *~ Deleted: trunk/octave-forge/main/miscellaneous/src/autogen.sh =================================================================== --- trunk/octave-forge/main/miscellaneous/src/autogen.sh 2012-03-24 19:53:23 UTC (rev 10043) +++ trunk/octave-forge/main/miscellaneous/src/autogen.sh 2012-03-24 19:54:57 UTC (rev 10044) @@ -1,27 +0,0 @@ -#! /bin/sh - -## Generate ./configure -rm -f configure.in -echo "dnl --- DO NOT EDIT --- Automatically generated by autogen.sh" > configure.in -cat configure.base >> configure.in -cat <<EOF >> configure.in - AC_OUTPUT(\$CONFIGURE_OUTPUTS) - dnl XXX FIXME XXX chmod is not in autoconf's list of portable functions - - echo " " - echo " \"\\\$prefix\" is \$prefix" - echo " \"\\\$exec_prefix\" is \$exec_prefix" - AC_MSG_RESULT([\$STATUS_MSG - -find . -name NOINSTALL -print # shows which toolboxes won't be installed -]) -EOF - -autoconf configure.in > configure.tmp -if [ diff configure.tmp configure > /dev/null 2>&1 ]; then - rm -f configure.tmp; -else - mv -f configure.tmp configure - chmod 0755 configure -fi -rm -f configure.in Deleted: trunk/octave-forge/main/miscellaneous/src/configure.base =================================================================== --- trunk/octave-forge/main/miscellaneous/src/configure.base 2012-03-24 19:53:23 UTC (rev 10043) +++ trunk/octave-forge/main/miscellaneous/src/configure.base 2012-03-24 19:54:57 UTC (rev 10044) @@ -1,376 +0,0 @@ -dnl The configure script is generated by autogen.sh from configure.base -dnl and the various configure.add files in the source tree. Edit -dnl configure.base and reprocess rather than modifying ./configure. - -dnl autoconf 2.13 certainly doesn't work! What is the minimum requirement? -AC_PREREQ(2.2) - -AC_INIT(configure.base) - -PACKAGE=octave-forge -MAJOR_VERSION=0 -MINOR_VERSION=1 -PATCH_LEVEL=0 - -dnl Kill caching --- this ought to be the default -define([AC_CACHE_LOAD], )dnl -define([AC_CACHE_SAVE], )dnl - -dnl uncomment to put support files in another directory -dnl AC_CONFIG_AUX_DIR(admin) - -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL -AC_SUBST(PACKAGE) -AC_SUBST(VERSION) - -dnl need to find admin files, so keep track of the top dir. -TOPDIR=`pwd` -AC_SUBST(TOPDIR) - -dnl if mkoctfile doesn't work, then we need the following: -dnl AC_PROG_CXX -dnl AC_PROG_F77 - -dnl Need C compiler regardless so define it in a way that -dnl makes autoconf happy and we can override whatever we -dnl need with mkoctfile -p. -dnl XXX FIXME XXX should use mkoctfile to get CC and CFLAGS -AC_PROG_CC - -dnl XXX FIXME XXX need tests for -p -c -s in mkoctfile. - -dnl ******************************************************************* -dnl Sort out mkoctfile version number and install paths - -dnl XXX FIXME XXX latest octave has octave-config so we don't -dnl need to discover things here. Doesn't have --exe-site-dir -dnl but defines --oct-site-dir and --m-site-dir - -dnl Check for mkoctfile -AC_CHECK_PROG(MKOCTFILE,mkoctfile,mkoctfile) -test -z "$MKOCTFILE" && AC_MSG_WARN([no mkoctfile found on path]) - -AC_SUBST(ver) -AC_SUBST(subver) -AC_SUBST(mpath) -AC_SUBST(opath) -AC_SUBST(xpath) -AC_SUBST(altpath) -AC_SUBST(altmpath) -AC_SUBST(altopath) - -AC_ARG_WITH(path, - [ --with-path install path prefix], - [ path=$withval ]) -AC_ARG_WITH(mpath, - [ --with-mpath override path for m-files], - [mpath=$withval]) -AC_ARG_WITH(opath, - [ --with-opath override path for oct-files], - [opath=$withval]) -AC_ARG_WITH(xpath, - [ --with-xpath override path for executables], - [xpath=$withval]) -AC_ARG_WITH(altpath, - [ --with-altpath alternative functions install path prefix], - [ altpath=$withval ]) -AC_ARG_WITH(altmpath, - [ --with-altmpath override path for alternative m-files], - [altmpath=$withval]) -AC_ARG_WITH(altopath, - [ --with-altopath override path for alternative oct-files], - [altopath=$withval]) - -if test -n "$path" ; then - test -z "$mpath" && mpath=$path - test -z "$opath" && opath=$path/oct - test -z "$xpath" && xpath=$path/bin - test -z "$altpath" && altpath=$path-alternatives -fi - -if test -n "$altpath" ; then - test -z "$altmpath" && altmpath=$altpath - test -z "$altopath" && altopath=$altpath/oct -fi - -dnl Don't query if path/ver are given in the configure environment -#if test -z "$mpath" || test -z "$opath" || test -z "$xpath" || test -z "$altmpath" || test -z "$altopath" || test -z "$ver" ; then -if test -z "$mpath" || test -z "$opath" || test -z "$xpath" || test -z "$ver" ; then - dnl Construct program to get mkoctfile version and local install paths - cat > conftest.cc <<EOF -#include <octave/config.h> -#include <octave/version.h> -#include <octave/defaults.h> - -#define INFOV "\nINFOV=" OCTAVE_VERSION "\n" - -#define INFOH "\nINFOH=" OCTAVE_CANONICAL_HOST_TYPE "\n" - -#ifdef OCTAVE_LOCALVERFCNFILEDIR -# define INFOM "\nINFOM=" OCTAVE_LOCALVERFCNFILEDIR "\n" -#else -# define INFOM "\nINFOM=" OCTAVE_LOCALFCNFILEPATH "\n" -#endif - -#ifdef OCTAVE_LOCALVEROCTFILEDIR -# define INFOO "\nINFOO=" OCTAVE_LOCALVEROCTFILEDIR "\n" -#else -# define INFOO "\nINFOO=" OCTAVE_LOCALOCTFILEPATH "\n" -#endif - -#ifdef OCTAVE_LOCALVERARCHLIBDIR -# define INFOX "\nINFOX=" OCTAVE_LOCALVERARCHLIBDIR "\n" -#else -# define INFOX "\nINFOX=" OCTAVE_LOCALARCHLIBDIR "\n" -#endif - -const char *infom = INFOM; -const char *infoo = INFOO; -const char *infox = INFOX; -const char *infoh = INFOH; -const char *infov = INFOV; -EOF - - dnl Compile program perhaps with a special version of mkoctfile - $MKOCTFILE conftest.cc || AC_MSG_ERROR(Could not run $MKOCTFILE) - - dnl Strip the config info from the compiled file - eval `strings conftest.o | grep "^INFO.=" | sed -e "s,//.*$,,"` - rm -rf conftest* - - dnl set the appropriate variables if they are not already set - ver=`echo $INFOV | sed -e "s/\.//" -e "s/\..*$//"` - subver=`echo $INFOV | sed -e "[s/^[^.]*[.][^.]*[.]//]"` - alt_mbase=`echo $INFOM | sed -e "[s,\/[^\/]*$,,]"` - alt_obase=`echo $INFOO | sed -e "[s,/site.*$,/site,]"` - test -z "$mpath" && mpath=$INFOM/octave-forge - test -z "$opath" && opath=$INFOO/octave-forge - test -z "$xpath" && xpath=$INFOX - test -z "$altmpath" && altmpath=$alt_mbase/octave-forge-alternatives/m - test -z "$altopath" && altopath=$alt_obase/octave-forge-alternatives/oct/$INFOH -fi - -dnl ******************************************************************* - -dnl XXX FIXME XXX Should we allow the user to override these? -dnl Do we even need them? The individual makefiles can call mkoctfile -p -dnl themselves, so the only reason to keep them is for configure, and -dnl for those things which are not built using mkoctfile (e.g., aurecord) -dnl but it is not clear we should be using octave compile flags for those. - -dnl C compiler and flags -AC_MSG_RESULT([retrieving compile and link flags from $MKOCTFILE]) -CC=`$MKOCTFILE -p CC` -CFLAGS=`$MKOCTFILE -p CFLAGS` -CPPFLAGS=`$MKOCTFILE -p CPPFLAGS` -CPICFLAG=`$MKOCTFILE -p CPICFLAG` -LDFLAGS=`$MKOCTFILE -p LDFLAGS` -LIBS=`$MKOCTFILE -p LIBS` -AC_SUBST(CC) -AC_SUBST(CFLAGS) -AC_SUBST(CPPFLAGS) -AC_SUBST(CPICFLAG) - -dnl Fortran compiler and flags -F77=`$MKOCTFILE -p F77` -FFLAGS=`$MKOCTFILE -p FFLAGS` -FPICFLAG=`$MKOCTFILE -p FPICFLAG` -AC_SUBST(F77) -AC_SUBST(FFLAGS) -AC_SUBST(FPICFLAG) - -dnl C++ compiler and flags -CXX=`$MKOCTFILE -p CXX` -CXXFLAGS=`$MKOCTFILE -p CXXFLAGS` -CXXPICFLAG=`$MKOCTFILE -p CXXPICFLAG` -AC_SUBST(CXX) -AC_SUBST(CXXFLAGS) -AC_SUBST(CXXPICFLAG) - -dnl ******************************************************************* - -dnl Check for features of your version of mkoctfile. -dnl All checks should be designed so that the default -dnl action if the tests are not performed is to do whatever -dnl is appropriate for the most recent version of Octave. - -dnl Define the following macro: -dnl OF_CHECK_LIB(lib,fn,true,false,helpers) -dnl This is just like AC_CHECK_LIB, but it doesn't update LIBS -AC_DEFUN(OF_CHECK_LIB, -[save_LIBS="$LIBS" -AC_CHECK_LIB($1,$2,$3,$4,$5) -LIBS="$save_LIBS" -]) - -dnl Define the following macro: -dnl TRY_MKOCTFILE(msg,program,action_if_true,action_if_false) -dnl -AC_DEFUN(TRY_MKOCTFILE, -[AC_MSG_CHECKING($1) -cat > conftest.cc << EOF -#include <octave/config.h> -$2 -EOF -ac_try="$MKOCTFILE -c conftest.cc" -if AC_TRY_EVAL(ac_try) ; then - AC_MSG_RESULT(yes) - $3 -else - AC_MSG_RESULT(no) - $4 -fi -]) - -dnl -dnl Check if F77_FUNC works with MKOCTFILE -dnl -TRY_MKOCTFILE([for F77_FUNC], -[int F77_FUNC (hello, HELLO) (const int &n);],, -[MKOCTFILE="$MKOCTFILE -DF77_FUNC=F77_FCN"]) - -dnl ********************************************************** - -dnl Evaluate an expression in octave -dnl -dnl OCTAVE_EVAL(expr,var) -> var=expr -dnl -AC_DEFUN(OCTAVE_EVAL, -[AC_MSG_CHECKING([for $1 in Octave]) -$2=`echo "disp($1)" | $OCTAVE -qf` -AC_MSG_RESULT($$2) -AC_SUBST($2) -]) - -dnl Check status of an octave variable -dnl -dnl OCTAVE_CHECK_EXIST(variable,action_if_true,action_if_false) -dnl -AC_DEFUN(OCTAVE_CHECK_EXIST, -[AC_MSG_CHECKING([for $1 in Octave]) -if test `echo 'disp(exist("$1"))' | $OCTAVE -qf`X != 0X ; then - AC_MSG_RESULT(yes) - $2 -else - AC_MSG_RESULT(no) - $3 -fi -]) - -dnl should check that $(OCTAVE) --version matches $(MKOCTFILE) --version -AC_CHECK_PROG(OCTAVE,octave,octave) -OCTAVE_EVAL(OCTAVE_VERSION,OCTAVE_VERSION) - -dnl grab canonical host type so we can write system specific install stuff -OCTAVE_EVAL(octave_config_info('canonical_host_type'),canonical_host_type) - -dnl grab SHLEXT from octave config -OCTAVE_EVAL(octave_config_info('SHLEXT'),SHLEXT) - -AC_PROG_LN_S - -AC_PROG_RANLIB - -dnl Use $(COPY_FLAGS) to set options for cp when installing .oct files. -COPY_FLAGS="-Rfp" -case "$canonical_host_type" in - *-*-linux*) - COPY_FLAGS="-fdp" - ;; -esac -AC_SUBST(COPY_FLAGS) - -dnl Use $(STRIP) in the makefile to strip executables. If not found, -dnl STRIP expands to ':', which in the makefile does nothing. -dnl Don't need this for .oct files since mkoctfile handles them directly -STRIP=${STRIP-strip} -AC_CHECK_PROG(STRIP,$STRIP,$STRIP,:) - -dnl Strip on windows, don't strip on Mac OS/X or IRIX -dnl For the rest, you can force strip using MKOCTFILE="mkoctfile -s" -dnl or avoid strip using STRIP=: before ./configure -case "$canonical_host_type" in - powerpc-apple-darwin*|*-sgi-*) - STRIP=: - ;; - *-cygwin-*|*-mingw-*) - MKOCTFILE="$MKOCTFILE -s" - ;; -esac - -AC_SUBST(MISCDEFS) -AC_SUBST(HAVE_LIB_TERMCAP) - -AC_CHECK_FUNCS(fork, [have_fork=yes], [have_fork=]) -AC_SUBST(have_fork) - -dnl In modern autoconf, we should be able to replace this with something -dnl the CHECK_TYPE macro -AC_DEFUN([TYPE_SOCKLEN_T], -[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, -[ - AC_TRY_COMPILE( - [#include <sys/types.h> - #include <sys/socket.h>], - [socklen_t len = 42; return 0;], - ac_cv_type_socklen_t=yes, - ac_cv_type_socklen_t=no) -]) - if test $ac_cv_type_socklen_t != yes; then - MISCDEFS="$MISCDEFS -Dsocklen_t=int" - fi -]) - -dnl Check for socklen_t -TYPE_SOCKLEN_T - -dnl Check if octave_function(void) fails -TRY_MKOCTFILE([for octave_function(void)], - [#include <octave/ov-fcn.h> - class myfun:octave_function {myfun():octave_function(){}};], - [],[MISCDEFS="$MISCDEFS -DOCTAVE_FUNCTION_VOID_FAILS"]) - -dnl Check for term.h -case "$canonical_host_type" in - *-sgi-*) - have_term=no - have_termcap=no - ;; - *) - AC_CHECK_HEADER(term.h, have_term=yes, have_term=no) - AC_CHECK_HEADER(termcap.h, have_termcap=yes, have_termcap=no) - ;; -esac - -if test $have_termcap = yes; then - MISCDEFS="$MISCDEFS -DUSE_TERM -DHAVE_TERMCAP_H" - OF_CHECK_LIB(termcap, tgetnum, HAVE_LIB_TERMCAP=yes) - TERMSTATUS=yes -elif test $have_term = yes; then - MISCDEFS="$MISCDEFS -DUSE_TERM -DHAVE_TERM_H" - TERMSTATUS=yes - OF_CHECK_LIB(termcap, tgetnum, HAVE_LIB_TERMCAP=yes) -else - TERMSTATUS=no -fi - -CONFIGURE_OUTPUTS="Makeconf" -STATUS_MSG=" -octave commands will install into the following directories: - m-files: $mpath - oct-files: $opath - binaries: $xpath -alternatives: - m-files: $altmpath - oct-files: $altopath - -shell commands will install into the following directories: - binaries: $bindir - man pages: $mandir - libraries: $libdir - headers: $includedir - -octave-forge is configured with - octave: $OCTAVE (version $OCTAVE_VERSION) - mkoctfile: $MKOCTFILE for Octave $subver - have term.h or termcap.h: $TERMSTATUS" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 19:53:34
|
Revision: 10043 http://octave.svn.sourceforge.net/octave/?rev=10043&view=rev Author: carandraug Date: 2012-03-24 19:53:23 +0000 (Sat, 24 Mar 2012) Log Message: ----------- partarray: replace tabs per spaces, update license Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/src/partarray.cc Modified: trunk/octave-forge/main/miscellaneous/src/partarray.cc =================================================================== --- trunk/octave-forge/main/miscellaneous/src/partarray.cc 2012-03-24 19:36:34 UTC (rev 10042) +++ trunk/octave-forge/main/miscellaneous/src/partarray.cc 2012-03-24 19:53:23 UTC (rev 10043) @@ -1,29 +1,25 @@ -/* +// Copyright (C) 2010,2011 Olaf Till <i7...@t-...> +// +// This program 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 3 of the License, or (at your option) any later +// version. +// +// This program 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 +// this program; if not, see <http://www.gnu.org/licenses/>. -Copyright (C) 2010, 2011 Olaf Till - -This program 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 3 of the License, or (at -your option) any later version. - -This program 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 this program. If not, see <http://www.gnu.org/licenses/>. - -*/ - #include <octave/oct.h> #include <octave/ov-struct.h> template<class NDA> static Cell do_partarray (const NDA& a, const std::string& fname, - const octave_value_list& args) + const octave_value_list& args) { // FIXME: some type-independent code should probably go into an // extra function (no template) to avoid its repetitive instanciation @@ -52,40 +48,40 @@ int cnidx; octave_value arg; if (i >= nidc || (arg = args(i + 1)).is_empty ()) - { - Array<octave_idx_type> bidx (dim_vector (1, 1), 1); - Array<octave_idx_type> eidx (dim_vector (1, 1), alldims(i)); - bidc[i] = bidx; - eidc[i] = eidx; - cnidx = 1; - } + { + Array<octave_idx_type> bidx (dim_vector (1, 1), 1); + Array<octave_idx_type> eidx (dim_vector (1, 1), alldims(i)); + bidc[i] = bidx; + eidc[i] = eidx; + cnidx = 1; + } else - { - dim_vector argdims = arg.dims (); - if (argdims.length () > 2 || argdims(1) != 2) - { - error ("%s: argument %i: wrong dimensions", - fname.c_str (), i + 2); - return Cell (); - } - cnidx = - (bidc[i] = octave_value (arg.matrix_value ().column (0)). - octave_idx_type_vector_value ()).length (); - eidc[i] = octave_value (arg.matrix_value ().column (1)). - octave_idx_type_vector_value (); - for (int j = 0; j < cnidx; j++) - { - if (bidc[i](j) < 1 || eidc[i](j) > alldims(i)) - error ("%s: index given by row %i of argument %i exceeds array dimensions", - fname.c_str (), j, i + 2); - if (bidc[i](j) > eidc[i](j)) - // so later length calculations yield 0 - eidc[i](j) = bidc[i](j) - 1; - } - } + { + dim_vector argdims = arg.dims (); + if (argdims.length () > 2 || argdims(1) != 2) + { + error ("%s: argument %i: wrong dimensions", + fname.c_str (), i + 2); + return Cell (); + } + cnidx = + (bidc[i] = octave_value (arg.matrix_value ().column (0)). + octave_idx_type_vector_value ()).length (); + eidc[i] = octave_value (arg.matrix_value ().column (1)). + octave_idx_type_vector_value (); + for (int j = 0; j < cnidx; j++) + { + if (bidc[i](j) < 1 || eidc[i](j) > alldims(i)) + error ("%s: index given by row %i of argument %i exceeds array dimensions", + fname.c_str (), j, i + 2); + if (bidc[i](j) > eidc[i](j)) + // so later length calculations yield 0 + eidc[i](j) = bidc[i](j) - 1; + } + } nc *= (nidx(i) = cnidx); if (i < maxdims - 1) - step(i + 1) = step(i) * alldims(i); + step(i + 1) = step(i) * alldims(i); } if (error_state) return Cell (); @@ -105,47 +101,47 @@ octave_idx_type n = 1, cursor = 0; Array<octave_idx_type> lengths (dim_vector (maxdims, 1)); for (int j = 0; j < maxdims; j++) - { - octave_idx_type begin = bidc[j](cidx(j)); - octave_idx_type end = eidc[j](cidx(j)); - octave_idx_type length = end + 1 - begin; - lengths(j) = length; - n *= length; - cursor += (begin - 1) * step(j); - } + { + octave_idx_type begin = bidc[j](cidx(j)); + octave_idx_type end = eidc[j](cidx(j)); + octave_idx_type length = end + 1 - begin; + lengths(j) = length; + n *= length; + cursor += (begin - 1) * step(j); + } Array<octave_idx_type> starts (dim_vector (maxdims - 1, 1), cursor); Array<octave_idx_type> idx_cursors (dim_vector (maxdims, 1), 0); // copy the subarray dim_vector subdv; subdv.resize (maxdims); for (octave_idx_type k = 0; k < maxdims; k++) - subdv(k) = lengths(k); + subdv(k) = lengths(k); NDA asub (subdv); for (octave_idx_type k = 0; k < n; k++) - { - asub(k) = a(cursor++); - idx_cursors(0)++; - for (int l = 0; l < maxdims - 1; l++) - { - if (idx_cursors(l) == lengths(l)) - { - idx_cursors(l) = 0; - idx_cursors(l + 1)++; - cursor = starts(l) + step(l + 1); - for (int m = 0; m <= l; starts(m) = cursor, m++); - } - } - } + { + asub(k) = a(cursor++); + idx_cursors(0)++; + for (int l = 0; l < maxdims - 1; l++) + { + if (idx_cursors(l) == lengths(l)) + { + idx_cursors(l) = 0; + idx_cursors(l + 1)++; + cursor = starts(l) + step(l + 1); + for (int m = 0; m <= l; starts(m) = cursor, m++); + } + } + } // insert subarray into cell retval(i, 0) = octave_value (asub); // prepare next combination cidx(0)++; for (int j = 0; j < maxdims - 1; j++) - if (cidx(j) >= nidx(j)) - { - cidx(j) = 0; - cidx(j + 1)++; - } + if (cidx(j) >= nidx(j)) + { + cidx(j) = 0; + cidx(j + 1)++; + } } return retval; @@ -153,7 +149,7 @@ DEFUN_DLD (partarray, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} partarray (@var{a}, @var{idx}, ...)\n\ +@deftypefn {Loadable Function} {} partarray (@var{a}, @var{idx}, @dots{})\n\ Return a column cell array with subarrays of the @var{a}. Start and end indices of subarrays are given in the rows of @var{idx}. @var{idx} can be given for each dimension, empty @var{idx} means no partitioning in the respective dimension. Order of returned subarrays: rows of @var{idx} of some dimension are completely used before using the next row of @var{idx} of the higher dimension.\n\ \n\ Does not work with structure arrays at the moment.\n\ @@ -187,39 +183,39 @@ else if (array.is_numeric_type ()) { if (array.is_integer_type ()) - { - if (array.is_int8_type ()) - retval = do_partarray (array.int8_array_value (), fname, args); - else if (array.is_int16_type ()) - retval = do_partarray (array.int16_array_value (), fname, args); - else if (array.is_int32_type ()) - retval = do_partarray (array.int32_array_value (), fname, args); - else if (array.is_int64_type ()) - retval = do_partarray (array.int64_array_value (), fname, args); - else if (array.is_uint8_type ()) - retval = do_partarray (array.uint8_array_value (), fname, args); - else if (array.is_uint16_type ()) - retval = do_partarray (array.uint16_array_value (), fname, args); - else if (array.is_uint32_type ()) - retval = do_partarray (array.uint32_array_value (), fname, args); - else if (array.is_uint64_type ()) - retval = do_partarray (array.uint64_array_value (), fname, args); - } + { + if (array.is_int8_type ()) + retval = do_partarray (array.int8_array_value (), fname, args); + else if (array.is_int16_type ()) + retval = do_partarray (array.int16_array_value (), fname, args); + else if (array.is_int32_type ()) + retval = do_partarray (array.int32_array_value (), fname, args); + else if (array.is_int64_type ()) + retval = do_partarray (array.int64_array_value (), fname, args); + else if (array.is_uint8_type ()) + retval = do_partarray (array.uint8_array_value (), fname, args); + else if (array.is_uint16_type ()) + retval = do_partarray (array.uint16_array_value (), fname, args); + else if (array.is_uint32_type ()) + retval = do_partarray (array.uint32_array_value (), fname, args); + else if (array.is_uint64_type ()) + retval = do_partarray (array.uint64_array_value (), fname, args); + } else if (array.is_complex_type ()) - { - if (array.is_single_type ()) - retval = do_partarray (array.float_complex_array_value (), - fname, args); - else - retval = do_partarray (array.complex_array_value (), fname, args); - } + { + if (array.is_single_type ()) + retval = do_partarray (array.float_complex_array_value (), + fname, args); + else + retval = do_partarray (array.complex_array_value (), fname, args); + } else - { - if (array.is_single_type ()) - retval = do_partarray (array.float_array_value (), fname, args); - else - retval = do_partarray (array.array_value (), fname, args); - } + { + if (array.is_single_type ()) + retval = do_partarray (array.float_array_value (), fname, args); + else + retval = do_partarray (array.array_value (), fname, args); + } } // FIXME: This seems to work in cellfun.cc, but not here ... /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 19:36:45
|
Revision: 10042 http://octave.svn.sourceforge.net/octave/?rev=10042&view=rev Author: carandraug Date: 2012-03-24 19:36:34 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous/server.cc: removed from src and into devel since no one seems to know what to do with these Added Paths: ----------- trunk/octave-forge/main/miscellaneous/devel/ trunk/octave-forge/main/miscellaneous/devel/README trunk/octave-forge/main/miscellaneous/devel/listencanfork.c trunk/octave-forge/main/miscellaneous/devel/server.cc trunk/octave-forge/main/miscellaneous/devel/server.txt trunk/octave-forge/main/miscellaneous/devel/stringmatch.c Removed Paths: ------------- trunk/octave-forge/main/miscellaneous/doc/ trunk/octave-forge/main/miscellaneous/src/listencanfork.c trunk/octave-forge/main/miscellaneous/src/server.cc trunk/octave-forge/main/miscellaneous/src/stringmatch.c Added: trunk/octave-forge/main/miscellaneous/devel/README =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/README (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/README 2012-03-24 19:36:34 UTC (rev 10042) @@ -0,0 +1,9 @@ +On revision 10042 the files server.cc, listencanfork.c and stringmatch.c were +removed from the src/ directory of the miscellaneous package since no one on the +mailing list knew what to do with these files. The packages releases were also +not properly configured to handle it's code and even Debian packages of +miscellaneous do not include them. + +Looking at the code of server.cc, it seems to implement the functions server, +listen and senderror. Some of these would conflict with the functions in the +package sockets. Maybe this code should be merged with sockets. Copied: trunk/octave-forge/main/miscellaneous/devel/listencanfork.c (from rev 10023, trunk/octave-forge/main/miscellaneous/src/listencanfork.c) =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/listencanfork.c (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/listencanfork.c 2012-03-24 19:36:34 UTC (rev 10042) @@ -0,0 +1,13 @@ +#if defined(__CYGWIN__) +#include <windows.h> + +int listencanfork() +{ + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx (&osvi); + return (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS); +} +#else +int listencanfork() { return 1; } +#endif Copied: trunk/octave-forge/main/miscellaneous/devel/server.cc (from rev 10023, trunk/octave-forge/main/miscellaneous/src/server.cc) =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/server.cc (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/server.cc 2012-03-24 19:36:34 UTC (rev 10042) @@ -0,0 +1,824 @@ +#define STATUS(x) do { if (debug) std::cout << x << std::endl << std::flush; } while (0) + +//#define HAVE_OCTAVE_30 +#include <iomanip> +#include <iostream> +#include <cstdio> +#include <cctype> +#include <cstdlib> +//#include <unistd.h> +//#include <stdint.h> +#include <cerrno> +// #include <string.h> +#include <sys/types.h> + +#if (defined(_WIN32)||defined(_WIN64)) && !defined(__CYGWIN__) +# define USE_WINSOCK +# define CAN_FORK false +# include <winsock.h> +# include <io.h> + typedef int socklen_t; +#else +# define HAVE_FORK 1 +# define USE_SIGNALS +# if defined(__CYGWIN__) +# define CAN_FORK listencanfork() +# else +# define USE_DAEMONIZE +# define CAN_FORK true +# endif +# include <sys/socket.h> +# include <netinet/in.h> +# include <arpa/inet.h> +# include <sys/wait.h> +# include <signal.h> +# define closesocket close +#endif + + +#include <octave/oct.h> +#include <octave/parse.h> +#include <octave/variables.h> +#if 0 +#include <octave/unwind-prot.h> +#endif +#include <octave/oct-syscalls.h> +#include <octave/oct-time.h> +#include <octave/lo-mappers.h> +#include <octave/symtab.h> + +static bool debug = false; +static char* context = NULL; + +static double timestamp = 0.0; +inline void tic(void) { timestamp = octave_time().double_value(); } +inline double toc(void) {return ceil(-1e6*(timestamp-octave_time().double_value()));} + +// XXX FIXME XXX --- surely this is part of the standard library? +void +lowercase (std::string& s) +{ + for (std::string::iterator i=s.begin(); i != s.end(); i++) *i = tolower(*i); +} + +#if 0 +octave_value +get_builtin_value (const std::string& nm) +{ + octave_value retval; + + symbol_record *sr = fbi_sym_tab->lookup (nm); + + if (sr) + { + octave_value sr_def = sr->def (); + + if (sr_def.is_undefined ()) + error ("get_builtin_value: undefined symbol `%s'", nm.c_str ()); + else + retval = sr_def; + } + else + error ("get_builtin_value: unknown symbol `$s'", nm.c_str ()); + + return retval; +} +#endif + +#ifdef USE_WINSOCK + bool init_sockets() + { + + WSADATA wsaData; + WORD version; + int error; + + version = MAKEWORD( 2, 0 ); + + error = WSAStartup( version, &wsaData ); + + /* check for error */ + if ( error != 0 ) + { + /* error occured */ + return false; + } + + /* check for correct version */ + if ( LOBYTE( wsaData.wVersion ) != 2 || + HIBYTE( wsaData.wVersion ) != 0 ) + { + /* incorrect WinSock version */ + WSACleanup(); + return false; + } + return true; + } + + inline void end_sockets() { WSACleanup(); } + inline int socket_errno() { return WSAGetLastError(); } +#else // !USE_WINSOCK +# include <cerrno> + inline bool init_sockets() { return true; } + inline void end_sockets() { } + inline int socket_errno() { return errno; } +#endif // !USE_WINSOCK +inline void socket_error(const char *context) +{ + int err = socket_errno(); + char errno_str[15]; + snprintf(errno_str, sizeof(errno_str), " %d: ", err); + std::string msg = std::string(context) + std::string(errno_str) + + std::string (strerror(err)); + error(msg.c_str()); +} + +#ifdef USE_SIGNALS +static void +sigchld_handler(int /* sig */) +{ + int status; + /* Reap all childrens */ + STATUS("reaping all children"); + while (waitpid(-1, &status, WNOHANG) > 0) + ; + STATUS("done reaping children"); +} + +/* Posix signal handling, based on the example from the + * Unix Programming FAQ + * Copyright (C) 2000 Andrew Gierth + */ +static void sigchld_setup(void) +{ + struct sigaction act; + + /* Assign sig_chld as our SIGCHLD handler */ + act.sa_handler = sigchld_handler; + + /* We don't want to block any other signals in this example */ + sigemptyset(&act.sa_mask); + + /* + * We're only interested in children that have terminated, not ones + * which have been stopped (eg user pressing control-Z at terminal) + */ + act.sa_flags = SA_NOCLDSTOP; + + /* + * Make these values effective. If we were writing a real + * application, we would probably save the old value instead of + * passing NULL. + */ + if (sigaction(SIGCHLD, &act, NULL) < 0) + error("listen could not set SIGCHLD"); +} +#else +inline void sigchld_setup(void) { } +#endif + + +#ifdef USE_DAEMONIZE + +static RETSIGTYPE +sigterm_handler(int /* sig */) +{ + exit(0); +} + +static void +daemonize(void) +{ + if (fork()) exit(0); // Stop parent + // Show child PID + std::cout << "Octave pid: " << octave_syscalls::getpid() << std::endl; + std::cout.flush(); + signal(SIGTERM,sigterm_handler); + signal(SIGQUIT,sigterm_handler); + + +#if 1 + const char err[] = "/dev/null"; + const char out[] = "/dev/null"; +#else + const char err[] = "/tmp/octserver.err"; + const char out[] = "/tmp/octserver.out"; + std::cout << "redirecting to " << out << " and " << err << std::endl; std::cout.flush(); +#endif + + // Exit silently if I/O redirect fails. + if (freopen("/dev/null", "r", stdin) == NULL + || freopen(out, "w", stdout) == NULL + || freopen(err, "w", stderr) == NULL) { + // std::cerr << "ioredirect failed" << std::endl; std::cerr.flush(); + exit(0); + } + // std::cout << "ioredirect succeeded" << std::endl; std::cout.flush(); + //debug = true; +} + +#else +// Don't daemonize on cygwin just yet. +inline void daemonize(void) {} + +#endif // !DAEMONIZE + + + +static octave_value get_octave_value(char *name) +{ + octave_value def; + + // Copy variable from octave +#if defined(HAVE_TOP_LEVEL_SYM_TAB) + // Octave 3.0 + symbol_record *sr = top_level_sym_tab->lookup (name); + if (sr) def = sr->def(); +#elif defined(HAVE_VARREF) + // Octave 2.x + def = symbol_table::varref (std::string (name), symbol_table::top_scope ()); +#else + // Octave 3.2 + def = get_global_value(name); +#endif + + return def; +} + + +static void channel_error (const int channel, const char *str) +{ + STATUS("sending error !!!e (" << strlen(str) << ") " << str); + + uint32_t len = strlen(str); + send(channel,"!!!e",4,0); + uint32_t t = htonl(len); send(channel,(const char *)&t,4,0); + send(channel,str,len,0); +} + +static bool reads (const int channel, void * buf, int n) +{ + // STATUS("entering reads loop with size " << n); tic(); + while (1) { + int chunk = recv(channel, (char *)buf, n, 0); + if (chunk == 0) STATUS("read socket returned 0"); + if (chunk < 0) STATUS("read socket error " << socket_errno()); + if (chunk <= 0) return false; + n -= chunk; + // if (n == 0) STATUS("done reads loop after " << toc() << "us"); + if (n == 0) return true; + // STATUS("reading remaining " << n << " characters"); + buf = (void *)((char *)buf + chunk); + } +} + +static bool writes (const int channel, const void * buf, int n) +{ + // STATUS("entering writes loop"); + while (1) { + int chunk = send(channel, (const char *)buf, n, 0); + if (chunk == 0) STATUS("write socket returned 0"); + if (chunk < 0) STATUS("write socket: " << strerror(errno)); + if (chunk <= 0) return false; + n -= chunk; + // if (n == 0) STATUS("done writes loop"); + if (n == 0) return true; + buf = (void *)((char *)buf + chunk); + } +} + +static void +process_commands(int channel) +{ + // XXX FIXME XXX check read/write return values + assert(sizeof(uint32_t) == 4); + char command[5]; + char def_context[16536]; + bool ok; + STATUS("waiting for command"); + + // XXX FIXME XXX do we need to specify the context size? + // int bufsize=sizeof(def_context); + // socklen_t ol; + // ol=sizeof(bufsize); + // setsockopt(channel,SOL_SOCKET,SO_SNDBUF,&bufsize,ol); + // setsockopt(channel,SOL_SOCKET,SO_RCVBUF,&bufsize,ol); + + // XXX FIXME XXX prepare to capture long jumps, because if + // we dont, then errors in octave might escape to the prompt + + command[4] = '\0'; + if (debug) tic(); + while (reads(channel, &command, 4)) { + // XXX FIXME XXX do whatever is require to check if function files + // have changed; do we really want to do this for _every_ command? + // Maybe we need a 'reload' command. + STATUS("received command " << command << " after " << toc() << "us"); + + // Check for magic command code + if (command[0] != '!' || command[1] != '!' || command[2] != '!') { + STATUS("communication error: closing connection"); + break; + } + + // Get command length + if (debug) tic(); // time the read + uint32_t len; + if (!reads(channel, &len, 4)) break; + len = ntohl(len); + // STATUS("read 4 byte command length in " << toc() << "us"); + + // Read the command context, allocating a new one if the default + // is too small. + if (len > (signed)sizeof(def_context)-1) { + // XXX FIXME XXX use octave allocators + // XXX FIXME XXX unwind_protect + context= new char[len+1]; + if (context== NULL) { + // Requested command is too large --- skip to the next command + // XXX FIXME XXX maybe we want to kill the connection instead? + channel_error(channel,"out of memory"); + ok = true; + STATUS("skip big command loop"); + while (ok && len > (signed)sizeof(def_context)) { + ok = reads(channel, def_context, sizeof(def_context)); + len -= sizeof(def_context); + } + STATUS("done skip big command loop"); + if (!ok) break; + ok = reads(channel, def_context, sizeof(def_context)); + if (!ok) break; + continue; + } + } else { + context = def_context; + } + // if (debug) tic(); + ok = reads(channel, context, len); + context[len] = '\0'; + STATUS("read " << len << " byte command in " << toc() << "us"); + + // Process the command + if (ok) switch (command[3]) { + case 'm': // send the named matrix + { + // XXX FIXME XXX this can be removed: app can do send(name,value) + STATUS("sending " << context); + uint32_t t; + + // read the matrix contents + octave_value def = get_octave_value(context); + if(!def.is_defined() || !def.is_real_matrix()) + channel_error(channel,"not a matrix"); + Matrix m = def.matrix_value(); + + // write the matrix transfer header + ok = writes(channel,"!!!m",4); // matrix message + t = htonl(12 + sizeof(double)*m.rows()*m.columns()); + if (ok) ok = writes(channel,&t,4); // length of message + t = htonl(m.rows()); + if (ok) ok = writes(channel,&t,4); // rows + t = htonl(m.columns()); + if (ok) ok = writes(channel,&t,4); // columns + t = htonl(len); + if (ok) ok = writes(channel, &t, 4); // name length + if (ok) ok = writes(channel,context,len); // name + + // write the matrix contents + const double *v = m.data(); // data + if (ok) ok = writes(channel,v,sizeof(double)*m.rows()*m.columns()); + if (ok) + STATUS("sent " << m.rows()*m.columns()); + else + STATUS("failed " << m.rows()*m.columns()); + } + break; + + case 'x': // silently execute the command + { + if (debug) + { + if (len > 500) + { + // XXX FIXME XXX can we limit the maximum output width for a + // string? The setprecision() io manipulator doesn't do it. + // In the meantime, a hack ... + char t = context[400]; context[400] = '\0'; + STATUS("evaluating (" << len << ") " + << context << std::endl + << "..." << std::endl + << context+len-100); + context[400] = t; + } + else + { + STATUS("evaluating (" << len << ") " << context); + } + } + + if (debug) tic(); +#if 1 + error_state = 0; + int parse_status = 0; + eval_string(context, true, parse_status, 0); + if (parse_status != 0 || error_state) + eval_string("senderror(lasterr);", true, parse_status, 0); +#elif 0 + octave_value_list evalargs; + evalargs(1) = "senderror(lasterr);"; + evalargs(0) = context; + octave_value_list fret = feval("eval",evalargs,0); +#else + evalargs(0) = octave_value(0.); +#endif + STATUS("done command"); + } + STATUS("free evalargs"); + break; + + case 'c': // execute the command and capture stdin/stdout + STATUS("capture command not yet implemented"); + break; + + default: + STATUS("ignoring command " << command); + break; + } + + if (context != def_context) delete[] context; + STATUS("done " << command); + if (!ok) break; + if (debug) tic(); + } +} + + +int channel = -1; + +DEFUN_DLD(senderror,args,,"\ +Send the given error message across the socket. The error context\n\ +is taken to be the last command received from the socket.") +{ + std::string str; + const int nargin = args.length(); + if (nargin != 1) str="senderror not called with error"; + else str = args(0).string_value(); + + // provide a context for the error (but not too much!) + str += "when evaluating:\n"; + if (strlen(context) > 100) + { + char t=context[100]; + context[100] = '\0'; + str+=context; + context[100]=t; + } + else + str += context; + + STATUS("error is " << str); + channel_error(channel,str.c_str()); + return octave_value_list(); +} + +DEFUN_DLD(send,args,,"\ +send(str)\n\ + Send a command on the current connection\n\ +send(name,value)\n\ + Send a binary value with the given name on the current connection\n\ +") +{ + bool ok; + uint32_t t; + octave_value_list ret; + int nargin = args.length(); + if (nargin < 1 || nargin > 2) + { + print_usage (); + return ret; + } + + if (channel < 0) { + error("Not presently listening on a port"); + return ret; + } + + std::string cmd(args(0).string_value()); + if (error_state) return ret; + + // XXX FIXME XXX perhaps process the panalopy of types? + if (nargin > 1) { + + octave_value def = args(1); + if (args(1).is_string()) { + // Grab the string value from args(1). + // Can't use args(1).string_value() because that trims trailing \0 + charMatrix m(args(1).char_matrix_value()); + std::string s(m.row_as_string(0,false,true)); + STATUS("sending string(" << cmd.c_str() << " len " << s.length() << ")"); + ok = writes(channel,"!!!s",4); // string message + t = htonl(8 + cmd.length() + s.length()); + if (ok) ok = writes(channel,&t,4); // length of message + t = htonl(s.length()); + if (ok) ok = writes(channel, &t, 4); // string length + t = htonl(cmd.length()); + if (ok) ok = writes(channel, &t, 4); // name length + if (cmd.length() && ok) + ok = writes(channel, cmd.c_str(), cmd.length()); // name + if (s.length() && ok) + ok = writes(channel, s.c_str(), s.length()); // string + } else if (args(1).is_real_type()) { + Matrix m(args(1).matrix_value()); + STATUS("sending matrix(" << cmd.c_str() << " " + << m.rows() << "x" << m.columns() << ")"); + + // write the matrix transfer header + ok = writes(channel,"!!!m",4); // matrix message + t = htonl(12 + cmd.length() + sizeof(double)*m.rows()*m.columns()); + if (ok) ok = writes(channel,&t,4); // length of message + t = htonl(m.rows()); + if (ok) ok = writes(channel,&t,4); // rows + t = htonl(m.columns()); + if (ok) ok = writes(channel,&t,4); // columns + t = htonl(cmd.length()); + if (ok) ok = writes(channel, &t, 4); // name length + if (ok) ok = writes(channel, cmd.c_str(), cmd.length()); // name + + // write the matrix contents + const double *v = m.data(); // data + if (m.rows()*m.columns() && ok) + ok = writes(channel,v,sizeof(double)*m.rows()*m.columns()); + } else { + ok = false; + error("send expected name and matrix or string value"); + } + if (!ok) error("send could not write to channel"); + } else { + STATUS("sending command(" << cmd.length() << ") " << cmd.c_str()); + // STATUS("start writing at "<<toc()<<"us"); + ok = writes(channel, "!!!x", 4); + t = htonl(cmd.length()); writes(channel, &t, 4); + if (ok) ok = writes(channel, cmd.c_str(), cmd.length()); + if (!ok) error("send could not write to channel"); + // STATUS("stop writing at "<<toc()<<"us"); + } + + return ret; +} + +extern "C" int listencanfork(void); +extern "C" int StringCaseMatch(const char* s, const char* p, int nocase); + +bool ishostglob(const std::string& s) +{ + for (unsigned int i=0; i < s.length(); i++) { + if (! ( isdigit(s[i]) || s[i]=='*' || s[i]=='-' + || s[i]=='.' || s[i]=='[' || s[i]==']')) return false; + } + return true; +} + +bool anyhostglob(const string_vector& hostlist, const char* host) +{ + for (int j=0; j < hostlist.length(); j++) { + if (StringCaseMatch(host, hostlist[j].c_str(), 0)) return true; + } + return false; +} + +// Known bug: functions which pass or return structures use a +// different ABI for gcc and native compilers on some architectures. +// Whether this is a bug depends on the structure length. SGI's 64-bit +// architecture makes this a problem for inet_ntoa. +#if defined(__GNUC__) && defined(_sgi) +#define BROKEN_INET_NTOA +#endif + +#ifdef BROKEN_INET_NTOA + +/************************************************* +* Replacement for broken inet_ntoa() * +*************************************************/ + + +/* On IRIX systems, gcc uses a different structure passing convention to the +native libraries. This causes inet_ntoa() to always yield 0.0.0.0 or +255.255.255.255. To get round this, we provide a private version of the +function here. It is used only if USE_INET_NTOA_FIX is set, which should +happen +only when gcc is in use on an IRIX system. Code send to me by J.T. Breitner, +with these comments: + + + code by Stuart Levy + as seen in comp.sys.sgi.admin + + +Arguments: sa an in_addr structure +Returns: pointer to static text string +*/ + + +char * +inet_ntoa(struct in_addr sa) +{ +static char addr[20]; +sprintf(addr, "%d.%d.%d.%d", + (US &sa.s_addr)[0], + (US &sa.s_addr)[1], + (US &sa.s_addr)[2], + (US &sa.s_addr)[3]); + return addr; +} + +#endif /* BROKEN_INET_NTOA */ + + +void _autoload(const char name[]) +{ + octave_value_list evalargs, fret; + evalargs(0) = "server"; + fret = feval("which",evalargs,1); + evalargs(0) = name; + evalargs(1) = fret(0); + fret = feval("autoload",evalargs,0); +} + +DEFUN_DLD(server,args,,"\ +server(port,host,host,...)\n\ + Listen for connections on the given port. Normally only accepts\n\ + connections from localhost (127.0.0.1), but you can specify any\n\ + dot-separated host name globs. E.g., '128.2.20.*' or '128.2.2[012].*'\n\ + Use '?' for '[0123456789]'. Use '*.*.*.*' for any host.\n\ +server(...,'debug'|'nodebug')\n\ + If debug, echo all commands sent across the connection. If nodebug,\n\ + detach the process and don't echo anything. You will need to use\n\ + kill directly to end the process. Nodebug is the default.\n\ +server(...,'fork'|'nofork')\n\ + If fork, start new server for each connection. If nofork, only allow\n\ + one connection at a time. Fork is the default (depending on system).\n\ +server(...,'loopback')\n\ + Use loopback address 127.0.0.1 rather than 0.0.0.0.\n\ +") +{ + bool canfork = CAN_FORK; + + _autoload("send"); + _autoload("senderror"); + octave_value_list ret; + int nargin = args.length(); + if (nargin < 1) + { + print_usage (); + return ret; + } + int port = args(0).int_value(); + if (error_state) return ret; + + // Winsock requires initialization + if (!init_sockets()) + { + socket_error("init"); + return ret; + } + + + debug = false; + uint32_t inaddr = INADDR_ANY; + + string_vector hostlist; + hostlist.append(std::string("127.0.0.1")); + for (int k = 1; k < nargin; k++) { + std::string lastarg(args(k).string_value()); + if (error_state) return ret; + lowercase(lastarg); + if (lastarg == "debug") { + debug = true; + } else if (lastarg == "nodebug") { + debug = false; + } else if (lastarg == "fork") { + canfork = true; + } else if (lastarg == "nofork") { + canfork = false; + } else if (lastarg == "loopback") { + inaddr = INADDR_LOOPBACK; + } else if (ishostglob(lastarg)) { + hostlist.append(lastarg); + } else { + print_usage (); + } + } + + int sockfd; // listen on sockfd, new connection channel + struct sockaddr_in my_addr; // my address information + struct sockaddr_in their_addr; // connector's address information + socklen_t sin_size; + int yes=1; + + sockfd = socket(AF_INET, SOCK_STREAM, 0); + if (sockfd == -1) { + socket_error("socket"); + return ret; + } + + if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,(const char *)(&yes),sizeof(yes)) == -1) { + socket_error("setsockopt"); + return ret; + } + + my_addr.sin_family = AF_INET; // host byte order + my_addr.sin_port = htons(port); // short, network byte order + my_addr.sin_addr.s_addr = htonl(inaddr); // automatically fill with my IP + memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct + + if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) + == -1) { + socket_error("bind"); + closesocket(sockfd); + return ret; + } + + /* listen for connections (allowing one pending connection) */ + if (listen(sockfd, canfork?1:0) == -1) { + socket_error("listen"); + closesocket(sockfd); + return ret; + } + +#if 0 + unwind_protect::begin_frame("Fserver"); + unwind_protect_bool (buffer_error_messages); + buffer_error_messages = true; +#endif + + sigchld_setup(); + if (!debug && canfork) daemonize(); + + // XXX FIXME XXX want a 'sandbox' option which disables fopen, cd, pwd, + // system, popen ... Or maybe just an initial script to run for each + // connection, plus a separate command to disable specific functions. + STATUS("listening on port " << port); + while(1) { // main accept() loop + sin_size = sizeof(struct sockaddr_in); + STATUS("trying to accept"); + if ((channel = accept(sockfd, (struct sockaddr *)&their_addr, + &sin_size)) == -1) { + // XXX FIXME XXX + // Linux is returning "Interrupted system call" when the + // child terminates. Until I figure out why, I can't use + // accept errors as a basis for breaking out of the listen + // loop, so instead print the octave PID so that I can kill + // it from another terminal. + STATUS("failed to accept" << std::endl + << "Octave pid: " << octave_syscalls::getpid() ); + perror("accept"); +#if defined(_sgi) + break; +#else + continue; +#endif + } + STATUS("connected"); + + /* Simulate inet_ntoa */ + const char *them = inet_ntoa(their_addr.sin_addr); + STATUS("server: got connection from " << them); + + if (anyhostglob(hostlist,them)) { +#ifdef HAVE_FORK + if (canfork) { + int pid = fork(); + if (pid == -1) { + socket_error("fork"); + break; + } else if (pid == 0) { + closesocket(sockfd); // child doesn't need listener + signal(SIGCHLD,SIG_DFL); // child doesn't need SIGCHLD signal + process_commands(channel); + STATUS("child is exitting"); + exit(0); + } + } else { + process_commands(channel); + STATUS("server: connection closed"); + } +#else // !HAVE_FORK + process_commands(channel); + STATUS("server: connection closed"); +#endif // !HAVE_FORK + } else { + STATUS("server: connection refused."); + } + + closesocket(channel); + channel = -1; + } + + STATUS("could not read commands; returning"); + closesocket(sockfd); + end_sockets(); +#if 0 + unwind_protect::run_frame("Fserver"); +#endif + return ret; +} Copied: trunk/octave-forge/main/miscellaneous/devel/server.txt (from rev 10023, trunk/octave-forge/main/miscellaneous/doc/server.txt) =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/server.txt (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/server.txt 2012-03-24 19:36:34 UTC (rev 10042) @@ -0,0 +1,118 @@ +You can talk to octave directly from other environments over the tcp/ip. +The protocol is not sophisticated. + +Here is what you can send to octave: + +!!!x length command + + evaluate command in octave. + length is a 32-bit network order integer. + command is a string (without zero-terminator). + +!!!m length name + + send matrix back to client. + length is a 32-bit network order integer. + name is a string (without zero-terminator). + + I don't use the !!!m command to the server because it is the same as + + !!!x send('name', matrix expression) + + The latter is much more useful because you don't have to name + the data that you are sending across. + +!!!n length namelen name command + + *** Not implemented *** + Evaluate the command in the namespace. This needs a lookup table + Map<string,symbol_table> namespace + and a command + evalin(symbol_table,command) + The function evalin pushes the given symbol table onto curr_sym_tab, + evaluates the command then pops the symbol table. + +Here is what you will receive from octave: + +!!!m length rows columns namelength name data + + recieve matrix from server. + length,rows,columns,namelength are 32-bit network order integers. + name is a string (without zero-terminator). + data is an array of rows*columns server order double values. + + This is sent in response to a !!!m matrix request or a + send('name',matrix) command. + + The first thing I do when I open a connection is request a matrix + containing 1.0. If the result is not 1.0, I know that I need to + swap the data to convert from server order to client order doubles. + +!!!s length strlen namelen name str + + receive string from server. + length, strlen, namelen are 32-bit network order integers. + name is a string (without zero-terminator). + str is a string (without zero-terminator). + + This is sent in response to a send('name',string) command. + +!!!x length str + + evaluate string in client. + length is a 32-bit network order integer. + str is a string (without zero-terminator). + + This is sent in response to a send('str'). The contents of str + are completely arbitrary (and may indeed contain binary data). It is + up to the client to decide how they want to interpret these strings. + +!!!e length error + + receive error from octave. + length is a 32-bit network order integer. + error is a string (without zero-terminator). + + This is sent in response to a !!!x command which produced an error. + +Composite values can be decomposed into their constituent parts. E.g., + structures: + for [v,k]=x, send([name,'.',k],v); end + complex arrays: + send([name,'.real'],real(x)); + send([name,'.imag'],imag(x)); + sparse arrays: + [v,i,j] = spfind(x); + send([name,'.i'],i); + send([name,'.j'],j); + send([name,'.v'],v); + cell arrays: + [nr,nc]=size(x); + for r=1:nr, for c=1:nc, send([name,sprintf('.%d.%d',r,c)],x{r,c}); end + +Note that the communication is completely asynchronous. I have a tcl client +that processes server responses via fileevent. That means that responses from +octave are not processed until tcl enters its event loop. + +To be sure that octave has processed a command I follow that command with a +synchronization sequence: + + set sync[incr syncid] 1 + octave eval "send('unset sync$syncid')" + vwait sync$syncid + +In practice it is more complicated than that because I allow the +syncronization command to time out just in case octave crashed out from +underneath me, but the idea is the same. + +Using sockets gives you platform independence and network transparency, +which is a big win. The only caveat is that winsock is slow. The best I +can do with dedicated winsock code on my machine is .3 seconds to transfer +a 1 Mb message. Under tcl/tk, it was closer to 1 second IIRC. A memory +copy of the same size took less than 0.06 seconds IIRC. + +That is why I'm working on a way to embed octave into tcl. Hopefully +it will be easy to embed in other environments as well. + +Paul Kienzle +2003 Copied: trunk/octave-forge/main/miscellaneous/devel/stringmatch.c (from rev 10023, trunk/octave-forge/main/miscellaneous/src/stringmatch.c) =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/stringmatch.c (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/stringmatch.c 2012-03-24 19:36:34 UTC (rev 10042) @@ -0,0 +1,242 @@ +/* Extracted from tclUtil.c + +Copyright (c) 1987-1993 The Regents of the University of California. +Copyright (c) 1994-1998 Sun Microsystems, Inc. +Copyright (c) 2001 by Kevin B. Kenny. All rights reserved. + + +This software is copyrighted by the Regents of the University of +California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState +Corporation and other parties. The following terms apply to all files +associated with the software unless explicitly disclaimed in +individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +GOVERNMENT USE: If you are acquiring this software on behalf of the +U.S. government, the Government shall have only "Restricted Rights" +in the software and related documentation as defined in the Federal +Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you +are acquiring the software on behalf of the Department of Defense, the +software shall be classified as "Commercial Computer Software" and the +Government shall have only "Restricted Rights" as defined in Clause +252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the +authors grant the U.S. Government and others acting in its behalf +permission to use and distribute the software in accordance with the +terms specified in this license. + + */ + + +/* + *---------------------------------------------------------------------- + * + * StringCaseMatch -- + * + * See if a particular string matches a particular pattern. + * Allows case insensitivity. + * + * Results: + * The return value is 1 if string matches pattern, and + * 0 otherwise. The matching operation permits the following + * special characters in the pattern: *?\[] (see the manual + * entry for details on what these mean). + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +#include <ctype.h> /* PAK: need tolower declaration */ +#define CONST const +#define UCHAR (unsigned char) + +/* Note: restore original code from the Tcl tree if you want unicode + * support. */ + +int +StringCaseMatch(string, pattern, nocase) + CONST char *string; /* String. */ + CONST char *pattern; /* Pattern, which may contain special + * characters. */ + int nocase; /* 0 for case sensitive, 1 for insensitive */ +{ + int p /*, charLen*/; /* PAK: unused */ + /* CONST char *pstart = pattern; */ /* PAK: unused */ + char ch1, ch2; + + while (1) { + p = *pattern; + + /* + * See if we're at the end of both the pattern and the string. If + * so, we succeeded. If we're at the end of the pattern but not at + * the end of the string, we failed. + */ + + if (p == '\0') { + return (*string == '\0'); + } + if ((*string == '\0') && (p != '*')) { + return 0; + } + + /* + * Check for a "*" as the next pattern character. It matches + * any substring. We handle this by calling ourselves + * recursively for each postfix of string, until either we + * match or we reach the end of the string. + */ + + if (p == '*') { + /* + * Skip all successive *'s in the pattern + */ + while (*(++pattern) == '*') {} + p = *pattern; + if (p == '\0') { + return 1; + } + ch2 = (nocase ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); + while (1) { + /* + * Optimization for matching - cruise through the string + * quickly if the next char in the pattern isn't a special + * character + */ + if ((p != '[') && (p != '?') && (p != '\\')) { + if (nocase) { + while (*string) { + ch1 = *string; + if (ch2==ch1 || ch2==tolower(ch1)) break; + string++; + } + } else { + while (*string) { + ch1 = *string; + if (ch2==ch1) break; + string++; + } + } + } + if (StringCaseMatch(string, pattern, nocase)) { + return 1; + } + if (*string == '\0') { + return 0; + } + string++; + } + } + + /* + * Check for a "?" as the next pattern character. It matches + * any single character. + */ + + if (p == '?') { + pattern++; + string++; + continue; + } + + /* + * Check for a "[" as the next pattern character. It is followed + * by a list of characters that are acceptable, or by a range + * (two characters separated by "-"). + */ + + if (p == '[') { + char startChar, endChar; + + pattern++; + ch1 = (nocase ? tolower(UCHAR(*string)) : UCHAR(*string)); + string++; + while (1) { + if ((*pattern == ']') || (*pattern == '\0')) { + return 0; + } + startChar = + (nocase ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); + pattern++; + if (*pattern == '-') { + pattern++; + if (*pattern == '\0') { + return 0; + } + endChar = + (nocase ? tolower(UCHAR(*pattern)) : UCHAR(*pattern)); + pattern++; + if (((startChar <= ch1) && (ch1 <= endChar)) + || ((endChar <= ch1) && (ch1 <= startChar))) { + /* + * Matches ranges of form [a-z] or [z-a]. + */ + + break; + } + } else if (startChar == ch1) { + break; + } + } + while (*pattern != ']') { + if (*pattern == '\0') { + pattern--; + break; + } + pattern++; + } + pattern++; + continue; + } + + /* + * If the next pattern character is '\', just strip off the '\' + * so we do exact matching on the character that follows. + */ + + if (p == '\\') { + pattern++; + if (*pattern == '\0') { + return 0; + } + } + + /* + * There's no special character. Just make sure that the next + * bytes of each string match. + */ + + ch1 = *string++; + ch2 = *pattern++; + if (nocase) { + if (tolower(ch1) != tolower(ch2)) { + return 0; + } + } else if (ch1 != ch2) { + return 0; + } + } +} Deleted: trunk/octave-forge/main/miscellaneous/src/listencanfork.c =================================================================== --- trunk/octave-forge/main/miscellaneous/src/listencanfork.c 2012-03-24 19:34:52 UTC (rev 10041) +++ trunk/octave-forge/main/miscellaneous/src/listencanfork.c 2012-03-24 19:36:34 UTC (rev 10042) @@ -1,13 +0,0 @@ -#if defined(__CYGWIN__) -#include <windows.h> - -int listencanfork() -{ - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx (&osvi); - return (osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS); -} -#else -int listencanfork() { return 1; } -#endif Deleted: trunk/octave-forge/main/miscellaneous/src/server.cc =================================================================== --- trunk/octave-forge/main/miscellaneous/src/server.cc 2012-03-24 19:34:52 UTC (rev 10041) +++ trunk/octave-forge/main/miscellaneous/src/server.cc 2012-03-24 19:36:34 UTC (rev 10042) @@ -1,824 +0,0 @@ -#define STATUS(x) do { if (debug) std::cout << x << std::endl << std::flush; } while (0) - -//#define HAVE_OCTAVE_30 -#include <iomanip> -#include <iostream> -#include <cstdio> -#include <cctype> -#include <cstdlib> -//#include <unistd.h> -//#include <stdint.h> -#include <cerrno> -// #include <string.h> -#include <sys/types.h> - -#if (defined(_WIN32)||defined(_WIN64)) && !defined(__CYGWIN__) -# define USE_WINSOCK -# define CAN_FORK false -# include <winsock.h> -# include <io.h> - typedef int socklen_t; -#else -# define HAVE_FORK 1 -# define USE_SIGNALS -# if defined(__CYGWIN__) -# define CAN_FORK listencanfork() -# else -# define USE_DAEMONIZE -# define CAN_FORK true -# endif -# include <sys/socket.h> -# include <netinet/in.h> -# include <arpa/inet.h> -# include <sys/wait.h> -# include <signal.h> -# define closesocket close -#endif - - -#include <octave/oct.h> -#include <octave/parse.h> -#include <octave/variables.h> -#if 0 -#include <octave/unwind-prot.h> -#endif -#include <octave/oct-syscalls.h> -#include <octave/oct-time.h> -#include <octave/lo-mappers.h> -#include <octave/symtab.h> - -static bool debug = false; -static char* context = NULL; - -static double timestamp = 0.0; -inline void tic(void) { timestamp = octave_time().double_value(); } -inline double toc(void) {return ceil(-1e6*(timestamp-octave_time().double_value()));} - -// XXX FIXME XXX --- surely this is part of the standard library? -void -lowercase (std::string& s) -{ - for (std::string::iterator i=s.begin(); i != s.end(); i++) *i = tolower(*i); -} - -#if 0 -octave_value -get_builtin_value (const std::string& nm) -{ - octave_value retval; - - symbol_record *sr = fbi_sym_tab->lookup (nm); - - if (sr) - { - octave_value sr_def = sr->def (); - - if (sr_def.is_undefined ()) - error ("get_builtin_value: undefined symbol `%s'", nm.c_str ()); - else - retval = sr_def; - } - else - error ("get_builtin_value: unknown symbol `$s'", nm.c_str ()); - - return retval; -} -#endif - -#ifdef USE_WINSOCK - bool init_sockets() - { - - WSADATA wsaData; - WORD version; - int error; - - version = MAKEWORD( 2, 0 ); - - error = WSAStartup( version, &wsaData ); - - /* check for error */ - if ( error != 0 ) - { - /* error occured */ - return false; - } - - /* check for correct version */ - if ( LOBYTE( wsaData.wVersion ) != 2 || - HIBYTE( wsaData.wVersion ) != 0 ) - { - /* incorrect WinSock version */ - WSACleanup(); - return false; - } - return true; - } - - inline void end_sockets() { WSACleanup(); } - inline int socket_errno() { return WSAGetLastError(); } -#else // !USE_WINSOCK -# include <cerrno> - inline bool init_sockets() { return true; } - inline void end_sockets() { } - inline int socket_errno() { return errno; } -#endif // !USE_WINSOCK -inline void socket_error(const char *context) -{ - int err = socket_errno(); - char errno_str[15]; - snprintf(errno_str, sizeof(errno_str), " %d: ", err); - std::string msg = std::string(context) + std::string(errno_str) - + std::string (strerror(err)); - error(msg.c_str()); -} - -#ifdef USE_SIGNALS -static void -sigchld_handler(int /* sig */) -{ - int status; - /* Reap all childrens */ - STATUS("reaping all children"); - while (waitpid(-1, &status, WNOHANG) > 0) - ; - STATUS("done reaping children"); -} - -/* Posix signal handling, based on the example from the - * Unix Programming FAQ - * Copyright (C) 2000 Andrew Gierth - */ -static void sigchld_setup(void) -{ - struct sigaction act; - - /* Assign sig_chld as our SIGCHLD handler */ - act.sa_handler = sigchld_handler; - - /* We don't want to block any other signals in this example */ - sigemptyset(&act.sa_mask); - - /* - * We're only interested in children that have terminated, not ones - * which have been stopped (eg user pressing control-Z at terminal) - */ - act.sa_flags = SA_NOCLDSTOP; - - /* - * Make these values effective. If we were writing a real - * application, we would probably save the old value instead of - * passing NULL. - */ - if (sigaction(SIGCHLD, &act, NULL) < 0) - error("listen could not set SIGCHLD"); -} -#else -inline void sigchld_setup(void) { } -#endif - - -#ifdef USE_DAEMONIZE - -static RETSIGTYPE -sigterm_handler(int /* sig */) -{ - exit(0); -} - -static void -daemonize(void) -{ - if (fork()) exit(0); // Stop parent - // Show child PID - std::cout << "Octave pid: " << octave_syscalls::getpid() << std::endl; - std::cout.flush(); - signal(SIGTERM,sigterm_handler); - signal(SIGQUIT,sigterm_handler); - - -#if 1 - const char err[] = "/dev/null"; - const char out[] = "/dev/null"; -#else - const char err[] = "/tmp/octserver.err"; - const char out[] = "/tmp/octserver.out"; - std::cout << "redirecting to " << out << " and " << err << std::endl; std::cout.flush(); -#endif - - // Exit silently if I/O redirect fails. - if (freopen("/dev/null", "r", stdin) == NULL - || freopen(out, "w", stdout) == NULL - || freopen(err, "w", stderr) == NULL) { - // std::cerr << "ioredirect failed" << std::endl; std::cerr.flush(); - exit(0); - } - // std::cout << "ioredirect succeeded" << std::endl; std::cout.flush(); - //debug = true; -} - -#else -// Don't daemonize on cygwin just yet. -inline void daemonize(void) {} - -#endif // !DAEMONIZE - - - -static octave_value get_octave_value(char *name) -{ - octave_value def; - - // Copy variable from octave -#if defined(HAVE_TOP_LEVEL_SYM_TAB) - // Octave 3.0 - symbol_record *sr = top_level_sym_tab->lookup (name); - if (sr) def = sr->def(); -#elif defined(HAVE_VARREF) - // Octave 2.x - def = symbol_table::varref (std::string (name), symbol_table::top_scope ()); -#else - // Octave 3.2 - def = get_global_value(name); -#endif - - return def; -} - - -static void channel_error (const int channel, const char *str) -{ - STATUS("sending error !!!e (" << strlen(str) << ") " << str); - - uint32_t len = strlen(str); - send(channel,"!!!e",4,0); - uint32_t t = htonl(len); send(channel,(const char *)&t,4,0); - send(channel,str,len,0); -} - -static bool reads (const int channel, void * buf, int n) -{ - // STATUS("entering reads loop with size " << n); tic(); - while (1) { - int chunk = recv(channel, (char *)buf, n, 0); - if (chunk == 0) STATUS("read socket returned 0"); - if (chunk < 0) STATUS("read socket error " << socket_errno()); - if (chunk <= 0) return false; - n -= chunk; - // if (n == 0) STATUS("done reads loop after " << toc() << "us"); - if (n == 0) return true; - // STATUS("reading remaining " << n << " characters"); - buf = (void *)((char *)buf + chunk); - } -} - -static bool writes (const int channel, const void * buf, int n) -{ - // STATUS("entering writes loop"); - while (1) { - int chunk = send(channel, (const char *)buf, n, 0); - if (chunk == 0) STATUS("write socket returned 0"); - if (chunk < 0) STATUS("write socket: " << strerror(errno)); - if (chunk <= 0) return false; - n -= chunk; - // if (n == 0) STATUS("done writes loop"); - if (n == 0) return true; - buf = (void *)((char *)buf + chunk); - } -} - -static void -process_commands(int channel) -{ - // XXX FIXME XXX check read/write return values - assert(sizeof(uint32_t) == 4); - char command[5]; - char def_context[16536]; - bool ok; - STATUS("waiting for command"); - - // XXX FIXME XXX do we need to specify the context size? - // int bufsize=sizeof(def_context); - // socklen_t ol; - // ol=sizeof(bufsize); - // setsockopt(channel,SOL_SOCKET,SO_SNDBUF,&bufsize,ol); - // setsockopt(channel,SOL_SOCKET,SO_RCVBUF,&bufsize,ol); - - // XXX FIXME XXX prepare to capture long jumps, because if - // we dont, then errors in octave might escape to the prompt - - command[4] = '\0'; - if (debug) tic(); - while (reads(channel, &command, 4)) { - // XXX FIXME XXX do whatever is require to check if function files - // have changed; do we really want to do this for _every_ command? - // Maybe we need a 'reload' command. - STATUS("received command " << command << " after " << toc() << "us"); - - // Check for magic command code - if (command[0] != '!' || command[1] != '!' || command[2] != '!') { - STATUS("communication error: closing connection"); - break; - } - - // Get command length - if (debug) tic(); // time the read - uint32_t len; - if (!reads(channel, &len, 4)) break; - len = ntohl(len); - // STATUS("read 4 byte command length in " << toc() << "us"); - - // Read the command context, allocating a new one if the default - // is too small. - if (len > (signed)sizeof(def_context)-1) { - // XXX FIXME XXX use octave allocators - // XXX FIXME XXX unwind_protect - context= new char[len+1]; - if (context== NULL) { - // Requested command is too large --- skip to the next command - // XXX FIXME XXX maybe we want to kill the connection instead? - channel_error(channel,"out of memory"); - ok = true; - STATUS("skip big command loop"); - while (ok && len > (signed)sizeof(def_context)) { - ok = reads(channel, def_context, sizeof(def_context)); - len -= sizeof(def_context); - } - STATUS("done skip big command loop"); - if (!ok) break; - ok = reads(channel, def_context, sizeof(def_context)); - if (!ok) break; - continue; - } - } else { - context = def_context; - } - // if (debug) tic(); - ok = reads(channel, context, len); - context[len] = '\0'; - STATUS("read " << len << " byte command in " << toc() << "us"); - - // Process the command - if (ok) switch (command[3]) { - case 'm': // send the named matrix - { - // XXX FIXME XXX this can be removed: app can do send(name,value) - STATUS("sending " << context); - uint32_t t; - - // read the matrix contents - octave_value def = get_octave_value(context); - if(!def.is_defined() || !def.is_real_matrix()) - channel_error(channel,"not a matrix"); - Matrix m = def.matrix_value(); - - // write the matrix transfer header - ok = writes(channel,"!!!m",4); // matrix message - t = htonl(12 + sizeof(double)*m.rows()*m.columns()); - if (ok) ok = writes(channel,&t,4); // length of message - t = htonl(m.rows()); - if (ok) ok = writes(channel,&t,4); // rows - t = htonl(m.columns()); - if (ok) ok = writes(channel,&t,4); // columns - t = htonl(len); - if (ok) ok = writes(channel, &t, 4); // name length - if (ok) ok = writes(channel,context,len); // name - - // write the matrix contents - const double *v = m.data(); // data - if (ok) ok = writes(channel,v,sizeof(double)*m.rows()*m.columns()); - if (ok) - STATUS("sent " << m.rows()*m.columns()); - else - STATUS("failed " << m.rows()*m.columns()); - } - break; - - case 'x': // silently execute the command - { - if (debug) - { - if (len > 500) - { - // XXX FIXME XXX can we limit the maximum output width for a - // string? The setprecision() io manipulator doesn't do it. - // In the meantime, a hack ... - char t = context[400]; context[400] = '\0'; - STATUS("evaluating (" << len << ") " - << context << std::endl - << "..." << std::endl - << context+len-100); - context[400] = t; - } - else - { - STATUS("evaluating (" << len << ") " << context); - } - } - - if (debug) tic(); -#if 1 - error_state = 0; - int parse_status = 0; - eval_string(context, true, parse_status, 0); - if (parse_status != 0 || error_state) - eval_string("senderror(lasterr);", true, parse_status, 0); -#elif 0 - octave_value_list evalargs; - evalargs(1) = "senderror(lasterr);"; - evalargs(0) = context; - octave_value_list fret = feval("eval",evalargs,0); -#else - evalargs(0) = octave_value(0.); -#endif - STATUS("done command"); - } - STATUS("free evalargs"); - break; - - case 'c': // execute the command and capture stdin/stdout - STATUS("capture command not yet implemented"); - break; - - default: - STATUS("ignoring command " << command); - break; - } - - if (context != def_context) delete[] context; - STATUS("done " << command); - if (!ok) break; - if (debug) tic(); - } -} - - -int channel = -1; - -DEFUN_DLD(senderror,args,,"\ -Send the given error message across the socket. The error context\n\ -is taken to be the last command received from the socket.") -{ - std::string str; - const int nargin = args.length(); - if (nargin != 1) str="senderror not called with error"; - else str = args(0).string_value(); - - // provide a context for the error (but not too much!) - str += "when evaluating:\n"; - if (strlen(context) > 100) - { - char t=context[100]; - context[100] = '\0'; - str+=context; - context[100]=t; - } - else - str += context; - - STATUS("error is " << str); - channel_error(channel,str.c_str()); - return octave_value_list(); -} - -DEFUN_DLD(send,args,,"\ -send(str)\n\ - Send a command on the current connection\n\ -send(name,value)\n\ - Send a binary value with the given name on the current connection\n\ -") -{ - bool ok; - uint32_t t; - octave_value_list ret; - int nargin = args.length(); - if (nargin < 1 || nargin > 2) - { - print_usage (); - return ret; - } - - if (channel < 0) { - error("Not presently listening on a port"); - return ret; - } - - std::string cmd(args(0).string_value()); - if (error_state) return ret; - - // XXX FIXME XXX perhaps process the panalopy of types? - if (nargin > 1) { - - octave_value def = args(1); - if (args(1).is_string()) { - // Grab the string value from args(1). - // Can't use args(1).string_value() because that trims trailing \0 - charMatrix m(args(1).char_matrix_value()); - std::string s(m.row_as_string(0,false,true)); - STATUS("sending string(" << cmd.c_str() << " len " << s.length() << ")"); - ok = writes(channel,"!!!s",4); // string message - t = htonl(8 + cmd.length() + s.length()); - if (ok) ok = writes(channel,&t,4); // length of message - t = htonl(s.length()); - if (ok) ok = writes(channel, &t, 4); // string length - t = htonl(cmd.length()); - if (ok) ok = writes(channel, &t, 4); // name length - if (cmd.length() && ok) - ok = writes(channel, cmd.c_str(), cmd.length()); // name - if (s.length() && ok) - ok = writes(channel, s.c_str(), s.length()); // string - } else if (args(1).is_real_type()) { - Matrix m(args(1).matrix_value()); - STATUS("sending matrix(" << cmd.c_str() << " " - << m.rows() << "x" << m.columns() << ")"); - - // write the matrix transfer header - ok = writes(channel,"!!!m",4); // matrix message - t = htonl(12 + cmd.length() + sizeof(double)*m.rows()*m.columns()); - if (ok) ok = writes(channel,&t,4); // length of message - t = htonl(m.rows()); - if (ok) ok = writes(channel,&t,4); // rows - t = htonl(m.columns()); - if (ok) ok = writes(channel,&t,4); // columns - t = htonl(cmd.length()); - if (ok) ok = writes(channel, &t, 4); // name length - if (ok) ok = writes(channel, cmd.c_str(), cmd.length()); // name - - // write the matrix contents - const double *v = m.data(); // data - if (m.rows()*m.columns() && ok) - ok = writes(channel,v,sizeof(double)*m.rows()*m.columns()); - } else { - ok = false; - error("send expected name and matrix or string value"); - } - if (!ok) error("send could not write to channel"); - } else { - STATUS("sending command(" << cmd.length() << ") " << cmd.c_str()); - // STATUS("start writing at "<<toc()<<"us"); - ok = writes(channel, "!!!x", 4); - t = htonl(cmd.length()); writes(channel, &t, 4); - if (ok) ok = writes(channel, cmd.c_str(), cmd.length()); - if (!ok) error("send could not write to channel"); - // STATUS("stop writing at "<<toc()<<"us"); - } - - return ret; -} - -extern "C" int listencanfork(void); -extern "C" int StringCaseMatch(const char* s, const char* p, int nocase); - -bool ishostglob(const std::string& s) -{ - for (unsigned int i=0; i < s.length(); i++) { - if (! ( isdigit(s[i]) || s[i]=='*' || s[i]=='-' - || s[i]=='.' || s[i]=='[' || s[i]==']')) return false; - } - return true; -} - -bool anyhostglob(const string_vector& hostlist, const char* host) -{ - for (int j=0; j < hostlist.length(); j++) { - if (StringCaseMatch(host, hostlist[j].c_str(), 0)) return true; - } - return false; -} - -// Known bug: functions which pass or return structures use a -// different ABI for gcc and native compilers on some architectures. -// Whether this is a bug depends on the structure length. SGI's 64-bit -// architecture makes this a problem for inet_ntoa. -#if defined(__GNUC__) && defined(_sgi) -#define BROKEN_INET_NTOA -#endif - -#ifdef BROKEN_INET_NTOA - -/************************************************* -* Replacement for broken inet_ntoa() * -*************************************************/ - - -/* On IRIX systems, gcc uses a different structure passing convention to the -native libraries. This causes inet_ntoa() to always yield 0.0.0.0 or -255.255.255.255. To get round this, we provide a private version of the -function here. It is used only if USE_INET_NTOA_FIX is set, which should -happen -only when gcc is in use on an IRIX system. Code send to me by J.T. Breitner, -with these comments: - - - code by Stuart Levy - as seen in comp.sys.sgi.admin - - -Arguments: sa an in_addr structure -Returns: pointer to static text string -*/ - - -char * -inet_ntoa(struct in_addr sa) -{ -static char addr[20]; -sprintf(addr, "%d.%d.%d.%d", - (US &sa.s_addr)[0], - (US &sa.s_addr)[1], - (US &sa.s_addr)[2], - (US &sa.s_addr)[3]); - return addr; -} - -#endif /* BROKEN_INET_NTOA */ - - -void _autoload(const char name[]) -{ - octave_value_list evalargs, fret; - evalargs(0) = "server"; - fret = feval("which",evalargs,1); - evalargs(0) = name; - evalargs(1) = fret(0); - fret = feval("autoload",evalargs,0); -} - -DEFUN_DLD(server,args,,"\ -server(port,host,host,...)\n\ - Listen for connections on the given port. Normally only accepts\n\ - connections from localhost (127.0.0.1), but you can specify any\n\ - dot-separated host name globs. E.g., '128.2.20.*' or '128.2.2[012].*'\n\ - Use '?' for '[0123456789]'. Use '*.*.*.*' for any host.\n\ -server(...,'debug'|'nodebug')\n\ - If debug, echo all commands sent across the connection. If nodebug,\n\ - detach the process and don't echo anything. You will need to use\n\ - kill directly to end the process. Nodebug is the default.\n\ -server(...,'fork'|'nofork')\n\ - If fork, start new server for each connection. If nofork, only allow\n\ - one connection at a time. Fork is the default (depending on system).\n\ -server(...,'loopback')\n\ - Use loopback address 127.0.0.1 rather than 0.0.0.0.\n\ -") -{ - bool canfork = CAN_FORK; - - _autoload("send"); - _autoload("senderror"); - octave_value_list ret; - int nargin = args.length(); - if (nargin < 1) - { - print_usage (); - return ret; - } - int port = args(0).int_value(); - if (error_state) return ret; - - // Winsock requires initialization - if (!init_sockets()) - { - socket_error("init"); - return ret; - } - - - debug = false; - uint32_t inaddr = INADDR_ANY; - - string_vector hostlist; - hostlist.append(std::string("127.0.0.1")); - for (int k = 1; k < nargin; k++) { - std::string lastarg(args(k).string_value()); - if (error_state) return ret; - lowercase(lastarg); - if (lastarg == "debug") { - debug = true; - } else if (lastarg == "nodebug") { - debug = false; - } else if (lastarg == "fork") { - canfork = true; - } else if (lastarg == "nofork") { - canfork = false; - } else if (lastarg == "loopback") { - inaddr = INADDR_LOOPBACK; - } else if (ishostglob(lastarg)) { - hostlist.append(lastarg); - } else { - print_usage (); - } - } - - int sockfd; // listen on sockfd, new connection channel - struct sockaddr_in my_addr; // my address information - struct sockaddr_in their_addr; // connector's address information - socklen_t sin_size; - int yes=1; - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd == -1) { - socket_error("socket"); - return ret; - } - - if (setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,(const char *)(&yes),sizeof(yes)) == -1) { - socket_error("setsockopt"); - return ret; - } - - my_addr.sin_family = AF_INET; // host byte order - my_addr.sin_port = htons(port); // short, network byte order - my_addr.sin_addr.s_addr = htonl(inaddr); // automatically fill with my IP - memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct - - if (bind(sockfd, (struct sock... [truncated message content] |
From: <car...@us...> - 2012-03-24 19:34:58
|
Revision: 10041 http://octave.svn.sourceforge.net/octave/?rev=10041&view=rev Author: carandraug Date: 2012-03-24 19:34:52 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous: update DESCRIPTION file Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/DESCRIPTION Modified: trunk/octave-forge/main/miscellaneous/DESCRIPTION =================================================================== --- trunk/octave-forge/main/miscellaneous/DESCRIPTION 2012-03-24 19:32:45 UTC (rev 10040) +++ trunk/octave-forge/main/miscellaneous/DESCRIPTION 2012-03-24 19:34:52 UTC (rev 10041) @@ -1,14 +1,14 @@ Name: Miscellaneous Version: 1.0.11 Date: 2011-12-11 -Author: Various Authors -Maintainer: The Octave Community +Author: various authors +Maintainer: Octave-Forge community <oct...@li...> Title: Miscellaneous functions Description: Miscellaneous tools that don't fit somewhere else. Categories: Miscellaneous -Depends: octave (>= 3.2.4) +Depends: octave (>= 3.6.0) Autoload: no SystemRequirements: units -BuildRequires: termcap-devel -License: GPL version 3 or later +BuildRequires: termcap-devel [Debian] libncurses5-dev +License: GPLv3+ Url: http://octave.sf.net This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 19:32:52
|
Revision: 10040 http://octave.svn.sourceforge.net/octave/?rev=10040&view=rev Author: carandraug Date: 2012-03-24 19:32:45 +0000 (Sat, 24 Mar 2012) Log Message: ----------- miscellaneous: update NEWS file Modified Paths: -------------- trunk/octave-forge/main/miscellaneous/NEWS Modified: trunk/octave-forge/main/miscellaneous/NEWS =================================================================== --- trunk/octave-forge/main/miscellaneous/NEWS 2012-03-24 18:58:52 UTC (rev 10039) +++ trunk/octave-forge/main/miscellaneous/NEWS 2012-03-24 19:32:45 UTC (rev 10040) @@ -38,3 +38,9 @@ ** Package is no longer automatically loaded. ** improvements to help text. + + ** The function `csv2latex' has been made silent and had bugs fixed. + + ** The function `publish' had bugs fixed. + + ** The function `match' can now accept cell arrays as input. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2012-03-24 18:58:59
|
Revision: 10039 http://octave.svn.sourceforge.net/octave/?rev=10039&view=rev Author: thomas-weber Date: 2012-03-24 18:58:52 +0000 (Sat, 24 Mar 2012) Log Message: ----------- Replace deprecated function calls Modified Paths: -------------- trunk/octave-forge/main/econometrics/inst/gmm_example.m trunk/octave-forge/main/econometrics/inst/gmm_results.m Modified: trunk/octave-forge/main/econometrics/inst/gmm_example.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_example.m 2012-03-24 18:38:45 UTC (rev 10038) +++ trunk/octave-forge/main/econometrics/inst/gmm_example.m 2012-03-24 18:58:52 UTC (rev 10039) @@ -25,7 +25,7 @@ w = [x, rand(n,1)]; theta_true = ones(k,1); lambda = exp(x*theta_true); -y = poisson_rnd(lambda); +y = poissrnd(lambda); [xs, scalecoef] = scale_data(x); # The arguments for gmm_estimate Modified: trunk/octave-forge/main/econometrics/inst/gmm_results.m =================================================================== --- trunk/octave-forge/main/econometrics/inst/gmm_results.m 2012-03-24 18:38:45 UTC (rev 10038) +++ trunk/octave-forge/main/econometrics/inst/gmm_results.m 2012-03-24 18:58:52 UTC (rev 10039) @@ -88,7 +88,7 @@ df = n - k; if df > 0 clabels = char("Value","df","p-value"); - a = [n*obj_value, df, 1 - chisquare_cdf(n*obj_value, df)]; + a = [n*obj_value, df, 1 - chi2cdf(n*obj_value, df)]; printf("\n"); prettyprint(a, junk, clabels); else @@ -96,7 +96,7 @@ end; # results for parameters - a =[theta, se, theta./se, 2 - 2*normal_cdf(abs(theta ./ se))]; + a =[theta, se, theta./se, 2 - 2*normcdf(abs(theta ./ se))]; clabels = char("estimate", "st. err", "t-stat", "p-value"); printf("\n"); prettyprint(a, names, clabels); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2012-03-24 18:38:51
|
Revision: 10038 http://octave.svn.sourceforge.net/octave/?rev=10038&view=rev Author: thomas-weber Date: 2012-03-24 18:38:45 +0000 (Sat, 24 Mar 2012) Log Message: ----------- Update fnder to cope with changed return values of mkpp Patch courtesy of Rafael Laboissiere, http://lists.alioth.debian.org/pipermail/pkg-octave-devel/2012-March/008537.html Modified Paths: -------------- trunk/octave-forge/main/splines/inst/fnder.m Modified: trunk/octave-forge/main/splines/inst/fnder.m =================================================================== --- trunk/octave-forge/main/splines/inst/fnder.m 2012-03-24 16:35:11 UTC (rev 10037) +++ trunk/octave-forge/main/splines/inst/fnder.m 2012-03-24 18:38:45 UTC (rev 10038) @@ -31,19 +31,16 @@ if (nargin < 2) o = 1; endif - - P = pp.P; + + [X, P, N, K, D] = unmkpp (pp); c = columns (P); r = rows (P); for i = 1:o #pp.P = polyder (pp.P); matrix capable polyder is needed. P = P(:, 1:c - 1) .* kron ((c - 1):- 1:1, ones (r,1)); - c = columns (P); endfor - dpp = pp; - dpp.P = P; - dpp.k = c; + dpp = mkpp (X, P); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:35:17
|
Revision: 10037 http://octave.svn.sourceforge.net/octave/?rev=10037&view=rev Author: slackydeb Date: 2012-03-24 16:35:11 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: move xtests to demo_ga Modified Paths: -------------- trunk/octave-forge/main/ga/devel/demo_ga.m trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/devel/demo_ga.m =================================================================== --- trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:34:53 UTC (rev 10036) +++ trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:35:11 UTC (rev 10037) @@ -65,3 +65,73 @@ ## This code shows a more complex objective function # TODO: convert to demo # %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); + + +## TODO: these should probably become tests (test, not xtest) using a deterministic sequence of random number +## +## simple optimization result checks. Failures here could happen because +## of non-determinism in the result but if one of these tests always +## fails for you, plese consider dropping an email to the octave-forge +## mailing list <oct...@li...>. +# %!function f = ff (min) +# %! f = @(x) sum ((x(:, 1:(columns (min))) - repmat (min, +# %! rows (x), 1)) .** 2, 2); +# %!function [C, Ceq] = nonlcon (x) +# %! C = []; +# %! Ceq = []; +# %!function r = rand_porcelain (interval_min, interval_max, nvars) +# %! assert (interval_min < interval_max); +# %! r = interval_min + ((interval_max - interval_min) * rand (1, nvars)); +# %!function t = tol (nvars) +# %! t = repelems (0.15, [1; nvars]); +# %!xtest +# %! nvars = 1; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! minimum = zeros (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 1; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! minimum = ones (1, nvars); +# %! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +# %!xtest +# %! nvars = 1; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); +# %!xtest +# %! nvars = 2; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); +# %!xtest +# %! nvars = 3; +# %! interval_min = -10; +# %! interval_max = 10; +# %! minimum = - rand_porcelain (interval_min, interval_max, nvars); +# %! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +# %! "CrossoverFraction", 0.2); +# %! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +# %! assert (x, minimum, 4 .* tol (nvars)); Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:53 UTC (rev 10036) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:35:11 UTC (rev 10037) @@ -370,71 +370,3 @@ %! bad_options = gaoptimset ("UseParallel", "garbage", %! "Vectorized", "garbage"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); - - -## simple optimization result checks. Failures here could happen because -## of non-determinism in the result but if one of these tests always -## fails for you, plese consider dropping an email to the octave-forge -## mailing list <oct...@li...>. -%!function f = ff (min) -%! f = @(x) sum ((x(:, 1:(columns (min))) - repmat (min, -%! rows (x), 1)) .** 2, 2); -%!function [C, Ceq] = nonlcon (x) -%! C = []; -%! Ceq = []; -%!function r = rand_porcelain (interval_min, interval_max, nvars) -%! assert (interval_min < interval_max); -%! r = interval_min + ((interval_max - interval_min) * rand (1, nvars)); -%!function t = tol (nvars) -%! t = repelems (0.15, [1; nvars]); -%!xtest -%! nvars = 1; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 2; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 3; -%! minimum = zeros (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 1; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 2; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 3; -%! minimum = ones (1, nvars); -%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); -%!xtest -%! nvars = 1; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); -%!xtest -%! nvars = 2; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); -%!xtest -%! nvars = 3; -%! interval_min = -10; -%! interval_max = 10; -%! minimum = - rand_porcelain (interval_min, interval_max, nvars); -%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], -%! "CrossoverFraction", 0.2); -%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); -%! assert (x, minimum, 4 .* tol (nvars)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:34:59
|
Revision: 10036 http://octave.svn.sourceforge.net/octave/?rev=10036&view=rev Author: slackydeb Date: 2012-03-24 16:34:53 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: test optimization result Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:40 UTC (rev 10035) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:53 UTC (rev 10036) @@ -372,14 +372,69 @@ %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); -# TODO: structure/add tests below - -%!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); - - -# TODO: convert to simple xtests -## nvars == 1 and min == zeros (1, nvars) - -%!test assert (ga (@(x) x ** 2, 1), 0, 1e-3); - -%!test assert (ga (@(x) (x ** 2) - (cos (2 * pi * x)) + 1, 1), 0, 1e-3); +## simple optimization result checks. Failures here could happen because +## of non-determinism in the result but if one of these tests always +## fails for you, plese consider dropping an email to the octave-forge +## mailing list <oct...@li...>. +%!function f = ff (min) +%! f = @(x) sum ((x(:, 1:(columns (min))) - repmat (min, +%! rows (x), 1)) .** 2, 2); +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!function r = rand_porcelain (interval_min, interval_max, nvars) +%! assert (interval_min < interval_max); +%! r = interval_min + ((interval_max - interval_min) * rand (1, nvars)); +%!function t = tol (nvars) +%! t = repelems (0.15, [1; nvars]); +%!xtest +%! nvars = 1; +%! minimum = zeros (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 2; +%! minimum = zeros (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 3; +%! minimum = zeros (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 1; +%! minimum = ones (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 2; +%! minimum = ones (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 3; +%! minimum = ones (1, nvars); +%! assert (ga (ff (minimum), nvars), minimum, tol (nvars)); +%!xtest +%! nvars = 1; +%! interval_min = -10; +%! interval_max = 10; +%! minimum = - rand_porcelain (interval_min, interval_max, nvars); +%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +%! "CrossoverFraction", 0.2); +%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +%! assert (x, minimum, 4 .* tol (nvars)); +%!xtest +%! nvars = 2; +%! interval_min = -10; +%! interval_max = 10; +%! minimum = - rand_porcelain (interval_min, interval_max, nvars); +%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +%! "CrossoverFraction", 0.2); +%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +%! assert (x, minimum, 4 .* tol (nvars)); +%!xtest +%! nvars = 3; +%! interval_min = -10; +%! interval_max = 10; +%! minimum = - rand_porcelain (interval_min, interval_max, nvars); +%! options = gaoptimset ("PopInitRange", 2 .* [interval_min; interval_max], +%! "CrossoverFraction", 0.2); +%! x = ga (ff (minimum), nvars, [], [], [], [], [], [], @nonlcon, options); +%! assert (x, minimum, 4 .* tol (nvars)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:34:46
|
Revision: 10035 http://octave.svn.sourceforge.net/octave/?rev=10035&view=rev Author: slackydeb Date: 2012-03-24 16:34:40 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: move test function to demo Modified Paths: -------------- trunk/octave-forge/main/ga/devel/demo_ga.m Modified: trunk/octave-forge/main/ga/devel/demo_ga.m =================================================================== --- trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:34:23 UTC (rev 10034) +++ trunk/octave-forge/main/ga/devel/demo_ga.m 2012-03-24 16:34:40 UTC (rev 10035) @@ -60,3 +60,8 @@ ## The "UseParallel" option should speed up execution # TODO: write demo (after implementing # UseParallel) - low priority + + +## This code shows a more complex objective function + # TODO: convert to demo +# %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:34:29
|
Revision: 10034 http://octave.svn.sourceforge.net/octave/?rev=10034&view=rev Author: slackydeb Date: 2012-03-24 16:34:23 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: test error when function requires more nvars than specified Trivial error. Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:10 UTC (rev 10033) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:34:23 UTC (rev 10034) @@ -130,6 +130,9 @@ # TODO ## type of arguments +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); +%!error x = ga (ff (3), 2); # TODO # TODO: test that each field in the user-specified "problem" structure is checked This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:34:19
|
Revision: 10033 http://octave.svn.sourceforge.net/octave/?rev=10033&view=rev Author: slackydeb Date: 2012-03-24 16:34:10 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: fix failing unit test A non-vectorized objective function must not work when vectorization is required. Modified Paths: -------------- trunk/octave-forge/main/ga/inst/__ga_scores__.m Modified: trunk/octave-forge/main/ga/inst/__ga_scores__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:33:56 UTC (rev 10032) +++ trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:34:10 UTC (rev 10033) @@ -14,9 +14,10 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.6 +## Version: 5.7 function Scores = __ga_scores__ (problem, Population) + [nrP ncP] = size (Population); switch problem.options.Vectorized case "on" ## using vectorized evaluation switch problem.options.UseParallel @@ -27,13 +28,12 @@ otherwise warning ("'Vectorized' option is 'on': ignoring invalid 'UseParallel' option value (it should be 'always' or 'never')"); endswitch - Scores = problem.fitnessfcn (Population); + Scores = (problem.fitnessfcn (Population))(1:nrP, 1); case "off" ## not using vectorized evaluation switch problem.options.UseParallel case "always" ## using parallel evaluation error ("TODO: implement parallel evaluation of objective function"); case "never" ## using serial evaluation (i.e. loop) - [nrP ncP] = size (Population); tmp = zeros (nrP, 1); for index = 1:nrP tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:34:02
|
Revision: 10032 http://octave.svn.sourceforge.net/octave/?rev=10032&view=rev Author: slackydeb Date: 2012-03-24 16:33:56 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: test private functions with unit tests too Probably these (as the others) private functions should be converted to subfunctions. Thus in the future this commit will be "reverted" and these private (sub)functions will be tested in the file of the main function. Modified Paths: -------------- trunk/octave-forge/main/ga/inst/test_ga.m Modified: trunk/octave-forge/main/ga/inst/test_ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/test_ga.m 2012-03-24 16:33:44 UTC (rev 10031) +++ trunk/octave-forge/main/ga/inst/test_ga.m 2012-03-24 16:33:56 UTC (rev 10032) @@ -20,7 +20,7 @@ ## Author: Luca Favatella <sla...@gm...> ## Created: March 2012 -## Version: 0.2 +## Version: 0.3 ## Creation test gacreationuniform @@ -43,3 +43,7 @@ ## Genetic Algorithm test gaoptimset test ga + +## Private functions +test __ga_initial_population__ +test __ga_problem_update_state_at_each_generation__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:33:50
|
Revision: 10031 http://octave.svn.sourceforge.net/octave/?rev=10031&view=rev Author: slackydeb Date: 2012-03-24 16:33:44 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: add unit tests about vectorized evaluation of fitness function Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:31 UTC (rev 10030) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:44 UTC (rev 10031) @@ -294,6 +294,35 @@ %! "InitialScores", zeros (ip + 1, 1)); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +## error with vectorized evaluation of objective function. Vectorized +## objective functions are better because can be evaluated both as +## serial and vectorized. +%!shared nvars +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); +%!function f_not_vectorized = ff_not_vectorized (nvars) +%! f_not_vectorized = @(x) sum (x(1:nvars) .** 2); +%!test # A non-vectorized objective function works when no vectorization is required +%! f = ff_not_vectorized (nvars); +%! options = gaoptimset ("Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # A non-vectorized objective function does not work when vectorization is required +%! f = ff_not_vectorized (nvars); +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # A vectorized objective function works when no vectorization is required +%! f = ff (nvars); +%! options = gaoptimset ("Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!test # A vectorized objective function works when vectorization is required +%! f = ff (nvars); +%! options = gaoptimset ("Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); + ## error with conflicting optimization parameters: parallel and ## vectorized evaluation of objective function %!shared f, nvars This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:33:37
|
Revision: 10030 http://octave.svn.sourceforge.net/octave/?rev=10030&view=rev Author: slackydeb Date: 2012-03-24 16:33:31 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: fix bad examples of objective functions Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:14 UTC (rev 10029) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:31 UTC (rev 10030) @@ -159,15 +159,17 @@ %! x = ga (problem); ## flawless execution with any nvars +%!function f = ff (nvars) +%! f = @(x) sum (x(:, 1:nvars) .** 2, 2); %!test %! nvars = 1; -%! x = ga (@(x) x(1, 1) ** 2, nvars); +%! x = ga (ff (nvars), nvars); %!test %! nvars = 2; -%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2), nvars); +%! x = ga (ff (nvars), nvars); %!test %! nvars = 3; -%! x = ga (@(x) (x(:, 1) ** 2) + (x(:, 2) ** 2) + (x(:, 3) ** 2), nvars); +%! x = ga (ff (nvars), nvars); ## flawless execution with any supported optimization parameter ## different from the default value This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:33:20
|
Revision: 10029 http://octave.svn.sourceforge.net/octave/?rev=10029&view=rev Author: slackydeb Date: 2012-03-24 16:33:14 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: style fix Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:02 UTC (rev 10028) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:14 UTC (rev 10029) @@ -133,6 +133,7 @@ # TODO # TODO: test that each field in the user-specified "problem" structure is checked + ## flawless execution with right arguments %!shared f, nvars %! f = @rastriginsfcn; @@ -264,6 +265,7 @@ %! options = gaoptimset ("Vectorized", "on"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); + ## error with conflicting optimization parameters: population size et al. %!shared f, nvars %! f = @rastriginsfcn; @@ -335,6 +337,7 @@ %! "Vectorized", "garbage"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); + # TODO: structure/add tests below %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:33:08
|
Revision: 10028 http://octave.svn.sourceforge.net/octave/?rev=10028&view=rev Author: slackydeb Date: 2012-03-24 16:33:02 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: test parallel and vectorized evaluation of finessfcn Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:32:50 UTC (rev 10027) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:33:02 UTC (rev 10028) @@ -257,14 +257,14 @@ %!test # TODO: use non-default value %! options = gaoptimset ("TimeLimit", Inf); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -%!#xtest # TODO -%!# options = gaoptimset ("UseParallel", "always"); -%!# x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # TODO: this should become test +%! options = gaoptimset ("UseParallel", "always"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); %!test %! options = gaoptimset ("Vectorized", "on"); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); -## error with conflicting optimization parameters +## error with conflicting optimization parameters: population size et al. %!shared f, nvars %! f = @rastriginsfcn; %! nvars = 2; @@ -290,6 +290,51 @@ %! "InitialScores", zeros (ip + 1, 1)); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +## error with conflicting optimization parameters: parallel and +## vectorized evaluation of objective function +%!shared f, nvars +%! f = @rastriginsfcn; +%! nvars = 2; +%!function [C, Ceq] = nonlcon (x) +%! C = []; +%! Ceq = []; +%!test +%! options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error # TODO: this should become test +%! options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!error +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "off"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!test +%! options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, options); +%!warning +%! bad_options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!warning +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "on"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "never", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "always", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); +%!error +%! bad_options = gaoptimset ("UseParallel", "garbage", +%! "Vectorized", "garbage"); +%! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); + # TODO: structure/add tests below %!test x = ga (struct ("fitnessfcn", @(x) rastriginsfcn (x(1:2)) + ((x(3) ** 2) - (cos (2 * pi * x(3))) + 1) + (x(4) ** 2), "nvars", 4, "options", gaoptimset ())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:32:59
|
Revision: 10027 http://octave.svn.sourceforge.net/octave/?rev=10027&view=rev Author: slackydeb Date: 2012-03-24 16:32:50 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: restructure __ga_scores__ for better error handling Modified Paths: -------------- trunk/octave-forge/main/ga/inst/__ga_scores__.m Modified: trunk/octave-forge/main/ga/inst/__ga_scores__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:32:37 UTC (rev 10026) +++ trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:32:50 UTC (rev 10027) @@ -14,30 +14,35 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.5.2 +## Version: 5.6 function Scores = __ga_scores__ (problem, Population) - if (strcmp (problem.options.Vectorized, "on")) ## using vectorized evaluation - if (strcmp (problem.options.UseParallel, "always")) - warning ("'Vectorized' option is 'on': ignoring 'UseParallel' option, even if it is 'always'"); - endif - Scores = problem.fitnessfcn (Population); - else ## not using vectorized evaluation - if (! strcmp (problem.options.Vectorized, "off")) + switch problem.options.Vectorized + case "on" ## using vectorized evaluation + switch problem.options.UseParallel + case "always" + warning ("'Vectorized' option is 'on': ignoring 'UseParallel' option, even if it is 'always'"); + case "never" + ## Nothing. + otherwise + warning ("'Vectorized' option is 'on': ignoring invalid 'UseParallel' option value (it should be 'always' or 'never')"); + endswitch + Scores = problem.fitnessfcn (Population); + case "off" ## not using vectorized evaluation + switch problem.options.UseParallel + case "always" ## using parallel evaluation + error ("TODO: implement parallel evaluation of objective function"); + case "never" ## using serial evaluation (i.e. loop) + [nrP ncP] = size (Population); + tmp = zeros (nrP, 1); + for index = 1:nrP + tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); + endfor + Scores = tmp(1:nrP, 1); + otherwise + error ("'UseParallel' option must be 'always' or 'never'"); + endswitch + otherwise error ("'Vectorized' option must be 'on' or 'off'"); - endif - if (strcmp (problem.options.UseParallel, "always")) ## using parallel evaluation - error ("TODO: implement parallel evaluation of objective function"); - else ## using serial evaluation (i.e. loop) - if (! strcmp (problem.options.UseParallel, "never")) - error ("'UseParallel' option must be 'always' or 'never'"); - endif - [nrP ncP] = size (Population); - tmp = zeros (nrP, 1); - for index = 1:nrP - tmp(index, 1) = problem.fitnessfcn (Population(index, 1:ncP)); - endfor - Scores = tmp(1:nrP, 1); - endif - endif -endfunction \ No newline at end of file + endswitch +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:32:47
|
Revision: 10026 http://octave.svn.sourceforge.net/octave/?rev=10026&view=rev Author: slackydeb Date: 2012-03-24 16:32:37 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: improve error message Modified Paths: -------------- trunk/octave-forge/main/ga/inst/__ga_scores__.m Modified: trunk/octave-forge/main/ga/inst/__ga_scores__.m =================================================================== --- trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:32:25 UTC (rev 10025) +++ trunk/octave-forge/main/ga/inst/__ga_scores__.m 2012-03-24 16:32:37 UTC (rev 10026) @@ -14,13 +14,12 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## Author: Luca Favatella <sla...@gm...> -## Version: 5.5.1 +## Version: 5.5.2 function Scores = __ga_scores__ (problem, Population) if (strcmp (problem.options.Vectorized, "on")) ## using vectorized evaluation if (strcmp (problem.options.UseParallel, "always")) - warning ("'Vectorized' option is 'on': ignoring 'UseParallel' \ - option, even if it is 'always'"); + warning ("'Vectorized' option is 'on': ignoring 'UseParallel' option, even if it is 'always'"); endif Scores = problem.fitnessfcn (Population); else ## not using vectorized evaluation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sla...@us...> - 2012-03-24 16:32:31
|
Revision: 10025 http://octave.svn.sourceforge.net/octave/?rev=10025&view=rev Author: slackydeb Date: 2012-03-24 16:32:25 +0000 (Sat, 24 Mar 2012) Log Message: ----------- ga: remove TODO comment in ga It looks like there are no more conflicting optimization parameters to consider at the moment. Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga.m Modified: trunk/octave-forge/main/ga/inst/ga.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:31:18 UTC (rev 10024) +++ trunk/octave-forge/main/ga/inst/ga.m 2012-03-24 16:32:25 UTC (rev 10025) @@ -289,7 +289,6 @@ %! bad_options = gaoptimset ("InitialPopulation", zeros (ip, nvars), %! "InitialScores", zeros (ip + 1, 1)); %! x = ga (f, nvars, [], [], [], [], [], [], @nonlcon, bad_options); -# TODO # TODO: structure/add tests below This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-24 16:31:28
|
Revision: 10024 http://octave.svn.sourceforge.net/octave/?rev=10024&view=rev Author: carandraug Date: 2012-03-24 16:31:18 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: make DESCRIPTION easier to parse automatically for upstream Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 15:54:32 UTC (rev 10023) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 16:31:18 UTC (rev 10024) @@ -7,5 +7,5 @@ Description: Library for geometric computing extending MatGeom functions. Useful to create, transform, manipulate and display geometric primitives. Depends: octave (>= 3.4.0) Autoload: yes -License: GPL version 3 and BSD (see files) +License: GPLv3+, FreeBSD Url: http://octave.sf.net, http://matgeom.sf.net, http://davis.wpi.edu/~matt/courses/clipping/, https://bitbucket.org/jgpallero/octclip This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |