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: <prn...@us...> - 2012-09-07 14:14:25
|
Revision: 10973 http://octave.svn.sourceforge.net/octave/?rev=10973&view=rev Author: prnienhuis Date: 2012-09-07 14:14:16 +0000 (Fri, 07 Sep 2012) Log Message: ----------- CDLF to LF Modified Paths: -------------- trunk/octave-forge/main/io/src/cell2csv.cc trunk/octave-forge/main/io/src/csv2cell.cc trunk/octave-forge/main/io/src/csvconcat.cc trunk/octave-forge/main/io/src/csvexplode.cc trunk/octave-forge/main/io/src/xmlread.cc trunk/octave-forge/main/io/src/xmltree.c trunk/octave-forge/main/io/src/xmltree.h trunk/octave-forge/main/io/src/xmltree_read.c trunk/octave-forge/main/io/src/xmltree_read.h Modified: trunk/octave-forge/main/io/src/cell2csv.cc =================================================================== --- trunk/octave-forge/main/io/src/cell2csv.cc 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/cell2csv.cc 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,116 +1,117 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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 <fstream> - -#include <octave/oct.h> -#include <octave/Cell.h> - -DEFUN_DLD (cell2csv, args, nargout, - "-*- texinfo -*-\n" - "@deftypefn {Loadable Function} {} cell2csv (@var{file}, @var{c})\n" - "@deftypefnx {Loadable Function} {} cell2csv (@var{file}, @var{c}, @var{sep})\n" - "@deftypefnx {Loadable Function} {} cell2csv (@var{file}, @var{c}, @var{sep}, @var{prot})\n" - "\n" - "Create a CSV file from a cell array. " - "@var{sep} (character value) changes the character used to separate two fields. " - "The default value is a comma " - "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " - "Default value is a double quote (@code{\"}).\n" - "@end deftypefn") { - - /* Check argument */ - if ((args.length() < 2) || (args.length() > 4)) { - print_usage (); - return octave_value(); - } - - /* Get arguments */ - std::string file = args(0).string_value(); - - Cell c = args(1).cell_value(); - - std::string sep = (args.length() > 2) ? args(2).string_value() : ","; - if (sep.length() != 1) { - error("cell2csv: separator can only be one character\n"); - return octave_value(); - } - - std::string prot = (args.length() > 3) ? args(3).string_value() : "\""; - if (prot.length() != 1) { - error("cell2csv: protector can only be one character\n"); - return octave_value(); - } - - /* Open file */ - std::ofstream fd(file.c_str()); - if (!fd.is_open()) { - error("cell2csv: cannot open file %s for writing\n", file.c_str()); - return octave_value(); - } - - /* Concat a cell into a string */ - std::string word; - - /* For each element */ - for (int i=0, il=c.rows(); i<il; i++) { - - for (int j=0, jl=c.columns(); j<jl; j++) { - word = ""; - - /* Add separator */ - if (j != 0) - word += sep; - - if (c(i, j).is_real_scalar()) { - - /* Output real value */ - char tmp[20]; - sprintf(tmp, "%g", c(i, j).double_value()); - word += tmp; + // + // 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 <fstream> + + #include <octave/oct.h> + #include <octave/Cell.h> + + DEFUN_DLD (cell2csv, args, nargout, + "-*- texinfo -*-\n" + "@deftypefn {Loadable Function} {} cell2csv (@var{file}, @var{c})\n" + "@deftypefnx {Loadable Function} {} cell2csv (@var{file}, @var{c}, @var{sep})\n" + "@deftypefnx {Loadable Function} {} cell2csv (@var{file}, @var{c}, @var{sep}, @var{prot})\n" + "\n" + "Create a CSV file from a cell array. " + "@var{sep} (character value) changes the character used to separate two fields. " + "The default value is a comma " + "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " + "Default value is a double quote (@code{\"}).\n" + "@end deftypefn") { + + /* Check argument */ + if ((args.length() < 2) || (args.length() > 4)) { + print_usage (); + return octave_value(); } - - else if (c(i, j).is_string()) { - /* Output string value */ - std::string str = c(i, j).string_value(); - if (str.find(sep) != str.npos) { - size_t pos = 0; - while ((pos=str.find(prot, pos)) != str.npos) { - str.replace(pos, 1, prot+prot); - pos += 2; + + /* Get arguments */ + std::string file = args(0).string_value(); + + Cell c = args(1).cell_value(); + + std::string sep = (args.length() > 2) ? args(2).string_value() : ","; + if (sep.length() != 1) { + error("cell2csv: separator can only be one character\n"); + return octave_value(); + } + + std::string prot = (args.length() > 3) ? args(3).string_value() : "\""; + if (prot.length() != 1) { + error("cell2csv: protector can only be one character\n"); + return octave_value(); + } + + /* Open file */ + std::ofstream fd(file.c_str()); + if (!fd.is_open()) { + error("cell2csv: cannot open file %s for writing\n", file.c_str()); + return octave_value(); + } + + /* Concat a cell into a string */ + std::string word; + + /* For each element */ + for (int i=0, il=c.rows(); i<il; i++) { + + for (int j=0, jl=c.columns(); j<jl; j++) { + word = ""; + + /* Add separator */ + if (j != 0) + word += sep; + + if (c(i, j).is_real_scalar()) { + + /* Output real value */ + char tmp[20]; + sprintf(tmp, "%g", c(i, j).double_value()); + word += tmp; } - str = prot + str + prot; + + else if (c(i, j).is_string()) { + /* Output string value */ + std::string str = c(i, j).string_value(); + if (str.find(sep) != str.npos) { + size_t pos = 0; + while ((pos=str.find(prot, pos)) != str.npos) { + str.replace(pos, 1, prot+prot); + pos += 2; + } + str = prot + str + prot; + } + word += str; + } + + else if (!c(i, j).is_empty()) { + /* Output NaN value */ + warning ("cell2csv: empty cell or not a real or a string value - converted to 'NaN'\n"); + word += "NaN"; + } + + fd << word; } - word += str; + + /* Add end of line */ + fd << std::endl; } - - else if (!c(i, j).is_empty()) { - /* Output NaN value */ - warning ("cell2csv: empty cell or not a real or a string value - converted to 'NaN'\n"); - word += "NaN"; - } - - fd << word; + + /* Close file */ + fd.close(); + + return octave_value(); } - - /* Add end of line */ - fd << std::endl; - } - - /* Close file */ - fd.close(); - - return octave_value(); -} + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/csv2cell.cc =================================================================== --- trunk/octave-forge/main/io/src/csv2cell.cc 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/csv2cell.cc 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,131 +1,85 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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 <fstream> - -#include <octave/oct.h> -#include <octave/Cell.h> - -#define MAXSTRINGLENGTH 4096 - -DEFUN_DLD (csv2cell, args, nargout, - "-*- texinfo -*-\n" - "@deftypefn {Loadable Function} {@var{c} = } csv2cell (@var{file})\n" - "@deftypefnx {Loadable Function} {@var{c} = } csv2cell (@var{file}, @var{sep})\n" - "@deftypefnx {Loadable Function} {@var{c} = } csv2cell (@var{file}, @var{sep}, @var{prot})\n" - "\n" - "Read a CSV (Comma Separated Values) file and convert it into a cell array. " - "@var{sep} (a character value) changes the character used to separate two fields. " - "The default value is a comma " - "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " - "The default is a double quote (@code{\"}).\n" - "The maximum line width of the csv file is 4092 characters.\n" - "@end deftypefn") { - - /* Get arguments */ - const int nargin = args.length (); - octave_value_list retval; - if (nargin == 0) - { - error ("csv2cell: not enough input arguments"); - return retval; - } + // + // 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/>. - const std::string file = args (0).string_value (); - - const std::string _sep = (nargin > 1) ? args (1).string_value () : ","; - if (_sep.length() != 1) - { - error ("csv2cell: separator value can only be one character\n"); - return retval; - } - char sep = _sep[0]; - - const std::string _prot = (nargin > 2) ? args (2).string_value () : "\""; - if (_prot.length() != 1) - { - error ("csv2cell: protector value can be only one character\n"); - return retval; - } - char prot = _prot[0]; - - /* Open file */ - std::ifstream fd (file.c_str ()); - if (!fd.is_open ()) - { - error ("csv2cell: cannot open file %s for reading\n", file.c_str()); - return retval; - } - fd.seekg (0, std::ios::end); - long fdend = fd.tellg (); - fd.seekg (0, std::ios::beg); - - if (fd.tellg () >= fdend) - return octave_value (Cell (0, 0)); - - /* Buffers */ - char line [MAXSTRINGLENGTH]; - std::string str, word; - bool inside = false; - - /* Read a line */ - str = ""; - fd.getline (line, MAXSTRINGLENGTH); - while (fd.fail ()) - { - fd.clear (); - str += line; - fd.getline (line, MAXSTRINGLENGTH); - } - str += line; - - /* Parse first to get number of columns */ - int nbcolumns = 0; - for (int i = 0, len = str.length (); i <= len; i++) - if (((i==len) || (str [i] == sep)) && (!inside)) - nbcolumns++; - else if ((inside) && (str [i] == prot) && ((i < len) && (str [i+1] == prot))) - ++i; - else if (str [i] == prot) - inside = !inside; - - /* Read all the file to get number of rows */ - int nbrows = 1; - while (fd.tellg () < fdend) - { - fd.getline (line, MAXSTRINGLENGTH); - while (fd.fail ()) + #include <fstream> + + #include <octave/oct.h> + #include <octave/Cell.h> + + #define MAXSTRINGLENGTH 4096 + + DEFUN_DLD (csv2cell, args, nargout, + "-*- texinfo -*-\n" + "@deftypefn {Loadable Function} {@var{c} = } csv2cell (@var{file})\n" + "@deftypefnx {Loadable Function} {@var{c} = } csv2cell (@var{file}, @var{sep})\n" + "@deftypefnx {Loadable Function} {@var{c} = } csv2cell (@var{file}, @var{sep}, @var{prot})\n" + "\n" + "Read a CSV (Comma Separated Values) file and convert it into a cell array. " + "@var{sep} (a character value) changes the character used to separate two fields. " + "The default value is a comma " + "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " + "The default is a double quote (@code{\"}).\n" + "The maximum line width of the csv file is 4092 characters.\n" + "@end deftypefn") { + + /* Get arguments */ + const int nargin = args.length (); + octave_value_list retval; + if (nargin == 0) { - fd.clear (); - fd.getline (line, MAXSTRINGLENGTH); + error ("csv2cell: not enough input arguments"); + return retval; } - nbrows++; - } - - /* Rewind */ - fd.seekg (0, std::ios::beg); - if (!fd.good ()) - { - error ("csv2cell: cannot reread %s\n", file.c_str ()); - return retval; - } - - /* Read all the file until the end */ - Cell c (nbrows, nbcolumns); - for (int i = 0; i < nbrows; i++) - { + + const std::string file = args (0).string_value (); + + const std::string _sep = (nargin > 1) ? args (1).string_value () : ","; + if (_sep.length() != 1) + { + error ("csv2cell: separator value can only be one character\n"); + return retval; + } + char sep = _sep[0]; + + const std::string _prot = (nargin > 2) ? args (2).string_value () : "\""; + if (_prot.length() != 1) + { + error ("csv2cell: protector value can be only one character\n"); + return retval; + } + char prot = _prot[0]; + + /* Open file */ + std::ifstream fd (file.c_str ()); + if (!fd.is_open ()) + { + error ("csv2cell: cannot open file %s for reading\n", file.c_str()); + return retval; + } + fd.seekg (0, std::ios::end); + long fdend = fd.tellg (); + fd.seekg (0, std::ios::beg); + + if (fd.tellg () >= fdend) + return octave_value (Cell (0, 0)); + + /* Buffers */ + char line [MAXSTRINGLENGTH]; + std::string str, word; + bool inside = false; + /* Read a line */ str = ""; fd.getline (line, MAXSTRINGLENGTH); @@ -136,58 +90,105 @@ fd.getline (line, MAXSTRINGLENGTH); } str += line; - - /* Explode a line into a sub cell */ - word = ""; - inside = false; - int j = 0; - for (int k = 0, len = str.length (); k <= len; k++) + + /* Parse first to get number of columns */ + int nbcolumns = 0; + for (int i = 0, len = str.length (); i <= len; i++) + if (((i==len) || (str [i] == sep)) && (!inside)) + nbcolumns++; + else if ((inside) && (str [i] == prot) && ((i < len) && (str [i+1] == prot))) + ++i; + else if (str [i] == prot) + inside = !inside; + + /* Read all the file to get number of rows */ + int nbrows = 1; + while (fd.tellg () < fdend) { - if (((k == len) || (str [k] == sep)) && (!inside)) + fd.getline (line, MAXSTRINGLENGTH); + while (fd.fail ()) { - /* Check number of columns */ - if (j == nbcolumns) + fd.clear (); + fd.getline (line, MAXSTRINGLENGTH); + } + nbrows++; + } + + /* Rewind */ + fd.seekg (0, std::ios::beg); + if (!fd.good ()) + { + error ("csv2cell: cannot reread %s\n", file.c_str ()); + return retval; + } + + /* Read all the file until the end */ + Cell c (nbrows, nbcolumns); + for (int i = 0; i < nbrows; i++) + { + /* Read a line */ + str = ""; + fd.getline (line, MAXSTRINGLENGTH); + while (fd.fail ()) + { + fd.clear (); + str += line; + fd.getline (line, MAXSTRINGLENGTH); + } + str += line; + + /* Explode a line into a sub cell */ + word = ""; + inside = false; + int j = 0; + for (int k = 0, len = str.length (); k <= len; k++) + { + if (((k == len) || (str [k] == sep)) && (!inside)) { - fd.close (); - error ("csv2cell: incorrect CSV file, line %d too long\n", i+1); - return retval; + /* Check number of columns */ + if (j == nbcolumns) + { + fd.close (); + error ("csv2cell: incorrect CSV file, line %d too long\n", i+1); + return retval; + } + + /* Check if scalar */ + const char *word_str = word.c_str (); + char *err; + double val = strtod (word_str, &err); + + /* Store into the cell */ + c (i, j++) = ((word == "") || (err != word_str+word.length())) ? + octave_value (word) : octave_value (val); + word = ""; } - - /* Check if scalar */ - const char *word_str = word.c_str (); - char *err; - double val = strtod (word_str, &err); - - /* Store into the cell */ - c (i, j++) = ((word == "") || (err != word_str+word.length())) ? - octave_value (word) : octave_value (val); - word = ""; + else if ((inside) && (str[k]==prot) && ((k<len) && (str[k+1]==prot))) + { + /* Insisde a string */ + word += prot; + ++k; + } + else if (str[k] == prot) + /* Changing */ + inside = !inside; + else + word += str[k]; } - else if ((inside) && (str[k]==prot) && ((k<len) && (str[k+1]==prot))) + + /* Check number of columns */ + if (j != nbcolumns) { - /* Insisde a string */ - word += prot; - ++k; + fd.close (); + error ("csv2cell: incorrect CSV file, line %d too short\n", i+1); + return retval; } - else if (str[k] == prot) - /* Changing */ - inside = !inside; - else - word += str[k]; } - - /* Check number of columns */ - if (j != nbcolumns) - { - fd.close (); - error ("csv2cell: incorrect CSV file, line %d too short\n", i+1); - return retval; - } + + /* Close file */ + fd.close (); + + retval (0) = c; + return retval; } - - /* Close file */ - fd.close (); - - retval (0) = c; - return retval; -} + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/csvconcat.cc =================================================================== --- trunk/octave-forge/main/io/src/csvconcat.cc 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/csvconcat.cc 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,98 +1,99 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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/Cell.h> - -DEFUN_DLD (csvconcat, args, nargout, - "-*- texinfo -*-\n" - "@deftypefn {Loadable Function} {@var{str} = } csvconcat (@var{c})\n" - "@deftypefnx {Loadable Function} {@var{str} = } csvconcat (@var{c}, @var{sep})\n" - "@deftypefnx {Loadable Function} {@var{str} = } csvconcat (@var{c}, @var{sep}, @var{prot})\n" - "\n" - "Concatenate a cell into a CSV string or array of strings. " - "@var{sep} (character value) changes the character used to separate two fields. " - "The default value is a comma " - "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " - "The default is a double quote (@code{\"}).\n" - "@end deftypefn") { - - /* Check argument */ - if ((args.length() < 1) || (args.length() > 3)) { - print_usage (); - return octave_value(); - } - - /* Get arguments */ - Cell c = args(0).cell_value(); - - std::string sep = (args.length() > 1) ? args(1).string_value() : ","; - if (sep.length() != 1) { - error("csvconcat: separator can only be one character\n"); - return octave_value(); - } - - std::string prot = (args.length() > 2) ? args(2).string_value() : "\""; - if (prot.length() != 1) { - error("csvconcat: protector can only be one character\n"); - return octave_value(); - } - - /* Concat a cell into a string */ - string_vector vec(c.rows()); - std::string word; - - /* For each element */ - for (int i=0, il=c.rows(); i<il; i++) { - word = ""; - for (int j=0, jl=c.columns(); j<jl; j++) { - - /* Add separator */ - if (j != 0) - word += sep; - - if (c(i, j).is_real_scalar()) { - - /* Output real value */ - char tmp[20]; - sprintf(tmp, "%g", c(i, j).double_value()); - word += tmp; + // + // 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/Cell.h> + + DEFUN_DLD (csvconcat, args, nargout, + "-*- texinfo -*-\n" + "@deftypefn {Loadable Function} {@var{str} = } csvconcat (@var{c})\n" + "@deftypefnx {Loadable Function} {@var{str} = } csvconcat (@var{c}, @var{sep})\n" + "@deftypefnx {Loadable Function} {@var{str} = } csvconcat (@var{c}, @var{sep}, @var{prot})\n" + "\n" + "Concatenate a cell into a CSV string or array of strings. " + "@var{sep} (character value) changes the character used to separate two fields. " + "The default value is a comma " + "(@code{,}). @var{prot} (character value) changes the character used to protect a string. " + "The default is a double quote (@code{\"}).\n" + "@end deftypefn") { + + /* Check argument */ + if ((args.length() < 1) || (args.length() > 3)) { + print_usage (); + return octave_value(); } - - else if (c(i, j).is_string()) { - /* Output string value */ - std::string str = c(i, j).string_value(); - if (str.find(sep) != str.npos) { - unsigned int pos = 0; - while ((pos=str.find(prot, pos)) != str.npos) { - str.replace(pos, 1, prot+prot); - pos += 2; - } - str = prot + str + prot; - } - word += str; + + /* Get arguments */ + Cell c = args(0).cell_value(); + + std::string sep = (args.length() > 1) ? args(1).string_value() : ","; + if (sep.length() != 1) { + error("csvconcat: separator can only be one character\n"); + return octave_value(); } - - else { - /* Output NaN value */ - warning ("csvconcat: empty cell or not a real or string value - converted to 'NaN'\n"); - word += "NaN"; + + std::string prot = (args.length() > 2) ? args(2).string_value() : "\""; + if (prot.length() != 1) { + error("csvconcat: protector can only be one character\n"); + return octave_value(); } + + /* Concat a cell into a string */ + string_vector vec(c.rows()); + std::string word; + + /* For each element */ + for (int i=0, il=c.rows(); i<il; i++) { + word = ""; + for (int j=0, jl=c.columns(); j<jl; j++) { + + /* Add separator */ + if (j != 0) + word += sep; + + if (c(i, j).is_real_scalar()) { + + /* Output real value */ + char tmp[20]; + sprintf(tmp, "%g", c(i, j).double_value()); + word += tmp; + } + + else if (c(i, j).is_string()) { + /* Output string value */ + std::string str = c(i, j).string_value(); + if (str.find(sep) != str.npos) { + unsigned int pos = 0; + while ((pos=str.find(prot, pos)) != str.npos) { + str.replace(pos, 1, prot+prot); + pos += 2; + } + str = prot + str + prot; + } + word += str; + } + + else { + /* Output NaN value */ + warning ("csvconcat: empty cell or not a real or string value - converted to 'NaN'\n"); + word += "NaN"; + } + } + vec(i) = word; + } + + return octave_value(vec); } - vec(i) = word; - } - - return octave_value(vec); -} + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/csvexplode.cc =================================================================== --- trunk/octave-forge/main/io/src/csvexplode.cc 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/csvexplode.cc 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,96 +1,97 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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/Cell.h> - -DEFUN_DLD (csvexplode, args, nargout, - "-*- texinfo -*-\n" - "@deftypefn {Loadable Function} {@var{c} =} csvexplode (@var{str})\n" - "@deftypefnx {Loadable Function} {@var{c} =} csvexplode (@var{str}, @var{sep})\n" - "@deftypefnx {Loadable Function} {@var{c} =} csvexplode (@var{str}, @var{sep}, @var{prot})\n" - "\n" - "Explode a CSV string into a cell. " - "@var{sep} (character value) changes the character used to separate two fields. " - "The default value is a comma (@code{,}). @var{prot} (character value) changes " - "the character used to protect a string. The default is a double quote (@code{\"}).\n" - "@end deftypefn") { - - /* Check argument */ - if ((args.length() < 1) || (args.length() > 3)) { - print_usage (); - return octave_value(); - } - - /* Get arguments */ - if (!args(0).is_string()) { - if (args(0).is_cell()) - return octave_value(args(0)); - else - return octave_value(Cell(args(0))); - } - std::string str = args(0).string_value(); - - std::string _sep = (args.length() > 1) ? args(1).string_value() : ","; - if (_sep.length() != 1) { - error("csvexplode: separator can only be one character\n"); - return octave_value(); - } - char sep = _sep[0]; - - std::string _prot = (args.length() > 2) ? args(2).string_value() : "\""; - if (_prot.length() != 1) { - error("csvexplode: protector can only be one character\n"); - return octave_value(); - } - char prot = _prot[0]; - - /* Explode a line into a cell */ - Cell retval; - std::string word; - bool inside = false; - for (int i=0, len=str.length(); i<=len; i++) { - if (((i==len) || (str[i] == sep)) && (!inside)) { - - /* Extand cell */ - retval.resize(dim_vector(1, retval.columns()+1)); - - /* Check if scalar */ - const char *word_str=word.c_str(); - char *err; - double val = strtod (word_str, &err); - - /* Store into the cell */ - retval(0, retval.columns()-1) = - ((word == "") || (err != word_str+word.length())) ? - octave_value(word) : octave_value(val); - - word = ""; + // + // 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/Cell.h> + + DEFUN_DLD (csvexplode, args, nargout, + "-*- texinfo -*-\n" + "@deftypefn {Loadable Function} {@var{c} =} csvexplode (@var{str})\n" + "@deftypefnx {Loadable Function} {@var{c} =} csvexplode (@var{str}, @var{sep})\n" + "@deftypefnx {Loadable Function} {@var{c} =} csvexplode (@var{str}, @var{sep}, @var{prot})\n" + "\n" + "Explode a CSV string into a cell. " + "@var{sep} (character value) changes the character used to separate two fields. " + "The default value is a comma (@code{,}). @var{prot} (character value) changes " + "the character used to protect a string. The default is a double quote (@code{\"}).\n" + "@end deftypefn") { + + /* Check argument */ + if ((args.length() < 1) || (args.length() > 3)) { + print_usage (); + return octave_value(); + } + + /* Get arguments */ + if (!args(0).is_string()) { + if (args(0).is_cell()) + return octave_value(args(0)); + else + return octave_value(Cell(args(0))); + } + std::string str = args(0).string_value(); + + std::string _sep = (args.length() > 1) ? args(1).string_value() : ","; + if (_sep.length() != 1) { + error("csvexplode: separator can only be one character\n"); + return octave_value(); + } + char sep = _sep[0]; + + std::string _prot = (args.length() > 2) ? args(2).string_value() : "\""; + if (_prot.length() != 1) { + error("csvexplode: protector can only be one character\n"); + return octave_value(); + } + char prot = _prot[0]; + + /* Explode a line into a cell */ + Cell retval; + std::string word; + bool inside = false; + for (int i=0, len=str.length(); i<=len; i++) { + if (((i==len) || (str[i] == sep)) && (!inside)) { + + /* Extand cell */ + retval.resize(dim_vector(1, retval.columns()+1)); + + /* Check if scalar */ + const char *word_str=word.c_str(); + char *err; + double val = strtod (word_str, &err); + + /* Store into the cell */ + retval(0, retval.columns()-1) = + ((word == "") || (err != word_str+word.length())) ? + octave_value(word) : octave_value(val); + + word = ""; + } + else if ((inside) && (str[i]==prot) && ((i<len) && (str[i+1]==prot))) { + + /* Insisde a string */ + word += prot; + ++i; + } + else if (str[i] == prot) + /* Changing */ + inside = !inside; + else + word += str[i]; + } + + return octave_value(retval); } - else if ((inside) && (str[i]==prot) && ((i<len) && (str[i+1]==prot))) { - - /* Insisde a string */ - word += prot; - ++i; - } - else if (str[i] == prot) - /* Changing */ - inside = !inside; - else - word += str[i]; - } - - return octave_value(retval); -} + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/xmlread.cc =================================================================== --- trunk/octave-forge/main/io/src/xmlread.cc 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/xmlread.cc 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,151 +1,152 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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/lo-ieee.h> -#include <octave/oct-map.h> -#include <octave/Cell.h> - -extern "C" { -#include "xmltree.h" -#include "xmltree_read.h" -} - -octave_value get_element (element *root) { - int length, rows, columns; - - string_vector tmp_array; - ComplexMatrix tmp_matrix; - Octave_map tmp_structure; - Cell tmp_cell; - octave_value_list tmp_list; - - octave_value retval; - - if (!root) - return retval; - - switch (root->def_value) { - case value_scalar: - switch (root->const_value) { - case const_true: retval = octave_value(true); break; - case const_false: retval = octave_value(false); break; - case const_inf: retval = octave_value(octave_Inf); break; - case const_neginf: retval = octave_value(-octave_Inf); break; - case const_nan: retval = octave_value(octave_NaN); break; - case const_na: retval = octave_value(octave_NA); break; - case const_undef: retval = octave_value(root->scalar_value); break; + // + // 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/lo-ieee.h> + #include <octave/oct-map.h> + #include <octave/Cell.h> + + extern "C" { + #include "xmltree.h" + #include "xmltree_read.h" } - break; - - case value_complex: - retval = - octave_value(Complex(get_element(root->child).double_value(), - get_element(root->child->next).double_value())); - break; - - case value_string: - retval = octave_value(root->string_value); - break; - - case value_array: - rows = root->rows; - root = root->child; - tmp_array = string_vector(rows); - for (int k=0; (k<rows) && (root); k++, root = root->next) - tmp_array(k) = get_element(root).string_value(); - retval = octave_value(tmp_array); - break; - - case value_matrix: - rows = root->rows; - columns = root->columns; - root = root->child; - tmp_matrix = ComplexMatrix(rows, columns); - for (int k=0; (k<rows) && (root); k++) - for (int l=0; (l<columns) && (root); l++, root = root->next) - tmp_matrix(k, l) = get_element(root).complex_value(); - if (tmp_matrix.all_elements_are_real()) - retval = octave_value(real(tmp_matrix)); - else - retval = octave_value(tmp_matrix); - break; - - case value_structure: - root = root->child; - for (int k=0; root; root = root->next) - if (root->name) - tmp_structure.assign(root->name, get_element(root)); - else { - char *name = new char[7]; - sprintf (name, "__%04d", k++); - warning ("no field name in structure."); - tmp_structure.assign(name, get_element(root)); - delete[] name; + + octave_value get_element (element *root) { + int length, rows, columns; + + string_vector tmp_array; + ComplexMatrix tmp_matrix; + Octave_map tmp_structure; + Cell tmp_cell; + octave_value_list tmp_list; + + octave_value retval; + + if (!root) + return retval; + + switch (root->def_value) { + case value_scalar: + switch (root->const_value) { + case const_true: retval = octave_value(true); break; + case const_false: retval = octave_value(false); break; + case const_inf: retval = octave_value(octave_Inf); break; + case const_neginf: retval = octave_value(-octave_Inf); break; + case const_nan: retval = octave_value(octave_NaN); break; + case const_na: retval = octave_value(octave_NA); break; + case const_undef: retval = octave_value(root->scalar_value); break; + } + break; + + case value_complex: + retval = + octave_value(Complex(get_element(root->child).double_value(), + get_element(root->child->next).double_value())); + break; + + case value_string: + retval = octave_value(root->string_value); + break; + + case value_array: + rows = root->rows; + root = root->child; + tmp_array = string_vector(rows); + for (int k=0; (k<rows) && (root); k++, root = root->next) + tmp_array(k) = get_element(root).string_value(); + retval = octave_value(tmp_array); + break; + + case value_matrix: + rows = root->rows; + columns = root->columns; + root = root->child; + tmp_matrix = ComplexMatrix(rows, columns); + for (int k=0; (k<rows) && (root); k++) + for (int l=0; (l<columns) && (root); l++, root = root->next) + tmp_matrix(k, l) = get_element(root).complex_value(); + if (tmp_matrix.all_elements_are_real()) + retval = octave_value(real(tmp_matrix)); + else + retval = octave_value(tmp_matrix); + break; + + case value_structure: + root = root->child; + for (int k=0; root; root = root->next) + if (root->name) + tmp_structure.assign(root->name, get_element(root)); + else { + char *name = new char[7]; + sprintf (name, "__%04d", k++); + warning ("no field name in structure."); + tmp_structure.assign(name, get_element(root)); + delete[] name; + } + retval = octave_value(tmp_structure); + break; + + case value_list: + length = root->length; + root = root->child; + //tmp_list = octave_value_list(length); + for (int k=0; (k<length) && (root); k++, root = root->next) + tmp_list(k) = get_element(root); + retval = octave_value(tmp_list); + break; + + case value_cell: + rows = root->rows; + columns = root->columns; + root = root->child; + tmp_cell = Cell(rows, columns); + for (int k=0; (k<rows) && (root); k++) + for (int l=0; (l<columns) && (root); l++, root = root->next) + tmp_cell(k, l) = get_element(root); + retval = octave_value(tmp_cell); + break; + + default: + warning ("unknown type.\n"); } - retval = octave_value(tmp_structure); - break; - - case value_list: - length = root->length; - root = root->child; - //tmp_list = octave_value_list(length); - for (int k=0; (k<length) && (root); k++, root = root->next) - tmp_list(k) = get_element(root); - retval = octave_value(tmp_list); - break; - case value_cell: - rows = root->rows; - columns = root->columns; - root = root->child; - tmp_cell = Cell(rows, columns); - for (int k=0; (k<rows) && (root); k++) - for (int l=0; (l<columns) && (root); l++, root = root->next) - tmp_cell(k, l) = get_element(root); - retval = octave_value(tmp_cell); - break; - - default: - warning ("unknown type.\n"); - } - - return retval; -} - -DEFUN_DLD (xmlread, args, nargout, - "-*- texinfo -*-\n" - "@deftypefn {Loadable Function} {@var{value} =} xmlread(@var{filename})\n" - "Read a @var{value} from @var{filename} as an XML file\n" - "@end deftypefn") { - - /* Check argument */ - if (args.length() != 1) { - print_usage (); - return octave_value_list(); - } - - /* Read file */ - std::string filename = args(0).string_value(); - element *root = read_xmltree(filename.c_str()); - if (!root) - return octave_value_list(); - - /* step down into the element tree */ - octave_value retval = get_element (root->child); - free_element (root); - - return retval; -} + return retval; + } + + DEFUN_DLD (xmlread, args, nargout, + "-*- texinfo -*-\n" + "@deftypefn {Loadable Function} {@var{value} =} xmlread(@var{filename})\n" + "Read a @var{value} from @var{filename} as an XML file\n" + "@end deftypefn") { + + /* Check argument */ + if (args.length() != 1) { + print_usage (); + return octave_value_list(); + } + + /* Read file */ + std::string filename = args(0).string_value(); + element *root = read_xmltree(filename.c_str()); + if (!root) + return octave_value_list(); + + /* step down into the element tree */ + octave_value retval = get_element (root->child); + free_element (root); + + return retval; + } + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/xmltree.c =================================================================== --- trunk/octave-forge/main/io/src/xmltree.c 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/xmltree.c 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,171 +1,172 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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 <stdio.h> -#include <stdlib.h> - -#include "xmltree.h" - -element *new_element () { - - element *new; - new = (element *) malloc (sizeof(element)); - if (!new) - perror("xmltree: not enough memory for new_element()\n"); - - new->next = new->child = NULL; - - new->def_value = value_undef; - new->const_value = const_undef; - new->scalar_value = 0; - new->string_value = NULL; - - new->name = NULL; - new->length = new->rows = new->columns = new->nb_elements = 0; - - return new; -} - -element *new_next (element *pred) { - - element *new = new_element(); - - if (pred) - pred->next = new; - - return new; -} - -element *new_child (element *father) { - - element *new = new_element(); - - if (father) - father->child = new; - - return new; -} - -void free_element (element *root) { - - if (!root) - return; - - if (root->next) - free_element (root->next); - if (root->child) - free_element (root->child); - - if (root->string_value) - free (root->string_value); - if (root->name) - free (root->name); - - free (root); -} - -void print_level(int l) { - int i; - for (i=0; i<l; i++) - printf (" "); -} - -void print_element (element *root, int l) { - - if (!root) - return; - - if (root->name) { - print_level(l); - printf ("name: %s\n", root->name); - } - - print_level(l); - switch (root->def_value) { - case value_scalar: - printf ("scalar: "); - switch (root->const_value) { - case const_true: printf ("true\n"); break; - case const_false: printf ("false\n"); break; - case const_inf: printf ("inf\n"); break; - case const_neginf: printf ("neginf\n"); break; - case const_nan: printf ("nan\n"); break; - case const_na: printf ("na\n"); break; - case const_undef: printf ("%f\n", root->scalar_value); break; + // + // 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 <stdio.h> + #include <stdlib.h> + + #include "xmltree.h" + + element *new_element () { + + element *new; + new = (element *) malloc (sizeof(element)); + if (!new) + perror("xmltree: not enough memory for new_element()\n"); + + new->next = new->child = NULL; + + new->def_value = value_undef; + new->const_value = const_undef; + new->scalar_value = 0; + new->string_value = NULL; + + new->name = NULL; + new->length = new->rows = new->columns = new->nb_elements = 0; + + return new; } - break; - case value_data: - printf ("data:\n"); - break; - case value_complex: - printf ("complex:\n"); - break; - case value_string: - printf ("string (%d): %s\n", root->length, root->string_value); - break; - case value_array: - printf ("array (%d):\n", root->rows); - break; - case value_matrix: - printf ("matrix (%d, %d):\n", root->rows, root->columns); - break; - case value_structure: - printf ("structure:\n"); - break; - case value_list: - printf ("list (%d):\n", root->length); - break; - case value_cell: - printf ("cell (%d, %d):\n", root->rows, root->columns); - break; - default: - printf ("???:\n"); - } - - if (root->child) { - print_level(l); - printf ("child:\n"); - print_element (root->child, l+1); - } - - if (root->next) { - print_level(l); - printf ("next:\n"); - print_element (root->next, l); - } -} - -list *new_list(list *father) { - - list *new; - new = (list *) malloc (sizeof(list)); - if (!new) - perror("xmltree: not enough memory for new_list()\n"); - - new->prev = father; - - new->root = NULL; - - return new; -} - -list *pop_list(list *child) { - list *father; - - father = child->prev; - free (child); - - return father; -} + + element *new_next (element *pred) { + + element *new = new_element(); + + if (pred) + pred->next = new; + + return new; + } + + element *new_child (element *father) { + + element *new = new_element(); + + if (father) + father->child = new; + + return new; + } + + void free_element (element *root) { + + if (!root) + return; + + if (root->next) + free_element (root->next); + if (root->child) + free_element (root->child); + + if (root->string_value) + free (root->string_value); + if (root->name) + free (root->name); + + free (root); + } + + void print_level(int l) { + int i; + for (i=0; i<l; i++) + printf (" "); + } + + void print_element (element *root, int l) { + + if (!root) + return; + + if (root->name) { + print_level(l); + printf ("name: %s\n", root->name); + } + + print_level(l); + switch (root->def_value) { + case value_scalar: + printf ("scalar: "); + switch (root->const_value) { + case const_true: printf ("true\n"); break; + case const_false: printf ("false\n"); break; + case const_inf: printf ("inf\n"); break; + case const_neginf: printf ("neginf\n"); break; + case const_nan: printf ("nan\n"); break; + case const_na: printf ("na\n"); break; + case const_undef: printf ("%f\n", root->scalar_value); break; + } + break; + case value_data: + printf ("data:\n"); + break; + case value_complex: + printf ("complex:\n"); + break; + case value_string: + printf ("string (%d): %s\n", root->length, root->string_value); + break; + case value_array: + printf ("array (%d):\n", root->rows); + break; + case value_matrix: + printf ("matrix (%d, %d):\n", root->rows, root->columns); + break; + case value_structure: + printf ("structure:\n"); + break; + case value_list: + printf ("list (%d):\n", root->length); + break; + case value_cell: + printf ("cell (%d, %d):\n", root->rows, root->columns); + break; + default: + printf ("???:\n"); + } + + if (root->child) { + print_level(l); + printf ("child:\n"); + print_element (root->child, l+1); + } + + if (root->next) { + print_level(l); + printf ("next:\n"); + print_element (root->next, l); + } + } + + list *new_list(list *father) { + + list *new; + new = (list *) malloc (sizeof(list)); + if (!new) + perror("xmltree: not enough memory for new_list()\n"); + + new->prev = father; + + new->root = NULL; + + return new; + } + + list *pop_list(list *child) { + list *father; + + father = child->prev; + free (child); + + return father; + } + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/xmltree.h =================================================================== --- trunk/octave-forge/main/io/src/xmltree.h 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/xmltree.h 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,80 +1,81 @@ // Copyright (C) 2004 Laurent Mazet <ma...@cr...> -// -// 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/>. - -/* - xmltree structure - */ - -#if !defined(__XMLTREE_H__) -#define __XMLTREE_H__ - -typedef enum { - value_undef = 0, - value_scalar, - value_complex, - value_string, - value_array, - value_matrix, - value_structure, - value_list, - value_cell, - value_data } t_value; - -typedef enum { - const_undef = 0, - const_true, - const_false, - const_inf, - const_neginf, - const_na, - const_nan } t_const; - -typedef struct _element { - struct _element *next; - struct _element *child; - - /* values */ - t_value def_value; - t_const const_value; - double scalar_value; - char *string_value; - - /* parameters */ - char *name; - int length; - int rows; - int columns; - - /* check */ - int nb_elements; - -} element; - -typedef struct _list { - struct _list *prev; - - element **root; -} list; - -element *new_element (); -element *new_next (element *pred); -element *new_child (element *father); -void free_element (element *root); -void print_element (element *root, int l); - -list *new_list(list *father); -list *pop_list(list *child); - -#endif /* __XMLTREE_H__ */ + // + // 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/>. + + /* + xmltree structure + */ + + #if !defined(__XMLTREE_H__) + #define __XMLTREE_H__ + + typedef enum { + value_undef = 0, + value_scalar, + value_complex, + value_string, + value_array, + value_matrix, + value_structure, + value_list, + value_cell, + value_data } t_value; + + typedef enum { + const_undef = 0, + const_true, + const_false, + const_inf, + const_neginf, + const_na, + const_nan } t_const; + + typedef struct _element { + struct _element *next; + struct _element *child; + + /* values */ + t_value def_value; + t_const const_value; + double scalar_value; + char *string_value; + + /* parameters */ + char *name; + int length; + int rows; + int columns; + + /* check */ + int nb_elements; + + } element; + + typedef struct _list { + struct _list *prev; + + element **root; + } list; + + element *new_element (); + element *new_next (element *pred); + element *new_child (element *father); + void free_element (element *root); + void print_element (element *root, int l); + + list *new_list(list *father); + list *pop_list(list *child); + + #endif /* __XMLTREE_H__ */ + \ No newline at end of file Modified: trunk/octave-forge/main/io/src/xmltree_read.c =================================================================== --- trunk/octave-forge/main/io/src/xmltree_read.c 2012-09-07 14:13:02 UTC (rev 10972) +++ trunk/octave-forge/main/io/src/xmltree_read.c 2012-09-07 14:14:16 UTC (rev 10973) @@ -1,4438 +1,4439 @@ /* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header$ - */ - -#define FLEX_SCANNER -#define XML__FLEX_MAJOR_VERSION 2 -#define XML__FLEX_MINOR_VERSION 5 - -#include <stdio.h> -#include <errno.h> - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> -#ifndef _WIN32 -#include <unistd.h> -#endif - -/* Use prototypes in function declarations. */ -#define XML__USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define XML__USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define XML__USE_PROTOS -#define XML__USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define XML__USE_CONST -#define XML__USE_PROTOS -#endif - -#ifdef XML__USE_CONST -#define xml_const const -#else -#define xml_const -#endif - - -#ifdef XML__USE_PROTOS -#define XML__PROTO(proto) proto -#else -#define XML__PROTO(proto) () -#endif - - -/* Returned upon end-of-file. */ -#define XML__NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define XML__SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN xml__start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The XML_STATE alias is for lex - * compatibility. - */ -#define XML__START ((xml__start - 1) / 2) -#define XML_STATE XML__START - -/* Action number for EOF rule of a given start state. */ -#define XML__STATE_EOF(state) (XML__END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define XML__NEW_FILE xml_restart( xml_in ) - -#define XML__END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define XML__BUF_SIZE 16384 - -typedef struct xml__buffer_state *XML__BUFFER_STATE; - -extern int xml_leng; -extern FILE *xml_in, *xml_out; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * xml_less( 5 ); - * else ... [truncated message content] |
From: <prn...@us...> - 2012-09-07 14:13:14
|
Revision: 10972 http://octave.svn.sourceforge.net/octave/?rev=10972&view=rev Author: prnienhuis Date: 2012-09-07 14:13:02 +0000 (Fri, 07 Sep 2012) Log Message: ----------- CRLF to LF Modified Paths: -------------- trunk/octave-forge/main/io/inst/calccelladdress.m trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m trunk/octave-forge/main/io/inst/getusedrange.m trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m trunk/octave-forge/main/io/inst/object2json.m trunk/octave-forge/main/io/inst/oct2ods.m trunk/octave-forge/main/io/inst/oct2xls.m trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsclose.m trunk/octave-forge/main/io/inst/odsfinfo.m trunk/octave-forge/main/io/inst/odsopen.m trunk/octave-forge/main/io/inst/odsread.m trunk/octave-forge/main/io/inst/odswrite.m trunk/octave-forge/main/io/inst/parse_sp_range.m trunk/octave-forge/main/io/inst/parsecell.m trunk/octave-forge/main/io/inst/pch2mat.m trunk/octave-forge/main/io/inst/spsh_chkrange.m trunk/octave-forge/main/io/inst/spsh_prstype.m trunk/octave-forge/main/io/inst/xls2oct.m trunk/octave-forge/main/io/inst/xlsclose.m trunk/octave-forge/main/io/inst/xlsfinfo.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/calccelladdress.m =================================================================== --- trunk/octave-forge/main/io/inst/calccelladdress.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/calccelladdress.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,88 +1,89 @@ -## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr....@us...> -## -## 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/>. - -## calccelladdress (R, C) - compute spreadsheet style cell address from -## row & column index (both 1-based). -## -## Max column index currently set to 18278 (max ODS: 1024, OOXML: 16384). -## Row limits for ODF and OOXML are 65536 and 1048576, resp. - -## Author: Philip Nienhuis <prnienhuis at users.sf.net> -## Created: 2009-12-12 -## Updates: -## 2009-12-27 Fixed OOXML limits -## 2010-03-17 Simplified argument list, only row + column needed -## 2010-09-27 Made error message more comprehensible -## 2010-10-11 Added check for row range -## 2011-04-21 Added tests -## 2011-04-30 Simplified column name computation -## 2011-12-17 Bugfix for wrong column address if column equals multiple of 26 -## 2011-12-18 Added tests for multiple-of-26 cases - -function [ celladdress ] = calccelladdress (row, column) - - if (nargin < 2) error ("calccelladdress: Two arguments needed") endif - - if (column > 18278 || column < 1) error ("Specified column out of range (1..18278)"); endif - if (row > 1048576 || row < 1), error ('Specified row out of range (1..1048576)'); endif - - str = ''; - while (column > 0.01) - rmd = floor ((column - 1) / 26); - str = [char(column - rmd * 26 + 'A' - 1) str]; - column = rmd; - endwhile - - celladdress = sprintf ("%s%d", str, row); - -endfunction - -%!test -%! a = calccelladdress (1, 1); -%! assert (a, 'A1'); - -%!test -%! a = calccelladdress (378, 28); -%! assert (a, 'AB378'); - -%!test -%! a = calccelladdress (65536, 1024); -%! assert (a, 'AMJ65536'); - -%!test -%! a = calccelladdress (1048576, 16384); -%! assert (a, 'XFD1048576'); - -%!test -%! a = calccelladdress (378, 26); -%! assert (a, 'Z378'); - -%!test -%! a = calccelladdress (378, 702); -%! assert (a, 'ZZ378'); - -%!test -%! a = calccelladdress (378, 701); -%! assert (a, 'ZY378'); - -%!test -%! a = calccelladdress (378, 703); -%! assert (a, 'AAA378'); - -%!test -%! a = calccelladdress (378, 676); -%! assert (a, 'YZ378'); - - +## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr....@us...> + ## + ## 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/>. + + ## calccelladdress (R, C) - compute spreadsheet style cell address from + ## row & column index (both 1-based). + ## + ## Max column index currently set to 18278 (max ODS: 1024, OOXML: 16384). + ## Row limits for ODF and OOXML are 65536 and 1048576, resp. + + ## Author: Philip Nienhuis <prnienhuis at users.sf.net> + ## Created: 2009-12-12 + ## Updates: + ## 2009-12-27 Fixed OOXML limits + ## 2010-03-17 Simplified argument list, only row + column needed + ## 2010-09-27 Made error message more comprehensible + ## 2010-10-11 Added check for row range + ## 2011-04-21 Added tests + ## 2011-04-30 Simplified column name computation + ## 2011-12-17 Bugfix for wrong column address if column equals multiple of 26 + ## 2011-12-18 Added tests for multiple-of-26 cases + + function [ celladdress ] = calccelladdress (row, column) + + if (nargin < 2) error ("calccelladdress: Two arguments needed") endif + + if (column > 18278 || column < 1) error ("Specified column out of range (1..18278)"); endif + if (row > 1048576 || row < 1), error ('Specified row out of range (1..1048576)'); endif + + str = ''; + while (column > 0.01) + rmd = floor ((column - 1) / 26); + str = [char(column - rmd * 26 + 'A' - 1) str]; + column = rmd; + endwhile + + celladdress = sprintf ("%s%d", str, row); + + endfunction + + %!test + %! a = calccelladdress (1, 1); + %! assert (a, 'A1'); + + %!test + %! a = calccelladdress (378, 28); + %! assert (a, 'AB378'); + + %!test + %! a = calccelladdress (65536, 1024); + %! assert (a, 'AMJ65536'); + + %!test + %! a = calccelladdress (1048576, 16384); + %! assert (a, 'XFD1048576'); + + %!test + %! a = calccelladdress (378, 26); + %! assert (a, 'Z378'); + + %!test + %! a = calccelladdress (378, 702); + %! assert (a, 'ZZ378'); + + %!test + %! a = calccelladdress (378, 701); + %! assert (a, 'ZY378'); + + %!test + %! a = calccelladdress (378, 703); + %! assert (a, 'AAA378'); + + %!test + %! a = calccelladdress (378, 676); + %! assert (a, 'YZ378'); + + + \ No newline at end of file Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,587 +1,588 @@ -% Check Octave / Matlab environment for spreadsheet I/O support. -% -% usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO]) -% -% CHK_SPREADSHEET_SUPPORT first checks ActiveX (native MS-Excel); then -% Java JRE presence, then Java support (builtin/activated (Matlab) or -% added tru octave-forge Java package (Octave); then check existing -% javaclasspath for Java class libraries (.jar) needed for various -% Java-based spreadsheet I/O interfaces. -% If desired the relevant classes can be added to the dynamic -% javaclasspath. In that case the path name to the directory -% containing these classes should be specified as input argument -% with -TAKE NOTICE- /forward/ slashes. In these jars reside in -% different directories, multiple calls to chk_spreadsheet_support -% can be made. -% -% Input arguments (all are optional, but the order is important): -% /PATH/TO/JARS = (string) path (relative or absolute) to a -% subdirectory where java class libraries (.jar) -% for spreadsheet I/O reside. Can be [] or '' -% DEBUG_LEVEL = (integer) between [0 (no output) .. 3 (full output] -% PATH_TO_OOO = (string) installation directory of Openffice.org, -% usually (but not guaranteed): -% - Windows: C:\Program Files\OpenOffice.org -% - *nix: /usr/lib/ooo -% - Mac OSX: ????? -% IMPORTANT: PATH_TO_OOO should be such that both: -% 1. PATH_TO_OOO/program/ -% and -% 2. PATH_TO_OOO/ure/.../ridl.jar -% resolve OK -% Returns: -% RETVAL = 0 No spreadsheet I/O support found -% <> 0 At least one spreadsheet I/O interface found. RETVAL -% RETVAL will be set to the sum of values for found interfaces: -% ---------- XLS (Excel) interfaces: ---------- -% 1 = COM (ActiveX / Excel) -% 2 = POI (Java / Apache POI) -% 4 = POI+OOXML (Java / Apache POI) -% 8 = JXL (Java / JExcelAPI) -% 16 = OXS (Java / OpenXLS) -% --- ODS (OpenOffice.org Calc) interfaces ---- -% 32 = OTK (Java/ ODF Toolkit) -% 64 = JOD (Java / jOpenDocument) -% ----------------- XLS & ODS: ---------------- -% 128 = UNO (Java / UNO bridge - OpenOffice.org) - -function [ retval ] = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo) - -% Copyright (C) 2009,2010,2011 Philip Nienhuis <prnienhuis at users.sf.net> -% -% 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/>. - - -% Author: Philip Nienhuis -% Created 2010-11-03 for Octave & Matlab -% Updates: -% 2010-12-19 Found that dom4j-1.6.1.jar is needed regardless of ML's dom4j -% presence in static classpath (ML r2007a) -% 2011-01-04 Adapted for general checks, debugging & set up, both Octave & ML -% 2011-04-04 Rebuilt into general setup/debug tool for spreadsheet I/O support -% and renamed chk_spreadsheet_support() -% 2011-05-04 Added in UNO support (OpenOffice.org & clones) -% '' Improved finding jar names in javaclasspath -% 2011-05-07 Improved help text -% 2011-05-15 Better error msg if OOo instal dir isn't found -% 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) -% 2011-05-27 Fix proper return value (retval); header text improved -% 2011-05-29 Made retval value dependent on detected interfaces & adapted help text -% 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg -% '' Fixed wrong return value update when adding UNO classes -% 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar -% 2011-09-18 Fixed 'Matlab style short circuit' warning in L. 152 -% 2012-12-24 Amended code stanze to find unoil.jar; now works in LibreOffice 3.5b2 as well -% 2012-06-07 Replaced all tabs by double space -% 2012-06-24 Replaced error msg by printf & return -% '' Added Java pkg inquiry (Octave) before attempting javaclasspath() -% '' Updated check for odfdom version (now supports 0.8.8) - - jcp = []; retval = 0; - if (nargin < 3); path_to_ooo= ''; end %if - if (nargin < 2); dbug = 0; end %if - isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; - if (dbug); fprintf ('\n'); end %if - % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital - - % Check if MS-Excel COM ActiveX server runs - if (dbug), fprintf ('Checking Excel/ActiveX/COM... '); end %if - try - app = actxserver ('Excel.application'); - % If we get here, the call succeeded & COM works. - xlsinterfaces.COM = 1; - % Close Excel to avoid zombie Excel invocation - app.Quit(); - delete(app); - if (dbug), fprintf ('OK.\n\n'); end %if - retval = retval + 1; - catch - % COM not supported - if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch - - % Check Java - if (dbug), fprintf ('Checking Java support...\n'); end %if - if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if - % Try if Java is installed at all - if (isOctave) - if (ispc) - jtst = (system ('java -version 2> nul')); - else - jtst = (system ('java -version 2> /dev/null')); - end %if - else - tst1 = version ('-java'); - jtst = isempty (strfind (tst1, 'Java')); - end %if - if (jtst) - printf ('Apparently no Java JRE installed.\n'); - return; - else - if (dbug > 1), fprintf ('OK, found one.\n'); end %if - end %if - if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if - try - if (isOctave) - % Check Java package - [~, b] = pkg ('describe', 'java'); - if (strcmpi (b{:}, 'Not loaded')) - if (dbug > 1); printf ('Java package not loaded. First do: "pkg load java"\n'); end %if - elseif strcmpi (b{:}, 'Not installed') - if (dbug > 1); printf ('Java package is not installed.\n'); end %if - endif - end %if - jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 - if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 - % If we get here, at least Java works. - if (dbug > 1 && isOctave), fprintf ('Java package seems to work OK.\n'); end %if - % Now check for proper version (> 1.6.x.x) - jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version')); - cjver = strsplit (jver, '.'); - if (sscanf (cjver{2}, '%d') < 6) - if (dbug) - fprintf (' Java version (%s) too old - you need at least Java 6 (v. 1.6.x.x)\n', jver); - if (isOctave) - warning (' At Octave prompt, try "!system ("java -version")"'); - else - warning (' At Matlab prompt, try "version -java"'); - end %if - end %if - return - else - if (dbug > 2), fprintf (' Java (version %s) seems OK.\n', jver); end %if - end %if - % Under *nix the classpath must first be split up. - % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() - % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order - if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if - if (dbug > 1) - % Check JVM virtual memory settings - jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); - jmem = jrt.maxMemory (); - if (isOctave), jmem = jmem.doubleValue(); end %if - jmem = int16 (jmem/1024/1024); - fprintf (' Maximum JVM memory: %5d MiB; ', jmem); - if (jmem < 400) - fprintf ('should better be at least 400 MB!\n'); - fprintf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); - if (isOctave) - fprintf (' %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']); - else - fprintf (' $matlabroot/bin/<arch>]\n'); - end %if - else - fprintf ('sufficient.\n'); - end %if - end %if - if (dbug), fprintf ('Java support OK\n'); end %if - catch - printf ('No Java support found.\n'); - return - end %try_catch - - if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if - - % Try Java & Apache POI. First Check basic .xls (BIFF8) support - if (dbug > 1), fprintf ('\nBasic POI (.xls) <poi-3> <poi-ooxml>:\n'); end %if - jpchk1 = 0; entries1 = {'poi-3', 'poi-ooxml-3'}; missing1 = zeros (1, numel (entries1)); - % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname) - % as javaclasspath is one long string. Under Windows however classpath is a cell array - % so we need the following more subtle, platform-independent approach: - for jj=1:length (entries1) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries1{jj})))) - jpchk1 = jpchk1 + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end %for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries1{jj}); end %if - missing1(jj) = 1; - end %if - end %for - if (jpchk1 >= numel (entries1)), retval = retval + 2; end %if - if (dbug > 1) - if (jpchk1 >= numel (entries1)) - fprintf (' => Apache (POI) OK\n'); - else - fprintf (' => Not all classes (.jar) required for POI in classpath\n'); - end %if - end %if - % Next, check OOXML support - if (dbug > 1), fprintf ('\nPOI OOXML (.xlsx) <xbean> <poi-ooxml-schemas> <dom4j>:\n'); end %if - jpchk2 = 0; entries2 = {'xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1'}; - missing2 = zeros (1, numel (entries2)); - for jj=1:length (entries2) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries2{jj})))) - jpchk2 = jpchk2 + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end % for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries2{jj}); end %if - missing2(jj) = 1; - end %if - end % for - % Only update retval if all classes for basic POI have been found in javaclasspath - if (jpchk1 >= numel (entries1) && jpchk2 >= numel (entries2)), retval = retval + 4; end %if - if (dbug > 1) - if (jpchk2 >= numel (entries2)) - fprintf (' => POI OOXML OK\n'); - else - fprintf (' => Some classes for POI OOXML support missing\n'); - end %if - end %if - - % Try Java & JExcelAPI - if (dbug > 1), fprintf ('\nJExcelAPI (.xls (incl. BIFF5 read)) <jxl>:\n'); end %if - jpchk = 0; entries3 = {'jxl'}; missing3 = zeros (1, numel (entries3)); - for jj=1:length (entries3) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries3{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end % if - end %for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries3{jj}); end %if - missing3(jj) = 1; - end %if - end %for - if (jpchk >= numel (entries3)), retval = retval + 8; end %if - if (dbug > 1) - if (jpchk >= numel (entries3)) - fprintf (' => Java/JExcelAPI (JXL) OK.\n'); - else - fprintf (' => Not all classes (.jar) required for JXL in classpath\n'); - end %if - end %if - - % Try Java & OpenXLS - if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if - jpchk = 0; entries4 = {'OpenXLS'}; missing4 = zeros (1, numel (entries4)); - for jj=1:length (entries4) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries4{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end % if - end %for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries4{jj}); end %if - missing4(jj) = 1; - end %if - end %for - if (jpchk >= numel (entries4)), retval = retval + 16; end %if - if (dbug > 1) - if (jpchk >= numel (entries4)) - fprintf (' => Java/OpenXLS (OXS) OK.\n'); - else - fprintf (' => Not all classes (.jar) required for OXS in classpath\n'); - end %if - end %if - - % Try Java & ODF toolkit - if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if - jpchk = 0; entries5 = {'odfdom', 'xercesImpl'}; missing5 = zeros (1, numel (entries5)); - for jj=1:length (entries5) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind ( lower (jcpentry), lower (entries5{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end %for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries5{jj}); end %if - missing5(jj) = 1; - end %if - end %for - if (jpchk >= numel (entries5)) % Apparently all requested classes present. - % Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6 work OK). - % The odfdom team deemed it necessary to change the version call so we need this: - odfvsn = ' '; - try - % New in 0.8.6 - odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); - catch - % Worked in 0.7.5 - odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); - end %try_catch - if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7') - || ~isempty (strfind (odfvsn, '0.8.8'))) - warning (' *** odfdom version (%s) is not supported - use v. 0.8.6 or newer\n', odfvsn); - else - if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if - retval = retval + 32; - end %if - elseif (dbug > 1) - fprintf (' => Not all required classes (.jar) in classpath for OTK\n'); - end %if - - % Try Java & jOpenDocument - if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if - jpchk = 0; entries6 = {'jOpenDocument'}; missing6 = zeros (1, numel (entries6)); - for jj=1:length (entries6) - found = 0; - for ii=1:length (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries6{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end %for - if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries6{jj}); end %if - missing6(jj) = 1; - end %if - end %for - if (jpchk >= numel (entries6)), retval = retval + 64; end %if - if (dbug > 1) - if (jpchk >= numel(entries6)) - fprintf (' => jOpenDocument (JOD) OK.\n'); - else - fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); - end %if - end %if - - % Try Java & UNO - if (dbug > 1), fprintf ('\nUNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if - % entries0(1) = not a jar but a directory (<000_install_dir/program/>) - jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'}; - missing0 = zeros (1, numel (entries0)); - for jj=1:numel (entries0) - found = 0; - for ii=1:numel (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries0{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end %for - if (~found) - if (dbug > 2) - if (jj == 1) - % Just a dir - fprintf (' %s.... (directory) not found\n', entries0{jj}); - else - fprintf (' %s....jar missing\n', entries0{jj}); - end %if - end %if - missing0(jj) = 1; - end %if - end %for - if (jpchk >= numel (entries0)), retval = retval + 128; end %if - if (dbug > 1) - if (jpchk >= numel (entries0)) - fprintf (' => UNO (OOo) OK\n'); - else - fprintf (' => One or more UNO classes (.jar) missing in javaclasspath\n'); - end %if - end %if - - % If requested, try to add UNO stuff to javaclasspath - ujars_complete = isempty (find (missing0, 1)); - - if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) - if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if - if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if - % Add missing jars to javaclasspath. First combine all entries - targt = sum (missing0); - if (missing0(1)) - % Add program dir (= where soffice or soffice.exe or ooffice resides) - programdir = [path_to_ooo filesep entries0{1}]; - if (exist (programdir, 'dir')) - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if - try - javaaddpath (programdir); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch - else - if (dbug > 2) - printf ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); - return - end %if - end %if - end %if - % Rest of missing entries. Find where URE is located. Watch out because case of ./ure is unknown - uredir = get_dir_ (path_to_ooo, 'ure'); - if (isempty (uredir)), return; end %if - % Now search for UNO jars - for ii=2:length (entries0) - if (missing0(ii)) - if (ii == 2) - % Special case as unoil.jar usually resides in ./Basis<something>/program/classes - % Find out the exact name of Basis..... - basisdirlst = dir ([path_to_ooo filesep '?asis' '*']); - jj = 1; - if (numel (basisdirlst) > 0) - while (jj <= size (basisdirlst, 1) && jj > 0) - basisdir = basisdirlst(jj).name; - if (basisdirlst(jj).isdir) - basisdir = basisdirlst(jj).name; - jj = 0; - else - jj = jj + 1; - end %if - end %while - basisdir = [path_to_ooo filesep basisdir ]; - else - basisdir = path_to_ooo; - endif - basisdirentries = {'program', 'classes'}; - tmp = basisdir; jj=1; - while (~isempty (tmp) && jj <= numel (basisdirentries)) - tmp = get_dir_ (tmp, basisdirentries{jj}); - jj = jj + 1; - end %if - unojarpath = tmp; - file = dir ([ unojarpath filesep entries0{2} '*' ]); - else - % Rest of jars in ./ure/share/java or ./ure/java - unojardir = get_dir_ (uredir, 'share'); - if (isempty (unojardir)) - tmp = uredir; - else - tmp = unojardir; - end %if - unojarpath = get_dir_ (tmp, 'java'); - file = dir ([unojarpath filesep entries0{ii} '*']); - end %if - % Path found, now try to add jar - if (isempty (file)) - if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', entries0{ii}); end %if - else - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file.name); end %if - try - javaaddpath ([unojarpath filesep file.name]); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch - end %if - end %if - end %for - if (~targt); retval = retval + 128; end %if - if (dbug) - if (targt) - fprintf ('Some UNO class libs still lacking...\n\n'); - else - fprintf ('UNO interface supported now.\n\n'); - end %if - end %f - end %if - -% ----------Rest of Java interfaces---------------------------------- - - missing = [missing1 missing2 missing3 missing4 missing5 missing6]; - jars_complete = isempty (find (missing, 1)); - if (dbug) - if (jars_complete) - fprintf ('All Java-based interfaces (save UNO) fully supported.\n\n'); - else - fprintf ('Some class libs lacking yet...\n\n'); - end %if - end %if - - if (~jars_complete && nargin > 0 && ~isempty (path_to_jars)) - % Add missing jars to javaclasspath. Assume they're all in the same place - if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if - if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if - % First combine all entries - targt = sum (missing); - % Search tru list of missing entries - for ii=1:6 % Adapt in case of future new interfaces - tmpe = eval ([ 'entries' char(ii + '0') ]); - tmpm = eval ([ 'missing' char(ii + '0') ]); - if (sum (tmpm)) - for jj=1:numel (tmpe) - if (tmpm(jj)) - file = dir ([path_to_jars filesep tmpe{jj} '*']); - if (isempty (file)) - if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', tmpe{jj}); end %if - else - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file(1).name); end %if - try - javaaddpath ([path_to_jars filesep file(1).name]); - targt = targt - 1; - tmpm(jj) = 0; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch - end %if - end %if - end %for - if (~sum (tmpm)) - retval = retval + 2^ii; - end %if - end %if - end %for - if (dbug) - if (targt) - fprintf ('Some other class libs still lacking...\n\n'); - else - fprintf ('All Java-based interfaces fully supported.now.\n\n'); - end %if - end %f - end %if - -end %function - - -function [ ret_dir ] = get_dir_ (base_dir, req_dir) - -% Construct path to subdirectory req_dir in a subdir tree, aimed -% at taking care of proper case (esp. for *nix) of existing subdir -% in the result. Case of input var req_dir is ignored on purpose. - - ret_dir = ''; - % Get list of directory entries - ret_dir_list = dir (base_dir); - % Find matching entries - idx = find (strcmpi ({ret_dir_list.name}, req_dir)); - % On *nix, several files and subdirs in one dir may have the same name as long as case differs - if (~isempty (idx)) - ii = 1; - while (~ret_dir_list(idx(ii)).isdir) - ii = ii + 1; - if (ii > numel (idx)); return; end %if - end %while - % If we get here, a dir with proper name has been found. Construct path - ret_dir = [ base_dir filesep ret_dir_list(idx(ii)).name ]; - end %if - -end %function +% Check Octave / Matlab environment for spreadsheet I/O support. + % + % usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO]) + % + % CHK_SPREADSHEET_SUPPORT first checks ActiveX (native MS-Excel); then + % Java JRE presence, then Java support (builtin/activated (Matlab) or + % added tru octave-forge Java package (Octave); then check existing + % javaclasspath for Java class libraries (.jar) needed for various + % Java-based spreadsheet I/O interfaces. + % If desired the relevant classes can be added to the dynamic + % javaclasspath. In that case the path name to the directory + % containing these classes should be specified as input argument + % with -TAKE NOTICE- /forward/ slashes. In these jars reside in + % different directories, multiple calls to chk_spreadsheet_support + % can be made. + % + % Input arguments (all are optional, but the order is important): + % /PATH/TO/JARS = (string) path (relative or absolute) to a + % subdirectory where java class libraries (.jar) + % for spreadsheet I/O reside. Can be [] or '' + % DEBUG_LEVEL = (integer) between [0 (no output) .. 3 (full output] + % PATH_TO_OOO = (string) installation directory of Openffice.org, + % usually (but not guaranteed): + % - Windows: C:\Program Files\OpenOffice.org + % - *nix: /usr/lib/ooo + % - Mac OSX: ????? + % IMPORTANT: PATH_TO_OOO should be such that both: + % 1. PATH_TO_OOO/program/ + % and + % 2. PATH_TO_OOO/ure/.../ridl.jar + % resolve OK + % Returns: + % RETVAL = 0 No spreadsheet I/O support found + % <> 0 At least one spreadsheet I/O interface found. RETVAL + % RETVAL will be set to the sum of values for found interfaces: + % ---------- XLS (Excel) interfaces: ---------- + % 1 = COM (ActiveX / Excel) + % 2 = POI (Java / Apache POI) + % 4 = POI+OOXML (Java / Apache POI) + % 8 = JXL (Java / JExcelAPI) + % 16 = OXS (Java / OpenXLS) + % --- ODS (OpenOffice.org Calc) interfaces ---- + % 32 = OTK (Java/ ODF Toolkit) + % 64 = JOD (Java / jOpenDocument) + % ----------------- XLS & ODS: ---------------- + % 128 = UNO (Java / UNO bridge - OpenOffice.org) + + function [ retval ] = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo) + + % Copyright (C) 2009,2010,2011 Philip Nienhuis <prnienhuis at users.sf.net> + % + % 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/>. + + + % Author: Philip Nienhuis + % Created 2010-11-03 for Octave & Matlab + % Updates: + % 2010-12-19 Found that dom4j-1.6.1.jar is needed regardless of ML's dom4j + % presence in static classpath (ML r2007a) + % 2011-01-04 Adapted for general checks, debugging & set up, both Octave & ML + % 2011-04-04 Rebuilt into general setup/debug tool for spreadsheet I/O support + % and renamed chk_spreadsheet_support() + % 2011-05-04 Added in UNO support (OpenOffice.org & clones) + % '' Improved finding jar names in javaclasspath + % 2011-05-07 Improved help text + % 2011-05-15 Better error msg if OOo instal dir isn't found + % 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) + % 2011-05-27 Fix proper return value (retval); header text improved + % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text + % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg + % '' Fixed wrong return value update when adding UNO classes + % 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar + % 2011-09-18 Fixed 'Matlab style short circuit' warning in L. 152 + % 2012-12-24 Amended code stanze to find unoil.jar; now works in LibreOffice 3.5b2 as well + % 2012-06-07 Replaced all tabs by double space + % 2012-06-24 Replaced error msg by printf & return + % '' Added Java pkg inquiry (Octave) before attempting javaclasspath() + % '' Updated check for odfdom version (now supports 0.8.8) + + jcp = []; retval = 0; + if (nargin < 3); path_to_ooo= ''; end %if + if (nargin < 2); dbug = 0; end %if + isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; + if (dbug); fprintf ('\n'); end %if + % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital + + % Check if MS-Excel COM ActiveX server runs + if (dbug), fprintf ('Checking Excel/ActiveX/COM... '); end %if + try + app = actxserver ('Excel.application'); + % If we get here, the call succeeded & COM works. + xlsinterfaces.COM = 1; + % Close Excel to avoid zombie Excel invocation + app.Quit(); + delete(app); + if (dbug), fprintf ('OK.\n\n'); end %if + retval = retval + 1; + catch + % COM not supported + if (dbug), fprintf ('not working.\n\n'); end %if + end %try_catch + + % Check Java + if (dbug), fprintf ('Checking Java support...\n'); end %if + if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if + % Try if Java is installed at all + if (isOctave) + if (ispc) + jtst = (system ('java -version 2> nul')); + else + jtst = (system ('java -version 2> /dev/null')); + end %if + else + tst1 = version ('-java'); + jtst = isempty (strfind (tst1, 'Java')); + end %if + if (jtst) + printf ('Apparently no Java JRE installed.\n'); + return; + else + if (dbug > 1), fprintf ('OK, found one.\n'); end %if + end %if + if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if + try + if (isOctave) + % Check Java package + [~, b] = pkg ('describe', 'java'); + if (strcmpi (b{:}, 'Not loaded')) + if (dbug > 1); printf ('Java package not loaded. First do: "pkg load java"\n'); end %if + elseif strcmpi (b{:}, 'Not installed') + if (dbug > 1); printf ('Java package is not installed.\n'); end %if + endif + end %if + jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 + if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 + % If we get here, at least Java works. + if (dbug > 1 && isOctave), fprintf ('Java package seems to work OK.\n'); end %if + % Now check for proper version (> 1.6.x.x) + jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version')); + cjver = strsplit (jver, '.'); + if (sscanf (cjver{2}, '%d') < 6) + if (dbug) + fprintf (' Java version (%s) too old - you need at least Java 6 (v. 1.6.x.x)\n', jver); + if (isOctave) + warning (' At Octave prompt, try "!system ("java -version")"'); + else + warning (' At Matlab prompt, try "version -java"'); + end %if + end %if + return + else + if (dbug > 2), fprintf (' Java (version %s) seems OK.\n', jver); end %if + end %if + % Under *nix the classpath must first be split up. + % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() + % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order + if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if + if (dbug > 1) + % Check JVM virtual memory settings + jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); + jmem = jrt.maxMemory (); + if (isOctave), jmem = jmem.doubleValue(); end %if + jmem = int16 (jmem/1024/1024); + fprintf (' Maximum JVM memory: %5d MiB; ', jmem); + if (jmem < 400) + fprintf ('should better be at least 400 MB!\n'); + fprintf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); + if (isOctave) + fprintf (' %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']); + else + fprintf (' $matlabroot/bin/<arch>]\n'); + end %if + else + fprintf ('sufficient.\n'); + end %if + end %if + if (dbug), fprintf ('Java support OK\n'); end %if + catch + printf ('No Java support found.\n'); + return + end %try_catch + + if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if + + % Try Java & Apache POI. First Check basic .xls (BIFF8) support + if (dbug > 1), fprintf ('\nBasic POI (.xls) <poi-3> <poi-ooxml>:\n'); end %if + jpchk1 = 0; entries1 = {'poi-3', 'poi-ooxml-3'}; missing1 = zeros (1, numel (entries1)); + % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname) + % as javaclasspath is one long string. Under Windows however classpath is a cell array + % so we need the following more subtle, platform-independent approach: + for jj=1:length (entries1) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries1{jj})))) + jpchk1 = jpchk1 + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries1{jj}); end %if + missing1(jj) = 1; + end %if + end %for + if (jpchk1 >= numel (entries1)), retval = retval + 2; end %if + if (dbug > 1) + if (jpchk1 >= numel (entries1)) + fprintf (' => Apache (POI) OK\n'); + else + fprintf (' => Not all classes (.jar) required for POI in classpath\n'); + end %if + end %if + % Next, check OOXML support + if (dbug > 1), fprintf ('\nPOI OOXML (.xlsx) <xbean> <poi-ooxml-schemas> <dom4j>:\n'); end %if + jpchk2 = 0; entries2 = {'xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1'}; + missing2 = zeros (1, numel (entries2)); + for jj=1:length (entries2) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries2{jj})))) + jpchk2 = jpchk2 + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end % for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries2{jj}); end %if + missing2(jj) = 1; + end %if + end % for + % Only update retval if all classes for basic POI have been found in javaclasspath + if (jpchk1 >= numel (entries1) && jpchk2 >= numel (entries2)), retval = retval + 4; end %if + if (dbug > 1) + if (jpchk2 >= numel (entries2)) + fprintf (' => POI OOXML OK\n'); + else + fprintf (' => Some classes for POI OOXML support missing\n'); + end %if + end %if + + % Try Java & JExcelAPI + if (dbug > 1), fprintf ('\nJExcelAPI (.xls (incl. BIFF5 read)) <jxl>:\n'); end %if + jpchk = 0; entries3 = {'jxl'}; missing3 = zeros (1, numel (entries3)); + for jj=1:length (entries3) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries3{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end % if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries3{jj}); end %if + missing3(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries3)), retval = retval + 8; end %if + if (dbug > 1) + if (jpchk >= numel (entries3)) + fprintf (' => Java/JExcelAPI (JXL) OK.\n'); + else + fprintf (' => Not all classes (.jar) required for JXL in classpath\n'); + end %if + end %if + + % Try Java & OpenXLS + if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if + jpchk = 0; entries4 = {'OpenXLS'}; missing4 = zeros (1, numel (entries4)); + for jj=1:length (entries4) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries4{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end % if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries4{jj}); end %if + missing4(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries4)), retval = retval + 16; end %if + if (dbug > 1) + if (jpchk >= numel (entries4)) + fprintf (' => Java/OpenXLS (OXS) OK.\n'); + else + fprintf (' => Not all classes (.jar) required for OXS in classpath\n'); + end %if + end %if + + % Try Java & ODF toolkit + if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if + jpchk = 0; entries5 = {'odfdom', 'xercesImpl'}; missing5 = zeros (1, numel (entries5)); + for jj=1:length (entries5) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind ( lower (jcpentry), lower (entries5{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries5{jj}); end %if + missing5(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries5)) % Apparently all requested classes present. + % Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6 work OK). + % The odfdom team deemed it necessary to change the version call so we need this: + odfvsn = ' '; + try + % New in 0.8.6 + odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); + catch + % Worked in 0.7.5 + odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); + end %try_catch + if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7') + || ~isempty (strfind (odfvsn, '0.8.8'))) + warning (' *** odfdom version (%s) is not supported - use v. 0.8.6 or newer\n', odfvsn); + else + if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if + retval = retval + 32; + end %if + elseif (dbug > 1) + fprintf (' => Not all required classes (.jar) in classpath for OTK\n'); + end %if + + % Try Java & jOpenDocument + if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if + jpchk = 0; entries6 = {'jOpenDocument'}; missing6 = zeros (1, numel (entries6)); + for jj=1:length (entries6) + found = 0; + for ii=1:length (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries6{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries6{jj}); end %if + missing6(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries6)), retval = retval + 64; end %if + if (dbug > 1) + if (jpchk >= numel(entries6)) + fprintf (' => jOpenDocument (JOD) OK.\n'); + else + fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); + end %if + end %if + + % Try Java & UNO + if (dbug > 1), fprintf ('\nUNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if + % entries0(1) = not a jar but a directory (<000_install_dir/program/>) + jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'}; + missing0 = zeros (1, numel (entries0)); + for jj=1:numel (entries0) + found = 0; + for ii=1:numel (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries0{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2) + if (jj == 1) + % Just a dir + fprintf (' %s.... (directory) not found\n', entries0{jj}); + else + fprintf (' %s....jar missing\n', entries0{jj}); + end %if + end %if + missing0(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries0)), retval = retval + 128; end %if + if (dbug > 1) + if (jpchk >= numel (entries0)) + fprintf (' => UNO (OOo) OK\n'); + else + fprintf (' => One or more UNO classes (.jar) missing in javaclasspath\n'); + end %if + end %if + + % If requested, try to add UNO stuff to javaclasspath + ujars_complete = isempty (find (missing0, 1)); + + if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) + if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if + if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if + % Add missing jars to javaclasspath. First combine all entries + targt = sum (missing0); + if (missing0(1)) + % Add program dir (= where soffice or soffice.exe or ooffice resides) + programdir = [path_to_ooo filesep entries0{1}]; + if (exist (programdir, 'dir')) + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if + try + javaaddpath (programdir); + targt = targt - 1; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + if (dbug > 2), fprintf ('FAILED\n'); end %if + end %try_catch + else + if (dbug > 2) + printf ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); + return + end %if + end %if + end %if + % Rest of missing entries. Find where URE is located. Watch out because case of ./ure is unknown + uredir = get_dir_ (path_to_ooo, 'ure'); + if (isempty (uredir)), return; end %if + % Now search for UNO jars + for ii=2:length (entries0) + if (missing0(ii)) + if (ii == 2) + % Special case as unoil.jar usually resides in ./Basis<something>/program/classes + % Find out the exact name of Basis..... + basisdirlst = dir ([path_to_ooo filesep '?asis' '*']); + jj = 1; + if (numel (basisdirlst) > 0) + while (jj <= size (basisdirlst, 1) && jj > 0) + basisdir = basisdirlst(jj).name; + if (basisdirlst(jj).isdir) + basisdir = basisdirlst(jj).name; + jj = 0; + else + jj = jj + 1; + end %if + end %while + basisdir = [path_to_ooo filesep basisdir ]; + else + basisdir = path_to_ooo; + endif + basisdirentries = {'program', 'classes'}; + tmp = basisdir; jj=1; + while (~isempty (tmp) && jj <= numel (basisdirentries)) + tmp = get_dir_ (tmp, basisdirentries{jj}); + jj = jj + 1; + end %if + unojarpath = tmp; + file = dir ([ unojarpath filesep entries0{2} '*' ]); + else + % Rest of jars in ./ure/share/java or ./ure/java + unojardir = get_dir_ (uredir, 'share'); + if (isempty (unojardir)) + tmp = uredir; + else + tmp = unojardir; + end %if + unojarpath = get_dir_ (tmp, 'java'); + file = dir ([unojarpath filesep entries0{ii} '*']); + end %if + % Path found, now try to add jar + if (isempty (file)) + if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', entries0{ii}); end %if + else + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file.name); end %if + try + javaaddpath ([unojarpath filesep file.name]); + targt = targt - 1; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + if (dbug > 2), fprintf ('FAILED\n'); end %if + end %try_catch + end %if + end %if + end %for + if (~targt); retval = retval + 128; end %if + if (dbug) + if (targt) + fprintf ('Some UNO class libs still lacking...\n\n'); + else + fprintf ('UNO interface supported now.\n\n'); + end %if + end %f + end %if + + % ----------Rest of Java interfaces---------------------------------- + + missing = [missing1 missing2 missing3 missing4 missing5 missing6]; + jars_complete = isempty (find (missing, 1)); + if (dbug) + if (jars_complete) + fprintf ('All Java-based interfaces (save UNO) fully supported.\n\n'); + else + fprintf ('Some class libs lacking yet...\n\n'); + end %if + end %if + + if (~jars_complete && nargin > 0 && ~isempty (path_to_jars)) + % Add missing jars to javaclasspath. Assume they're all in the same place + if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if + if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if + % First combine all entries + targt = sum (missing); + % Search tru list of missing entries + for ii=1:6 % Adapt in case of future new interfaces + tmpe = eval ([ 'entries' char(ii + '0') ]); + tmpm = eval ([ 'missing' char(ii + '0') ]); + if (sum (tmpm)) + for jj=1:numel (tmpe) + if (tmpm(jj)) + file = dir ([path_to_jars filesep tmpe{jj} '*']); + if (isempty (file)) + if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', tmpe{jj}); end %if + else + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file(1).name); end %if + try + javaaddpath ([path_to_jars filesep file(1).name]); + targt = targt - 1; + tmpm(jj) = 0; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + if (dbug > 2), fprintf ('FAILED\n'); end %if + end %try_catch + end %if + end %if + end %for + if (~sum (tmpm)) + retval = retval + 2^ii; + end %if + end %if + end %for + if (dbug) + if (targt) + fprintf ('Some other class libs still lacking...\n\n'); + else + fprintf ('All Java-based interfaces fully supported.now.\n\n'); + end %if + end %f + end %if + + end %function + + + function [ ret_dir ] = get_dir_ (base_dir, req_dir) + + % Construct path to subdirectory req_dir in a subdir tree, aimed + % at taking care of proper case (esp. for *nix) of existing subdir + % in the result. Case of input var req_dir is ignored on purpose. + + ret_dir = ''; + % Get list of directory entries + ret_dir_list = dir (base_dir); + % Find matching entries + idx = find (strcmpi ({ret_dir_list.name}, req_dir)); + % On *nix, several files and subdirs in one dir may have the same name as long as case differs + if (~isempty (idx)) + ii = 1; + while (~ret_dir_list(idx(ii)).isdir) + ii = ii + 1; + if (ii > numel (idx)); return; end %if + end %while + % If we get here, a dir with proper name has been found. Construct path + ret_dir = [ base_dir filesep ret_dir_list(idx(ii)).name ]; + end %if + + end %function + \ No newline at end of file Modified: trunk/octave-forge/main/io/inst/getusedrange.m =================================================================== --- trunk/octave-forge/main/io/inst/getusedrange.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/getusedrange.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,659 +1,660 @@ -## Copyright (C) 2010,2011,2012 Philip Nienhuis <pr....@us...> -## -## 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/>. - -## -*- texinfo -*- -## @deftypefn {Function File} [ @var{toprow#}, @var{bottomrow#}, @var{leftcol#}, @var{rightcol#} ] = getusedrange (@var{spptr}, @var{shindex#}) -## Find occupied data range in worksheet @var{shindex#} in a spreadsheet -## pointed to in struct @var{spptr} (either MS-Excel or -## OpenOffice_org Calc). -## -## @var{shindex#} must be numeric and is 1-based. @var{spptr} can either -## refer to an MS-Excel spreadsheet (spptr returned by xlsopen) or an -## OpenOffice.org Calc spreadsheet (spptr returned by odsopen). -## None of these inputs are checked! -## -## Be aware that especially for OpenOffice.org Calc (ODS) spreadsheets -## the results can only be obtained by counting all cells in all rows; -## this can be fairly time-consuming. Reliable ods data size results can -## only be obtained using UNO interface. -## For the ActiveX (COM) interface the underlying Visual Basic call relies -## on cached range values and counts empty cells with only formatting too, -## so COM returns only approximate (but then usually too big) range values. -## -## Examples: -## -## @example -## [trow, brow, lcol, rcol] = getusedrange (ods2, 3); -## (which returns the outermost... [truncated message content] |
From: <prn...@us...> - 2012-09-07 14:11:58
|
Revision: 10971 http://octave.svn.sourceforge.net/octave/?rev=10971&view=rev Author: prnienhuis Date: 2012-09-07 14:11:47 +0000 (Fri, 07 Sep 2012) Log Message: ----------- CRLF to LF Modified Paths: -------------- trunk/octave-forge/main/io/INDEX trunk/octave-forge/main/io/PKG_ADD trunk/octave-forge/main/io/PKG_DEL Modified: trunk/octave-forge/main/io/INDEX =================================================================== --- trunk/octave-forge/main/io/INDEX 2012-09-07 12:58:28 UTC (rev 10970) +++ trunk/octave-forge/main/io/INDEX 2012-09-07 14:11:47 UTC (rev 10971) @@ -1,44 +1,45 @@ -io >> Input from and output to external formats -File I/O - append_save - fexist -Miscellaneous conversion functions - object2json - pch2mat -CSV file functions - csv2cell - csvconcat - csvexplode - cell2csv -XML I/O - xmlread - xmlwrite -Spreadsheet I/O user functions for MS-Excel - oct2xls - xls2oct - xlsclose - xlsfinfo - xlsopen - xlsread - xlswrite -Spreadsheet I/O user functions for OpenOffice.org Calc - oct2ods - ods2oct - odsclose - odsfinfo - odsopen - odsread - odswrite -Spreadsheet utility functions - calccelladdress - chk_spreadsheet_support - parsecell -Spreadsheet I/O internal functions - getusedrange - parse_sp_range - spsh_chkrange - spsh_prstype -Spreadsheet function test scripts - io_xls_testscript - io_ods_testscript - +io >> Input from and output to external formats + File I/O + append_save + fexist + Miscellaneous conversion functions + object2json + pch2mat + CSV file functions + csv2cell + csvconcat + csvexplode + cell2csv + XML I/O + xmlread + xmlwrite + Spreadsheet I/O user functions for MS-Excel + oct2xls + xls2oct + xlsclose + xlsfinfo + xlsopen + xlsread + xlswrite + Spreadsheet I/O user functions for OpenOffice.org Calc + oct2ods + ods2oct + odsclose + odsfinfo + odsopen + odsread + odswrite + Spreadsheet utility functions + calccelladdress + chk_spreadsheet_support + parsecell + Spreadsheet I/O internal functions + getusedrange + parse_sp_range + spsh_chkrange + spsh_prstype + Spreadsheet function test scripts + io_xls_testscript + io_ods_testscript + + \ No newline at end of file Modified: trunk/octave-forge/main/io/PKG_ADD =================================================================== --- trunk/octave-forge/main/io/PKG_ADD 2012-09-07 12:58:28 UTC (rev 10970) +++ trunk/octave-forge/main/io/PKG_ADD 2012-09-07 14:11:47 UTC (rev 10971) @@ -1,16 +1,17 @@ -## PKG_ADD -## add paths of io pkg java jars if java pkg is installed and loaded -pkglist = pkg ("list"); -javapkgind = find (cellfun (@(x) strcmp(x.name, "java"), pkglist), 1, "first"); -if (! isempty (javapkgind)) - javapkg = pkglist{javapkgind}; - if (javapkg.loaded) - # Assume jar files are in /lib/java and let chk_spreadsheet_support sort it out - libdir = octave_config_info ("libdir"); - ## Allow time for package to be fully loaded - pause (0.25); - spr_status = chk_spreadsheet_support ([ libdir filesep "java" ]); - endif -endif -## Clean up -clear javapkgind javapkg libdir spr_status pkglist ; \ No newline at end of file +## PKG_ADD + ## add paths of io pkg java jars if java pkg is installed and loaded + pkglist = pkg ("list"); + javapkgind = find (cellfun (@(x) strcmp(x.name, "java"), pkglist), 1, "first"); + if (! isempty (javapkgind)) + keyboard + javapkg = pkglist{javapkgind}; + if (javapkg.loaded) + # Assume jar files are in /lib/java and let chk_spreadsheet_support sort it out + libdir = octave_config_info ("libdir"); + ## Allow time for package to be fully loaded + pause (0.25); + spr_status = chk_spreadsheet_support ([ libdir filesep "java" ]); + endif + endif + ## Clean up + clear javapkgind javapkg libdir spr_status pkglist ; \ No newline at end of file Modified: trunk/octave-forge/main/io/PKG_DEL =================================================================== --- trunk/octave-forge/main/io/PKG_DEL 2012-09-07 12:58:28 UTC (rev 10970) +++ trunk/octave-forge/main/io/PKG_DEL 2012-09-07 14:11:47 UTC (rev 10971) @@ -1,7 +1,8 @@ -## PKG_DEL -## -## Below are base names of spreadsheet I/O Java class libs. -## They'll stay (harmless) in the javaclasspath until termination of the current Octave session. -## {'poi-3', 'poi-ooxml-3', xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1', 'jxl', 'openxls', ... -## 'odfdom', 'xercesImpl', 'jopendocument', ... -## 'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'} +## PKG_DEL + ## + ## Below are base names of spreadsheet I/O Java class libs. + ## They'll stay (harmless) in the javaclasspath until termination of the current Octave session. + ## {'poi-3', 'poi-ooxml-3', xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1', 'jxl', 'openxls', ... + ## 'odfdom', 'xercesImpl', 'jopendocument', ... + ## 'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'} + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-07 12:58:39
|
Revision: 10970 http://octave.svn.sourceforge.net/octave/?rev=10970&view=rev Author: prnienhuis Date: 2012-09-07 12:58:28 +0000 (Fri, 07 Sep 2012) Log Message: ----------- Style changes + filesep rather than hard-coded "/" Modified Paths: -------------- trunk/octave-forge/main/io/PKG_ADD Modified: trunk/octave-forge/main/io/PKG_ADD =================================================================== --- trunk/octave-forge/main/io/PKG_ADD 2012-09-07 09:01:00 UTC (rev 10969) +++ trunk/octave-forge/main/io/PKG_ADD 2012-09-07 12:58:28 UTC (rev 10970) @@ -1,14 +1,16 @@ ## PKG_ADD ## add paths of io pkg java jars if java pkg is installed and loaded pkglist = pkg ("list"); -javapkgind = find (cellfun(@(x) strcmp(x.name, "java"), pkglist), 1, "first"); -if ~isempty (javapkgind) +javapkgind = find (cellfun (@(x) strcmp(x.name, "java"), pkglist), 1, "first"); +if (! isempty (javapkgind)) javapkg = pkglist{javapkgind}; - if javapkg.loaded + if (javapkg.loaded) # Assume jar files are in /lib/java and let chk_spreadsheet_support sort it out - libdir = octave_config_info("libdir"); - pause (0.5); - spr_status = chk_spreadsheet_support ([libdir "/java"]); + libdir = octave_config_info ("libdir"); + ## Allow time for package to be fully loaded + pause (0.25); + spr_status = chk_spreadsheet_support ([ libdir filesep "java" ]); endif endif +## Clean up clear javapkgind javapkg libdir spr_status pkglist ; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-07 09:01:11
|
Revision: 10969 http://octave.svn.sourceforge.net/octave/?rev=10969&view=rev Author: prnienhuis Date: 2012-09-07 09:01:00 +0000 (Fri, 07 Sep 2012) Log Message: ----------- Updated text Modified Paths: -------------- trunk/octave-forge/main/io/doc/READ-ODS.html trunk/octave-forge/main/io/doc/READ-XLS.html Modified: trunk/octave-forge/main/io/doc/READ-ODS.html =================================================================== --- trunk/octave-forge/main/io/doc/READ-ODS.html 2012-09-07 08:55:50 UTC (rev 10968) +++ trunk/octave-forge/main/io/doc/READ-ODS.html 2012-09-07 09:01:00 UTC (rev 10969) @@ -18,7 +18,7 @@ Copyright \xA9 2009 - 2012 Philip Nienhuis <prnienhuis at users.sf.net></font></font> </p> <p align="center"><font face="Arial, sans-serif"><font size="2"> - This version June 08, 2012</font></font> + This version September 7, 2012</font></font> </p> <p><font face="Arial, sans-serif"><font size="2"> <i>(ODS = Open Document Format spreadsheet data format, used by e.g., OpenOffice.org.)</i></font></font> @@ -88,14 +88,19 @@ <ul> <li> <p align="left"><font face="Arial, sans-serif"><font size="2"> - (currently the preferred option) <b>odfdom.jar</b> (<u>only</u> versions <b>0.7.5</b>, - <b>0.8.6</b>, <b>0.8.7</b> and <b>0.8.8</b>(-incubator) work OK!) & <b>xercesImpl.jar</b> (watch out here too! only version 2.9.1 (2007-sep-14) works OK with odfdom). Get them here: + <b>odfdom.jar</b> currently the preferred option)<br> + (<u>only</u> versions <b>0.7.5</b>, + <b>0.8.6</b>, <b>0.8.7</b> and <b>0.8.8</b> (the latter from incubator v. 0.5, see download URL below) work OK!) & <b>xercesImpl.jar</b> (watch out here too! only version 2.9.1 (2007-sep-14) works OK with odfdom). Get them here: </font></font></p> - </li><li><p align="left"> - <a href="http://odftoolkit.org/projects/odfdom/pages/Home"><font face="Arial, sans-serif"><font size="2">http://odftoolkit.org/projects/odfdom/pages/Home</font></font></a></p></li> - <li><p align="left" lang="zxx"> - <font color="#000080"><font face="Arial, sans-serif"><font size="2"><a href="http://incubator.apache.org/odftoolkit/downloads.html"><font face="Arial, sans-serif"><font size="2">http://incubator.apache.org/odftoolkit/downloads.html</font></font></a></font></font></font></p></li><li><p align="left"> - <a href="http://www.google.com/search?ie=UTF-8&oe=utf-8&q=xerces-2.9.1+download"><font face="Arial, sans-serif"><font size="2">Google for xerces-2.9.1 download </font></font></a></p></li> + </li> + <ul> + <li> + <p align="left"><a href="http://odftoolkit.org/projects/odfdom/pages/Home"><font face="Arial, sans-serif"><font size="2">http://odftoolkit.org/projects/odfdom/pages/Home</font></font></a></p> + </li><li> + <p align="left" lang="zxx"><font color="#000080"><font face="Arial, sans-serif"><font size="2"><a href="http://incubator.apache.org/odftoolkit/downloads.html"><font face="Arial, sans-serif"><font size="2">http://incubator.apache.org/odftoolkit/downloads.html</font></font></a> (preferred)</font></font></font></p> + </li><li><p align="left"><a href="http://www.google.com/search?ie=UTF-8&oe=utf-8&q=xerces-2.9.1+download"><font face="Arial, sans-serif"><font size="2">Google for xerces-2.9.1 download</a></p> + </li> + </ul> </ul> <dl><dt><p> <br><font face="Arial, sans-serif"><font size="2">and/or</font></font> @@ -557,7 +562,7 @@ <font face="Arial, sans-serif"><font size="2">oct2ods.m (revision 7159)</font></font></li></ul> <p><font face="Arial, sans-serif"><font size="2">Enjoy!</font></font></p><p align="center"><font face="Arial, sans-serif"><font size="2">Philip - Nienhuis, June 08, 2012</font></font></p><dl><dd><p align="center"> + Nienhuis, September 7, 2012</font></font></p><dl><dd><p align="center"> <br> </p></dd></dl> </body></html> \ No newline at end of file Modified: trunk/octave-forge/main/io/doc/READ-XLS.html =================================================================== --- trunk/octave-forge/main/io/doc/READ-XLS.html 2012-09-07 08:55:50 UTC (rev 10968) +++ trunk/octave-forge/main/io/doc/READ-XLS.html 2012-09-07 09:01:00 UTC (rev 10969) @@ -13,7 +13,7 @@ <BR> Copyright (C) 2009 - 2012 Philip Nienhuis <prnienhuis at users.sf.net><BR> <BR> -This version June 7, 2012</P> +This version September 7, 2012</P> </FONT></FONT><B><U><FONT FACE="Arial, sans-serif" SIZE=4><FONT FACE="Arial, sans-serif" SIZE=4><P ALIGN="CENTER">EXCEL .XLS SUPPORT FILES</P> </B></U></FONT></FONT><FONT FACE="Arial, sans-serif" SIZE=2><FONT FACE="Arial, sans-serif" SIZE=2><DL> <DT><BR> @@ -68,7 +68,7 @@ <UL> <FONT FACE="Arial, sans-serif" SIZE=2><FONT FACE="Arial, sans-serif" SIZE=2><LI>octave-forge java-1.2.8 package or later version on Linux</LI> -<LI>octave-forge java-1.2.8 with latest svn fixes on Windows/MingW</LI> +<LI>octave-forge java-1.2.8 with latest svn fixes, or later version on Windows/MingW</LI> <LI>Java JRE or JDK > 1.6.0 (hasn't been tested with earlier versions)</LI></UL> <DL> @@ -327,6 +327,6 @@ <P>Enjoy!</FONT></FONT> </P> <FONT FACE="Arial, sans-serif" SIZE=2><FONT FACE="Arial, sans-serif" SIZE=2><DL> -<DD ALIGN="CENTER">Philip Nienhuis, June 7, 2012</DD> +<DD ALIGN="CENTER">Philip Nienhuis, September 7, 2012</DD> </DL></FONT></FONT></BODY> </HTML> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-09-07 08:55:59
|
Revision: 10968 http://octave.svn.sourceforge.net/octave/?rev=10968&view=rev Author: cdf Date: 2012-09-07 08:55:50 +0000 (Fri, 07 Sep 2012) Log Message: ----------- get rid of oct files Modified Paths: -------------- trunk/octave-forge/extra/fpl/DESCRIPTION trunk/octave-forge/extra/fpl/NEWS trunk/octave-forge/extra/fpl/inst/fpl_vtk_b64_write_field.m trunk/octave-forge/extra/fpl/inst/fpl_vtk_raw_write_field.m Removed Paths: ------------- trunk/octave-forge/extra/fpl/src/ Modified: trunk/octave-forge/extra/fpl/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/fpl/DESCRIPTION 2012-09-06 20:29:31 UTC (rev 10967) +++ trunk/octave-forge/extra/fpl/DESCRIPTION 2012-09-07 08:55:50 UTC (rev 10968) @@ -1,11 +1,11 @@ Name: fpl -Version: 1.3.1 -Date: 2012-08-10 +Version: 1.3.2 +Date: 2012-09-07 Author: Carlo de Falco, Massimiliano Culpo and others Maintainer: Carlo de Falco, Massimiliano Culpo Title: Fem PLotting Description: Collection of routines to export data produced by Finite Elements or Finite Volume Simulations in formats used by some visualization programs. Categories: Graphics -Depends: octave ( >= 3.4.2 ) +Depends: octave ( >= 3.2.3 ) License: GPLv3+ Modified: trunk/octave-forge/extra/fpl/NEWS =================================================================== --- trunk/octave-forge/extra/fpl/NEWS 2012-09-06 20:29:31 UTC (rev 10967) +++ trunk/octave-forge/extra/fpl/NEWS 2012-09-07 08:55:50 UTC (rev 10968) @@ -1,3 +1,9 @@ +Summary of important user-visible changes for fpl 1.3.2: +------------------------------------------------------------------- + + * raw/base64 vtk exporters have been rewritten in a more backward-compatible + way. This should also make fpl easier to install. + Summary of important user-visible changes for fpl 1.3.1: ------------------------------------------------------------------- Modified: trunk/octave-forge/extra/fpl/inst/fpl_vtk_b64_write_field.m =================================================================== --- trunk/octave-forge/extra/fpl/inst/fpl_vtk_b64_write_field.m 2012-09-06 20:29:31 UTC (rev 10967) +++ trunk/octave-forge/extra/fpl/inst/fpl_vtk_b64_write_field.m 2012-09-07 08:55:50 UTC (rev 10968) @@ -156,8 +156,8 @@ ## VTK-Points (mesh nodes) fprintf (fid, " <Points>\n"); fprintf (fid, " <DataArray type=""Float64"" Name=""Array"" NumberOfComponents=""3"" format=""appended"" offset=""%d"" />\n", offset); - newdata = __array_to_uint8__(p)(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast (p, 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); fprintf (fid, " </Points>\n"); @@ -165,20 +165,20 @@ ## VTK-Cells (mesh elements) fprintf (fid, " <Cells>\n"); fprintf (fid, " <DataArray type=""Int32"" Name=""connectivity"" format=""appended"" offset=""%d"" />\n", offset); - newdata = __array_to_uint8__(int32 (t))(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast (int32 (t), 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); fprintf (fid, " <DataArray type=""Int32"" Name=""offsets"" format=""appended"" offset=""%d"" />\n", offset); tmp = (dim+1):(dim+1):((dim+1)*nelems); - newdata = __array_to_uint8__(int32 (tmp))(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast(int32 (tmp), 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); fprintf (fid, " <DataArray type=""UInt8"" Name=""types"" format=""appended"" offset=""%d"" />\n", offset); tmp = eltype*ones(nelems,1); - newdata = __array_to_uint8__(uint8 (tmp))(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast(uint8 (tmp), 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); fprintf (fid, " </Cells>\n"); @@ -204,8 +204,8 @@ endif fprintf (fid, " <DataArray type=""Float64"" Name=""%s"" ", ndataname); fprintf (fid, "NumberOfComponents=""%d"" format=""appended"" offset=""%d"" />\n", ncomp, offset); - newdata = __array_to_uint8__(ndata.')(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast (ndata.', 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); endfor fprintf (fid, " </PointData>\n"); @@ -231,8 +231,8 @@ endif fprintf (fid, " <DataArray type=""Float64"" Name=""%s"" ", cdataname); fprintf (fid, "NumberOfComponents=""%d"" format=""appended"" offset=""%d"" />\n", ncomp, offset); - newdata = __array_to_uint8__(cdata.')(:); - data = [data, base64_encode([__array_to_uint8__(int32 (numel (newdata)))(:); newdata])]; + newdata = typecast(cdata.', 'uint8')(:); + data = [data, base64_encode([typecast(int32 (numel (newdata)), 'uint8')(:); newdata])]; offset = numel (data); endfor fprintf (fid, " </CellData>\n"); Modified: trunk/octave-forge/extra/fpl/inst/fpl_vtk_raw_write_field.m =================================================================== --- trunk/octave-forge/extra/fpl/inst/fpl_vtk_raw_write_field.m 2012-09-06 20:29:31 UTC (rev 10967) +++ trunk/octave-forge/extra/fpl/inst/fpl_vtk_raw_write_field.m 2012-09-07 08:55:50 UTC (rev 10968) @@ -151,8 +151,8 @@ ## VTK-Points (mesh nodes) fprintf (fid, " <Points>\n"); fprintf (fid, " <DataArray type=""Float64"" Name=""Array"" NumberOfComponents=""3"" format=""appended"" offset=""%d"" />\n", offset); - newdata = __array_to_uint8__ (p); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (p, 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); fprintf (fid, " </Points>\n"); @@ -160,20 +160,20 @@ ## VTK-Cells (mesh elements) fprintf (fid, " <Cells>\n"); fprintf (fid, " <DataArray type=""Int32"" Name=""connectivity"" format=""appended"" offset=""%d"" />\n", offset); - newdata = __array_to_uint8__ (int32 (t)); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (int32 (t), 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); fprintf (fid, " <DataArray type=""Int32"" Name=""offsets"" format=""appended"" offset=""%d"" />\n", offset); tmp = (dim+1):(dim+1):((dim+1)*nelems); - newdata = __array_to_uint8__ (int32 (tmp)); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (int32 (tmp), 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); fprintf (fid, " <DataArray type=""UInt8"" Name=""types"" format=""appended"" offset=""%d"" />\n", offset); tmp = eltype*ones(nelems,1); - newdata = __array_to_uint8__ (uint8 (tmp)); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (uint8 (tmp), 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); fprintf (fid, " </Cells>\n"); @@ -199,8 +199,8 @@ endif fprintf (fid, " <DataArray type=""Float64"" Name=""%s"" ", ndataname); fprintf (fid, "NumberOfComponents=""%d"" format=""appended"" offset=""%d"" />\n", ncomp, offset); - newdata = __array_to_uint8__ (ndata.'); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (ndata.', 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); endfor fprintf (fid, " </PointData>\n"); @@ -226,8 +226,8 @@ endif fprintf (fid, " <DataArray type=""Float64"" Name=""%s"" ", cdataname); fprintf (fid, "NumberOfComponents=""%d"" format=""appended"" offset=""%d"" />\n", ncomp, offset); - newdata = __array_to_uint8__ (cdata.'); - data = [data, __array_to_uint8__(int32 (numel (newdata))), newdata]; + newdata = typecast (cdata.', 'uint8')(:); + data = [data; typecast(int32 (numel (newdata)), 'uint8')(:); newdata]; offset = numel (data); endfor fprintf (fid, " </CellData>\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cde...@us...> - 2012-09-06 20:29:37
|
Revision: 10967 http://octave.svn.sourceforge.net/octave/?rev=10967&view=rev Author: cdemills Date: 2012-09-06 20:29:31 +0000 (Thu, 06 Sep 2012) Log Message: ----------- A few cleanups Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/isempty.m trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/isempty.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/isempty.m 2012-09-05 20:02:40 UTC (rev 10966) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/isempty.m 2012-09-06 20:29:31 UTC (rev 10967) @@ -5,6 +5,6 @@ %# the number of columns, or both are zero). Otherwise, return 0. %# @end deftypefn - resu = any(0 == size(df)); + resu = any (0 == size (df)); endfunction Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m 2012-09-05 20:02:40 UTC (rev 10966) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/permute.m 2012-09-06 20:29:31 UTC (rev 10967) @@ -109,6 +109,7 @@ endif resu._src = df._src; + resu._header = df._header; resu._cmt = df._cmt; endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-09-05 20:02:46
|
Revision: 10966 http://octave.svn.sourceforge.net/octave/?rev=10966&view=rev Author: jordigh Date: 2012-09-05 20:02:40 +0000 (Wed, 05 Sep 2012) Log Message: ----------- Remove zero padding from bwlabeln output Modified Paths: -------------- trunk/octave-forge/main/image/src/bwlabeln.cc trunk/octave-forge/main/image/src/union-find.h++ Modified: trunk/octave-forge/main/image/src/bwlabeln.cc =================================================================== --- trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-05 19:14:14 UTC (rev 10965) +++ trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-05 20:02:40 UTC (rev 10966) @@ -412,14 +412,17 @@ ids_to_label[id] = label; } else - { label = try_label -> second; - } L_vec[*idx] = label; } - rval(0) = L; + // Remove the zero padding... + Array<idx_vector> inner_slice (dim_vector (size_vec.length (), 1)); + for (octave_idx_type i = 0; i < padded_size.length (); i++) + inner_slice(i) = idx_vector (1, padded_size(i) - 1); + + rval(0) = L.index (inner_slice); rval(1) = ids_to_label.size (); return rval; } Modified: trunk/octave-forge/main/image/src/union-find.h++ =================================================================== --- trunk/octave-forge/main/image/src/union-find.h++ 2012-09-05 19:14:14 UTC (rev 10965) +++ trunk/octave-forge/main/image/src/union-find.h++ 2012-09-05 20:02:40 UTC (rev 10966) @@ -71,8 +71,6 @@ voxel *v1 = voxels[root1], *v2 = voxels[root2]; if (root1 != root2) { - - if ( v1->rank > v2->rank) v1->parent = root2; else if (v1->rank < v2->rank) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-09-05 19:14:20
|
Revision: 10965 http://octave.svn.sourceforge.net/octave/?rev=10965&view=rev Author: jordigh Date: 2012-09-05 19:14:14 +0000 (Wed, 05 Sep 2012) Log Message: ----------- Further speedups to bwlabeln Modified Paths: -------------- trunk/octave-forge/main/image/src/Makefile trunk/octave-forge/main/image/src/bwlabeln.cc trunk/octave-forge/main/image/src/union-find.h++ Modified: trunk/octave-forge/main/image/src/Makefile =================================================================== --- trunk/octave-forge/main/image/src/Makefile 2012-09-05 10:21:06 UTC (rev 10964) +++ trunk/octave-forge/main/image/src/Makefile 2012-09-05 19:14:14 UTC (rev 10965) @@ -5,7 +5,7 @@ %.oct: %.cc mkoctfile -Wall $< -bwlabeln.oct: bwlabeln.cc +bwlabeln.oct: bwlabeln.cc union-find.h++ CXXFLAGS='-g -O2 -std=c++0x -Wall' mkoctfile $< clean: Modified: trunk/octave-forge/main/image/src/bwlabeln.cc =================================================================== --- trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-05 10:21:06 UTC (rev 10964) +++ trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-05 19:14:14 UTC (rev 10965) @@ -18,6 +18,7 @@ #include <oct.h> #include <set> #include "union-find.h++" +#include <unordered_map> typedef Array<octave_idx_type> coord; @@ -295,8 +296,6 @@ { octave_value_list rval; - union_find<octave_idx_type> u_f; - octave_idx_type nargin = args.length (); if (nargin < 1 || nargin > 2) @@ -373,6 +372,7 @@ L.insert(BW, coord (dim_vector (size_vec.length (), 1), 1)); double* L_vec = L.fortran_vec (); + union_find u_f (L.nelem ()); for (octave_idx_type BWidx = 0; BWidx < BW.nelem (); BWidx++) { @@ -381,7 +381,7 @@ if (L_vec[Lidx]) { //Insert this one into its group - u_f.find_id(Lidx); + u_f.find (Lidx); //Replace this with C++0x range-based for loop later //(implemented in gcc 4.6) @@ -395,17 +395,16 @@ } - unordered_map<octave_idx_type, octave_idx_type> ids_to_label; + std::unordered_map<octave_idx_type, octave_idx_type> ids_to_label; octave_idx_type next_label = 1; - auto idxs = u_f.get_objects (); + auto idxs = u_f.get_ids (); //C++0x foreach later - for (auto idx = idxs.begin (); idx != idxs.end (); idx++) { octave_idx_type label; - octave_idx_type id = u_f.find_id (idx->first); + octave_idx_type id = u_f.find (*idx); auto try_label = ids_to_label.find (id); if( try_label == ids_to_label.end ()) { @@ -417,7 +416,7 @@ label = try_label -> second; } - L_vec[idx->first] = label; + L_vec[*idx] = label; } rval(0) = L; Modified: trunk/octave-forge/main/image/src/union-find.h++ =================================================================== --- trunk/octave-forge/main/image/src/union-find.h++ 2012-09-05 10:21:06 UTC (rev 10964) +++ trunk/octave-forge/main/image/src/union-find.h++ 2012-09-05 19:14:14 UTC (rev 10965) @@ -15,118 +15,85 @@ // union-find.h++ -#include <unordered_map> -#include <list> +#include <vector> -using std::unordered_map; -using std::list; +struct voxel{ + octave_idx_type rank; + octave_idx_type parent; +}; -// T - type of object we're union-finding for -// H - hash for the map -template <typename T, typename H = std::hash<T> > class union_find { -//Dramatis personae private: + std::vector<voxel*> voxels; - //Each root has rank. - unordered_map<octave_idx_type, octave_idx_type, H> num_ranks; - - //Each object points to its parent, possibly itself. - unordered_map<octave_idx_type, octave_idx_type, H> parent_pointers; - - //Represent each object by a number and vice versa. - unordered_map<octave_idx_type, T, H> num_to_objects; - unordered_map<T, octave_idx_type, H> objects_to_num; - -// Act 1 public: - //Insert a collection of objects - void insert_objects (const list<T>& objects) + union_find (octave_idx_type s) : voxels (s, NULL) {}; + + ~union_find () { - for (auto i = objects.begin (); i != objects.end (); i++) - { - find (*i); - } + for (auto v = voxels.begin(); v != voxels.end(); v++) + delete *v; } - //Give the root representative id for this object, or insert into a //new set if none is found - octave_idx_type find_id (const T& object) + octave_idx_type find (octave_idx_type idx) { //Insert new element if not found - if (objects_to_num.find (object) == objects_to_num.end () ) + auto v = voxels[idx]; + if (!v) { - //Assign number serially to objects - octave_idx_type obj_num = objects_to_num.size ()+1; - - num_ranks[obj_num] = 0; - objects_to_num[object] = obj_num; - num_to_objects[obj_num] = object; - parent_pointers[obj_num] = obj_num; - return obj_num; + voxel* new_voxel = new voxel; + new_voxel->rank = 0; + new_voxel->parent = idx; + voxels[idx] = new_voxel; + return idx; } - //Path from this element to its root, we'll build it. - list<octave_idx_type> path (1, objects_to_num[object]); - octave_idx_type par = parent_pointers[path.back ()]; - while ( par != path.back () ) - { - path.push_back (par); - par = parent_pointers[par]; - } + voxel* elt = v; + if (elt->parent != idx) + elt->parent = find (elt->parent); - //Update everything we've seen to point to the root. - for (auto i = path.begin (); i != path.end (); i++) - { - parent_pointers[*i] = par; - } - - return par; + return elt->parent; } - T find( const T& object) - { - return num_to_objects[find_id (object)]; - } - //Given two objects, unite the sets to which they belong - void unite (const T& obj1, const T& obj2) + void unite (octave_idx_type idx1, octave_idx_type idx2) { - octave_idx_type on1 = find_id(obj1), on2 = find_id(obj2); + octave_idx_type root1 = find (idx1), root2 = find (idx2); //Check if any union needs to be done, maybe they already are //in the same set. - if (on1 != on2) + voxel *v1 = voxels[root1], *v2 = voxels[root2]; + if (root1 != root2) { - octave_idx_type r1 = num_ranks[on1], r2 = num_ranks[on2]; - if ( r1 < r2) - { - parent_pointers[on1] = on2; - num_ranks.erase (on1); //Only root nodes need a rank - } - else if (r2 > r1) - { - parent_pointers[on2] = on1; - num_ranks.erase (on2); - } + + if ( v1->rank > v2->rank) + v1->parent = root2; + else if (v1->rank < v2->rank) + v2->parent = root1; else { - parent_pointers[on2] = on1; - num_ranks.erase (on2); - num_ranks[on1]++; + v2->parent = root1; + v1->rank++; } } } - const unordered_map<T, octave_idx_type, H>& get_objects() + std::vector<octave_idx_type> get_ids() { - return objects_to_num; + std::vector<octave_idx_type> ids; + + for (size_t i = 0; i < voxels.size (); i++) + if (voxels[i]) + ids.push_back (i); + + return ids; }; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cde...@us...> - 2012-09-05 10:21:17
|
Revision: 10964 http://octave.svn.sourceforge.net/octave/?rev=10964&view=rev Author: cdemills Date: 2012-09-05 10:21:06 +0000 (Wed, 05 Sep 2012) Log Message: ----------- Header values now stored in a 'header' field, plus various cleanup Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-09-05 08:41:17 UTC (rev 10963) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/dataframe.m 2012-09-05 10:21:06 UTC (rev 10964) @@ -1,4 +1,4 @@ -function df = dataframe(x = [], varargin) +function df = dataframe(x, varargin) %# -*- texinfo -*- %# @deftypefn {Function File} @var{df} = dataframe(@var{x = []}, ...) @@ -61,14 +61,10 @@ %# if (0 == nargin) - disp ('FIXME -- should create a dataframe from the whole workspace') - df = dataframe ([]); - return -endif - -if (isempty (x) && 1 == nargin) - %# default constructor: initialise the fields in the right order - df._cnt = [0 0]; + %# default constructor: create a scalar struct and initialise the + %# fields in the right order + df = struct ('_cnt', [0 0]); + %# do not call "struct" with the two next args: it would create an array df._name = {cell(0, 1), cell(1, 0)}; %# rows - cols df._over = cell (1, 2); df._ridx = []; @@ -76,24 +72,45 @@ df._rep = cell (0, 0); %# a repetition index df._type = cell (0, 0); %# the type of each column df._src = cell (0, 0); + df._header = cell (0, 0); df._cmt = cell (0, 0); %# to put comments df = class (df, 'dataframe'); return endif +if (isnull (x) && 1 == nargin) + disp ('FIXME -- should create a dataframe from the whole workspace') + df = dataframe (); %# just call the default constructor + return +endif + if (isa (x, 'dataframe')) + %# Try to append whatever data or metadata given through varargin + %# into this dataframe df = x; -elseif (isa (x, 'struct')) - df = class (x, 'dataframe'); return else - df = dataframe ([]); %# get the right fields + df = dataframe (); %# get the right fields + if (isa (x, 'struct')) + %# only accept a struct if it has the same fieldnames as a dataframe + dummy = fieldnames (x); + indi = fieldnames (df); + if (size (dummy, 1) ~= size (indi, 1)) + error ('First argument of dataframe is a struct with the wrong number of fields'); + endif + if (~all (cellfun (@strcmp, dummy, indi))) + error ('First argument of dataframe is a struct with wrong field names'); + endif + %# easy way to transform a struct into a dataframe object + df = class (x, 'dataframe'); + if (1 == nargin) return; endif + endif endif %# default values seeked = []; trigger = []; unquot = true; sep = "\t,"; cmt_lines = []; locales = "C"; datefmt = ''; -if (length (varargin) > 0) +if (length (varargin) > 0) %# extract known arguments indi = 1; %# loop over possible arguments while (indi <= size (varargin, 2)) @@ -149,7 +166,11 @@ case 'datefmt' datefmt = varargin{indi + 1}; varargin(indi:indi+1) = []; - otherwise %# FIXME: just skip it for now + case '--' + %# stop processing args -- take the rest as filenames + varargin(indi) = []; + break; + otherwise %# FIXME: just skip it for now disp (sprintf ("Ignoring unkown argument %s", varargin{indi})); indi = indi + 1; endswitch @@ -181,16 +202,15 @@ indi = indi + 1; if (~isa (x, 'dataframe')) if (isa (x, 'char') && size (x, 1) < 2) - %# read the data frame from a file + dummy = tilde_expand (x); try - dummy = tilde_expand (x); + %# read the data frame from a file x = load (dummy); df._src{end+1, 1} = dummy; catch %# try our own method UTF8_BOM = char ([0xEF 0xBB 0xBF]); unwind_protect - dummy = tilde_expand (x); fid = fopen (dummy); if (fid ~= -1) df._src{end+1, 1} = dummy; @@ -244,9 +264,14 @@ continue; endif dummy = content{indl}; - if (strcmp (dummy{1}, seeked)) + if (~isempty (regexp (dummy{1}, seeked, 'match'))) break; - endif + endif + if (isempty (df._header)) + df._header = dummy; + else + df._header(end+1, 1:length (dummy)) = dummy; + endif indl = indl + 1; endwhile elseif (~isempty (trigger)) @@ -256,7 +281,12 @@ if (all (cellfun ('size', dummy, 2) == 0)) continue; endif - if (size (dummy, 2) >= 1 && ... + if (isempty (df._header)) + df._header = dummy; + else + df._header(end+1, 1:length (dummy)) = dummy; + endif + if (size (dummy, 2) >= 1 && ... ~isempty (regexp (dummy{1}, trigger, 'match'))) break; endif @@ -430,7 +460,11 @@ %# use direct assignement if (ndims (x) > 2), idx.subs{3} = 1:size (x, 3); endif %# df = subsasgn(df, idx, x); <= call directly lower level - df = df_matassign (df, idx, indj, length (indj), x); + try + df = df_matassign (df, idx, indj, length (indj), x); + catch + disp ('line 443 '); keyboard + end_try_catch if (~isempty (cmt_lines)) df._cmt = vertcat (df._cmt, cellstr (cmt_lines)); cmt_lines = []; Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2012-09-05 08:41:17 UTC (rev 10963) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2012-09-05 10:21:06 UTC (rev 10964) @@ -117,6 +117,14 @@ endif return + case "header" + if (length (S) > 1) + df._header = feval (@subsasgn, df._header, S(2:end), RHS); + else + df._header = RHS; + endif + return + case "comment" if (length (S) > 1) df._cmt = feval (@subsasgn, df._cmt, S(2:end), RHS); Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2012-09-05 08:41:17 UTC (rev 10963) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsref.m 2012-09-05 10:21:06 UTC (rev 10964) @@ -124,6 +124,9 @@ case "source" S(1).subs = "_src"; further_deref = true; + case "header" + S(1).subs = "_header"; + further_deref = true; case "comment" S(1).subs = "_cmt"; further_deref = true; @@ -431,6 +434,7 @@ endif %# to be verified : keyboard resu._src = df._src; + resu._header = df._header; resu._cmt = df._cmt; resu = df_thirddim (resu); if (length (S) > 1) %# perform further access, if required This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <raf...@us...> - 2012-09-05 08:41:26
|
Revision: 10963 http://octave.svn.sourceforge.net/octave/?rev=10963&view=rev Author: rafavzqz Date: 2012-09-05 08:41:17 +0000 (Wed, 05 Sep 2012) Log Message: ----------- Small changes Modified Paths: -------------- trunk/octave-forge/extra/nurbs/inst/nrbexport.m trunk/octave-forge/extra/nurbs/inst/nrbkntplot.m trunk/octave-forge/extra/nurbs/src/tbasisfun.cc Modified: trunk/octave-forge/extra/nurbs/inst/nrbexport.m =================================================================== --- trunk/octave-forge/extra/nurbs/inst/nrbexport.m 2012-09-04 21:29:27 UTC (rev 10962) +++ trunk/octave-forge/extra/nurbs/inst/nrbexport.m 2012-09-05 08:41:17 UTC (rev 10963) @@ -45,14 +45,14 @@ fprintf (fid, '%s\n', ['# ' date]); fprintf (fid, '%s\n', '#'); -fprintf (fid, '%2i', ndim, npatch); +fprintf (fid, '%4i', ndim, npatch); fprintf (fid, '\n'); for iptc = 1:npatch fprintf (fid, '%s %i', 'PATCH', iptc); fprintf (fid, '\n'); - fprintf (fid, '%2i', nurbs(iptc).order-1); + fprintf (fid, '%4i', nurbs(iptc).order-1); fprintf (fid, '\n'); - fprintf (fid, '%2i', nurbs(iptc).number); + fprintf (fid, '%4i', nurbs(iptc).number); fprintf (fid, '\n'); for ii = 1:ndim fprintf (fid, '%1.7f ', nurbs(iptc).knots{ii}); Modified: trunk/octave-forge/extra/nurbs/inst/nrbkntplot.m =================================================================== --- trunk/octave-forge/extra/nurbs/inst/nrbkntplot.m 2012-09-04 21:29:27 UTC (rev 10962) +++ trunk/octave-forge/extra/nurbs/inst/nrbkntplot.m 2012-09-05 08:41:17 UTC (rev 10963) @@ -80,8 +80,6 @@ elseif (size (nurbs.knots,2) == 3) % plot a NURBS volume - nsub = 100; - % Plot the boundaries bnd = nrbextract (nurbs); nrbkntplot (bnd(1)); Modified: trunk/octave-forge/extra/nurbs/src/tbasisfun.cc =================================================================== --- trunk/octave-forge/extra/nurbs/src/tbasisfun.cc 2012-09-04 21:29:27 UTC (rev 10962) +++ trunk/octave-forge/extra/nurbs/src/tbasisfun.cc 2012-09-05 08:41:17 UTC (rev 10963) @@ -93,33 +93,31 @@ void onebasisfunder__ (double u, octave_idx_type p, RowVector U, double *N, double *Nder) { double aux; - *N = 0.0; *Nder = 0.0; - if ((u <= U.min ()) || ( u > U.max ())) + *N = 0.0; *Nder = 0.0; + if ((u <= U.min ()) || ( u > U.max ())) return; - - else if (p == 0) - { - *N = 1.0; - *Nder = 0.0; + else if (p == 0) + { + *N = 1.0; + *Nder = 0.0; return; - } - - else { - - double ln = u - U(0); - double ld = U(U.length () - 2) - U(0); - - if (ld != 0) + } + else { + double ln = u - U(0); + double ld = U(U.length () - 2) - U(0); + + if (ld != 0) { onebasisfun__ (u, p-1, U.extract (0, U.length () - 2), &aux); - aux = aux / ld; - *N += ln * aux; - *Nder += p * aux; - } + aux = aux / ld; + *N += ln * aux; + *Nder += p * aux; + } - double dn = U(U.length () - 1) - u; - double dd = U(U.length () - 1) - U(1); - if (dd != 0) + double dn = U(U.length () - 1) - u; + double dd = U(U.length () - 1) - U(1); + + if (dd != 0) { onebasisfun__ (u, p-1, U.extract (1, U.length () - 1), &aux); aux = aux / dd; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-09-04 21:29:33
|
Revision: 10962 http://octave.svn.sourceforge.net/octave/?rev=10962&view=rev Author: jordigh Date: 2012-09-04 21:29:27 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Slight optimisations in bwlabeln.cc (use linear indices consistently) Modified Paths: -------------- trunk/octave-forge/main/image/src/bwlabeln.cc Modified: trunk/octave-forge/main/image/src/bwlabeln.cc =================================================================== --- trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-04 19:08:06 UTC (rev 10961) +++ trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-04 21:29:27 UTC (rev 10962) @@ -32,14 +32,6 @@ return true; } -bool in_range (const coord& a, const dim_vector& size_vec) -{ - for(octave_idx_type i = 0; i < a.nelem (); i++) - if (a(i) < 0 or a(i) >= size_vec(i)) - return false; - return true; -} - //Lexicographic order for coords bool operator< (const coord& a, const coord& b) { @@ -61,31 +53,12 @@ return true; } -struct coord_hash -{ - inline size_t operator() (const coord& c) const - { - size_t seed = 0; - for(octave_idx_type i = 0; i < c.nelem (); i++) - { - //Boost's hash - seed ^= c(i) + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - return seed; - } - - inline size_t operator()(size_t s) const - { - return s; - } -}; - // A few basic utility functions //{ inline coord -to_coord(const dim_vector& dv, - octave_idx_type k) +to_coord (const dim_vector& dv, + octave_idx_type k) { octave_idx_type n = dv.length (); coord retval ( dim_vector (n, 1)); @@ -98,6 +71,21 @@ } inline +octave_idx_type +coord_to_pad_idx (const dim_vector& dv, + const coord& c) +{ + octave_idx_type idx = 0; + octave_idx_type mul = 1; + for (octave_idx_type j = 0; j < dv.length (); j++) + { + idx += mul*c(j); + mul *= dv(j) + 2; + } + return idx; +} + +inline coord operator+ (const coord& a, const coord& b) { @@ -139,28 +127,34 @@ } //} -std::set<coord> -populate_neighbours(const boolNDArray& conn_mask) +std::set<octave_idx_type> +populate_neighbours(const boolNDArray& conn_mask, + const dim_vector& size_vec) { + std::set<octave_idx_type> neighbours_idx; std::set<coord> neighbours; dim_vector conn_size = conn_mask.dims (); - coord centre(dim_vector(conn_size.length (), 1), 1); - coord zero(dim_vector(conn_size.length (), 1), 0); + coord centre (dim_vector(conn_size.length (), 1), 1); + coord zero (dim_vector(conn_size.length (), 1), 0); for (octave_idx_type idx = 0; idx < conn_mask.nelem (); idx++) { if (conn_mask(idx)) { - coord aidx = to_coord(conn_size, idx) - centre; + coord aidx = to_coord (conn_size, idx) - centre; + //The zero coordinates are the centre, and the negative ones //are the ones reflected about the centre, and we don't need //to consider those. if( aidx == zero or neighbours.find(-aidx) != neighbours.end() ) continue; + neighbours.insert (aidx); + + neighbours_idx.insert (coord_to_pad_idx(size_vec, aidx)); } } - return neighbours; + return neighbours_idx; } boolNDArray @@ -265,8 +259,23 @@ return boolNDArray (mask_dims, 1); } -#include <iostream> +octave_idx_type +get_padded_index (octave_idx_type r, + const dim_vector& dv) +{ + octave_idx_type mult = 1; + octave_idx_type padded = 0; + for (octave_idx_type j = 0; j < dv.length (); j++) + { + padded += mult*(r % dv(j) + 1); + mult *= dv(j) + 2; + r /= dv(j); + } + return padded; +} + + DEFUN_DLD(bwlabeln, args, , "\ -*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{l}, @var{num}] =} bwlabeln(@var{bw})\n\ @@ -286,7 +295,7 @@ { octave_value_list rval; - union_find<coord, coord_hash> u_f; + union_find<octave_idx_type> u_f; octave_idx_type nargin = args.length (); @@ -350,40 +359,49 @@ if (error_state) return rval; - using std::set; + auto neighbours = populate_neighbours(conn_mask, size_vec); - set<coord> neighbours = populate_neighbours(conn_mask); + // Use temporary array with borders padded with zeros. Labels will + // also go in here eventually. + dim_vector padded_size = size_vec; + for (octave_idx_type j = 0; j < size_vec.length (); j++) + padded_size(j) += 2; - std::cout << "Union-finding..." << std::endl;; + NDArray L (padded_size, 0); - bool* BW_vec = BW.fortran_vec (); - for (octave_idx_type idx = 0; idx < BW.nelem (); idx++) + // L(2:end-1, 2:end, ..., 2:end-1) = BW + L.insert(BW, coord (dim_vector (size_vec.length (), 1), 1)); + + double* L_vec = L.fortran_vec (); + + for (octave_idx_type BWidx = 0; BWidx < BW.nelem (); BWidx++) { - if (BW_vec[idx]) + octave_idx_type Lidx = get_padded_index (BWidx, size_vec); + + if (L_vec[Lidx]) { - coord aidx = to_coord (size_vec, idx); - //Insert this one into its group - u_f.find_id(aidx); + u_f.find_id(Lidx); //Replace this with C++0x range-based for loop later //(implemented in gcc 4.6) for (auto nbr = neighbours.begin (); nbr != neighbours.end (); nbr++) { - coord n = *nbr + aidx; - if (in_range (n,size_vec) and BW(n) ) - u_f.unite (n,aidx); + octave_idx_type n = *nbr + Lidx; + if (L_vec[n] ) + u_f.unite (n, Lidx); } } } - NDArray L (size_vec, 0); + unordered_map<octave_idx_type, octave_idx_type> ids_to_label; octave_idx_type next_label = 1; auto idxs = u_f.get_objects (); //C++0x foreach later + for (auto idx = idxs.begin (); idx != idxs.end (); idx++) { octave_idx_type label; @@ -399,7 +417,7 @@ label = try_label -> second; } - L(idx->first) = label; + L_vec[idx->first] = label; } rval(0) = L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-04 19:08:12
|
Revision: 10961 http://octave.svn.sourceforge.net/octave/?rev=10961&view=rev Author: prnienhuis Date: 2012-09-04 19:08:06 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Updated text Modified Paths: -------------- trunk/octave-forge/main/io/NEWS Modified: trunk/octave-forge/main/io/NEWS =================================================================== --- trunk/octave-forge/main/io/NEWS 2012-09-04 19:01:14 UTC (rev 10960) +++ trunk/octave-forge/main/io/NEWS 2012-09-04 19:08:06 UTC (rev 10961) @@ -10,7 +10,12 @@ doesn't work with non-existent (new) files on *nix) (bug #36677); Web addresses (URLs) only need two rather than three slashes; --- xlsopen: matching .jar names to javaclasspath entries worked the wrong way +--- io_xls_testscript / io_ods_testscript: added small delay for UNO calls to + avoid lock-ups with recent LibreOffice (3.6.x) +** The annoying flashing LibreOffice splash screens have been fixed upstream; + with LibreOffice 3.6.1 I didn't see them anymore + ** Extended file rename section in odsclose similar to that in xlsclose =============================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-04 19:01:23
|
Revision: 10960 http://octave.svn.sourceforge.net/octave/?rev=10960&view=rev Author: prnienhuis Date: 2012-09-04 19:01:14 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Add a small delay to UNO (LibreOffice/OOo) calls to avoid lockup Modified Paths: -------------- trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m Modified: trunk/octave-forge/main/io/inst/io_ods_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-09-04 09:09:48 UTC (rev 10959) +++ trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-09-04 19:01:14 UTC (rev 10960) @@ -20,10 +20,15 @@ ## Author: Philip Nienhuis ## Created: 2012-02-25 ## Updates: +## 2012-09-04 Add small delay between LibreOffice calls to avoid lock-ups with UNO - printf ("\nTesting .ods interface %s ...\n", intf); +isuno = false; dly = 0.25; +if (strcmp (lower (intf), 'uno')); + isuno = true; +endif + ## 1. Initialize test arrays printf ("\n 1. Initialize arrays.\n"); arr1 = [ 1 2; 3 4.5]; @@ -32,26 +37,26 @@ ## 2. Insert empty sheet printf ("\n 2. Insert first empty sheet.\n"); -odswrite ('io-test.ods', {''}, 'EmptySheet', 'b4', intf); +odswrite ('io-test.ods', {''}, 'EmptySheet', 'b4', intf); if (isuno); sleep (dly); endif ## 3. Add data to test sheet printf ("\n 3. Add data to test sheet.\n"); -odswrite ('io-test.ods', arr1, 'Testsheet', 'c2:d3', intf); -odswrite ('io-test.ods', arr2, 'Testsheet', 'd4:z20', intf); +odswrite ('io-test.ods', arr1, 'Testsheet', 'c2:d3', intf); if (isuno); sleep (dly); endif +odswrite ('io-test.ods', arr2, 'Testsheet', 'd4:z20', intf); if (isuno); sleep (dly); endif ## 4. Insert another sheet printf ("\n 4. Add another sheet with just one number in A1.\n"); -odswrite ('io-test.ods', [1], 'JustOne', 'A1', intf); +odswrite ('io-test.ods', [1], 'JustOne', 'A1', intf); if (isuno); sleep (dly); endif ## 5. Get sheet info & find sheet with data and data range printf ("\n 5. Explore sheet info.\n"); -[~, shts] = odsfinfo ('io-test.ods', intf); +[~, shts] = odsfinfo ('io-test.ods', intf); if (isuno); sleep (dly); endif shnr = strmatch ('Testsheet', shts(:, 1)); # Note case! crange = shts{shnr, 2}; ## 6. Read data back printf ("\n 6. Read data back.\n"); -[num, txt, raw, lims] = odsread ('io-test.ods', shnr, crange, intf); +[num, txt, raw, lims] = odsread ('io-test.ods', shnr, crange, intf); if (isuno); sleep (dly); endif ## 7. Here come the tests, part 1 printf ("\n 7. Tests part 1 (basic I/O):\n"); @@ -92,9 +97,9 @@ ## Check if formulas_as_text works: printf ("\n 8. Repeat reading, now return formulas as text\n"); opts.formulas_as_text = 1; -ods = odsopen ('io-test.ods', 0, intf); -raw = ods2oct (ods, shnr, crange, opts); -ods = odsclose (ods); +ods = odsopen ('io-test.ods', 0, intf); if (isuno); sleep (dly); endif +raw = ods2oct (ods, shnr, crange, opts); if (isuno); sleep (dly); endif +ods = odsclose (ods); if (isuno); sleep (dly); endif clear ods; ## 9. Here come the tests, part 2. Fails on COM Modified: trunk/octave-forge/main/io/inst/io_xls_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-09-04 09:09:48 UTC (rev 10959) +++ trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-09-04 19:01:14 UTC (rev 10960) @@ -21,15 +21,18 @@ ## Created: 2012-02-25 ## Updates: ## 2012-06-06 Adapted to COM implementation for "formulas_as_text" option +## 2012-09-04 Added delay between LibreOffice calls to avoid lockups with UNO printf ("\nTesting .xls interface %s ...\n", intf); -if (strcmp (lower (intf), 'oxs')); +isuno = false; dly = 0.25; +intf2 = intf; +if (strcmp (lower (intf), 'oxs')) printf ("OXS interface has no write support enabled - writing is done with POI.\n"); intf2 = 'com'; -else; - intf2 = intf; +elseif (strcmp (lower (intf), 'uno')); + isuno = true; endif ## 1. Initialize test arrays @@ -40,26 +43,26 @@ ## 2. Insert empty sheet printf ("\n 2. Insert first empty sheet.\n"); -xlswrite ('io-test.xls', {''}, 'EmptySheet', 'b4', intf2); +xlswrite ('io-test.xls', {''}, 'EmptySheet', 'b4', intf2); if (isuno); sleep (dly); endif ## 3. Add data to test sheet printf ("\n 3. Add data to test sheet.\n"); -xlswrite ('io-test.xls', arr1, 'Testsheet', 'c2:d3', intf2); -xlswrite ('io-test.xls', arr2, 'Testsheet', 'd4:z20', intf2); +xlswrite ('io-test.xls', arr1, 'Testsheet', 'c2:d3', intf2); if (isuno); sleep (dly); endif +xlswrite ('io-test.xls', arr2, 'Testsheet', 'd4:z20', intf2); if (isuno); sleep (dly); endif ## 4. Insert another sheet printf ("\n 4. Add another sheet with just one number in A1.\n"); -xlswrite ('io-test.xls', [1], 'JustOne', 'A1', intf2); +xlswrite ('io-test.xls', [1], 'JustOne', 'A1', intf2); if (isuno); sleep (dly); endif ## 5. Get sheet info & find sheet with data and data range printf ("\n 5. Explore sheet info.\n"); -[~, shts] = xlsfinfo ('io-test.xls', intf); +[~, shts] = xlsfinfo ('io-test.xls', intf); if (isuno); sleep (dly); endif shnr = strmatch ('Testsheet', shts(:, 1)); # Note case! crange = shts{shnr, 2}; ## 6. Read data back printf ("\n 6. Read data back.\n"); -[num, txt, raw, lims] = xlsread ('io-test.xls', shnr, crange, intf); +[num, txt, raw, lims] = xlsread ('io-test.xls', shnr, crange, intf); if (isuno); sleep (dly); endif ## 7. Here come the tests, part 1 printf ("\n 7. Tests part 1 (basic I/O):\n"); @@ -97,9 +100,9 @@ ## Check if "formulas_as_text" option works: printf ("\n 8. Repeat reading, now return formulas as text\n"); opts.formulas_as_text = 1; -xls = xlsopen ('io-test.xls', 0, intf); -raw = xls2oct (xls, shnr, crange, opts); -xls = xlsclose (xls); +xls = xlsopen ('io-test.xls', 0, intf); if (isuno); sleep (dly); endif +raw = xls2oct (xls, shnr, crange, opts); if (isuno); sleep (dly); endif +xls = xlsclose (xls); if (isuno); sleep (dly); endif ## 9. Here come the tests, part 2. printf ("\n 9. Tests part 2 (read back formula):\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-04 09:09:58
|
Revision: 10959 http://octave.svn.sourceforge.net/octave/?rev=10959&view=rev Author: paramaniac Date: 2012-09-04 09:09:48 +0000 (Tue, 04 Sep 2012) Log Message: ----------- control: add underscores to slicot functions to emphasize their private nature Modified Paths: -------------- trunk/octave-forge/main/control/devel/bug_minreal.m trunk/octave-forge/main/control/devel/test_ss2tf.m trunk/octave-forge/main/control/devel/test_tf2ss.m trunk/octave-forge/main/control/inst/@lti/c2d.m trunk/octave-forge/main/control/inst/@lti/norm.m trunk/octave-forge/main/control/inst/@lti/prescale.m trunk/octave-forge/main/control/inst/@ss/__c2d__.m trunk/octave-forge/main/control/inst/@ss/__d2c__.m trunk/octave-forge/main/control/inst/@ss/__minreal__.m trunk/octave-forge/main/control/inst/@ss/__prescale__.m trunk/octave-forge/main/control/inst/@ss/__sys2tf__.m trunk/octave-forge/main/control/inst/@ss/__zero__.m trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m trunk/octave-forge/main/control/inst/__conred_sb16ad__.m trunk/octave-forge/main/control/inst/__dss2ss__.m trunk/octave-forge/main/control/inst/__modred_ab09id__.m trunk/octave-forge/main/control/inst/__slicot_identification__.m trunk/octave-forge/main/control/inst/arx.m trunk/octave-forge/main/control/inst/bstmodred.m trunk/octave-forge/main/control/inst/care.m trunk/octave-forge/main/control/inst/cfconred.m trunk/octave-forge/main/control/inst/ctrbf.m trunk/octave-forge/main/control/inst/dare.m trunk/octave-forge/main/control/inst/dlyap.m trunk/octave-forge/main/control/inst/dlyapchol.m trunk/octave-forge/main/control/inst/fitfrd.m trunk/octave-forge/main/control/inst/fwcfconred.m trunk/octave-forge/main/control/inst/h2syn.m trunk/octave-forge/main/control/inst/hinfsyn.m trunk/octave-forge/main/control/inst/hnamodred.m trunk/octave-forge/main/control/inst/hsvd.m trunk/octave-forge/main/control/inst/isctrb.m trunk/octave-forge/main/control/inst/isstabilizable.m trunk/octave-forge/main/control/inst/ltimodels.m trunk/octave-forge/main/control/inst/lyap.m trunk/octave-forge/main/control/inst/lyapchol.m trunk/octave-forge/main/control/inst/ncfsyn.m trunk/octave-forge/main/control/inst/place.m trunk/octave-forge/main/control/src/Makefile trunk/octave-forge/main/control/src/slab01od.cc trunk/octave-forge/main/control/src/slab04md.cc trunk/octave-forge/main/control/src/slab08nd.cc trunk/octave-forge/main/control/src/slab09hd.cc trunk/octave-forge/main/control/src/slab09id.cc trunk/octave-forge/main/control/src/slab09jd.cc trunk/octave-forge/main/control/src/slab13ad.cc trunk/octave-forge/main/control/src/slab13bd.cc trunk/octave-forge/main/control/src/slab13dd.cc trunk/octave-forge/main/control/src/slag08bd.cc trunk/octave-forge/main/control/src/slib01ad.cc trunk/octave-forge/main/control/src/slib01cd.cc trunk/octave-forge/main/control/src/slident.cc trunk/octave-forge/main/control/src/slsb01bd.cc trunk/octave-forge/main/control/src/slsb02od.cc trunk/octave-forge/main/control/src/slsb03md.cc trunk/octave-forge/main/control/src/slsb03od.cc trunk/octave-forge/main/control/src/slsb04md.cc trunk/octave-forge/main/control/src/slsb04qd.cc trunk/octave-forge/main/control/src/slsb10dd.cc trunk/octave-forge/main/control/src/slsb10ed.cc trunk/octave-forge/main/control/src/slsb10fd.cc trunk/octave-forge/main/control/src/slsb10hd.cc trunk/octave-forge/main/control/src/slsb10id.cc trunk/octave-forge/main/control/src/slsb10jd.cc trunk/octave-forge/main/control/src/slsb10kd.cc trunk/octave-forge/main/control/src/slsb10yd.cc trunk/octave-forge/main/control/src/slsb10zd.cc trunk/octave-forge/main/control/src/slsb16ad.cc trunk/octave-forge/main/control/src/slsb16bd.cc trunk/octave-forge/main/control/src/slsb16cd.cc trunk/octave-forge/main/control/src/slsg02ad.cc trunk/octave-forge/main/control/src/slsg03ad.cc trunk/octave-forge/main/control/src/slsg03bd.cc trunk/octave-forge/main/control/src/sltb01id.cc trunk/octave-forge/main/control/src/sltb01pd.cc trunk/octave-forge/main/control/src/sltb01ud.cc trunk/octave-forge/main/control/src/sltb04bd.cc trunk/octave-forge/main/control/src/sltd04ad.cc trunk/octave-forge/main/control/src/sltg01ad.cc trunk/octave-forge/main/control/src/sltg01hd.cc trunk/octave-forge/main/control/src/sltg01id.cc trunk/octave-forge/main/control/src/sltg01jd.cc trunk/octave-forge/main/control/src/sltg04bx.cc Added Paths: ----------- trunk/octave-forge/main/control/src/__control_slicot_functions__.cc Removed Paths: ------------- trunk/octave-forge/main/control/src/control_slicot_functions.cc Modified: trunk/octave-forge/main/control/devel/bug_minreal.m =================================================================== --- trunk/octave-forge/main/control/devel/bug_minreal.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/devel/bug_minreal.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -4,7 +4,7 @@ %{ ** On entry to TG01JD parameter number 20 had an illegal value -error: sltg01jd: exception encountered in Fortran subroutine tg01jd_ +error: __sl_tg01jd__: exception encountered in Fortran subroutine tg01jd_ error: called from: error: /Users/lukas/control/inst/@ss/__minreal__.m at line 39, column 19 error: /Users/lukas/control/inst/@lti/minreal.m at line 38, column 7 Modified: trunk/octave-forge/main/control/devel/test_ss2tf.m =================================================================== --- trunk/octave-forge/main/control/devel/test_ss2tf.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/devel/test_ss2tf.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -14,7 +14,7 @@ [p, m] = size (d); md = 4 -[gn, gd, ign, igd] = sltb04bd (a, b, c, d) +[gn, gd, ign, igd] = __sl_tb04bd__ (a, b, c, d) num = reshape (gn, md, p, m) den = reshape (gd, md, p, m) @@ -53,7 +53,7 @@ %num = gn(1:ign+1) %den = gd(1:igd+1) %{ -[gn, gd, ign, igd] = sltb04bd (-2, 3, 4, 5) +[gn, gd, ign, igd] = __sl_tb04bd__ (-2, 3, 4, 5) % for i = 1 : size (gn, 1) @@ -68,16 +68,16 @@ S = ss (P); -[num, den, ign, igd] = sltb04bd (S.a, S.b, S.c, S.d) +[num, den, ign, igd] = __sl_tb04bd__ (S.a, S.b, S.c, S.d) P -[num, den, ign, igd] = sltb04bd (0, 1, 1, 0) +[num, den, ign, igd] = __sl_tb04bd__ (0, 1, 1, 0) sys = WestlandLynx; -[num, den, ign, igd] = sltb04bd (sys.a, sys.b, sys.c, sys.d); +[num, den, ign, igd] = __sl_tb04bd__ (sys.a, sys.b, sys.c, sys.d); %} Modified: trunk/octave-forge/main/control/devel/test_tf2ss.m =================================================================== --- trunk/octave-forge/main/control/devel/test_tf2ss.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/devel/test_tf2ss.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -15,5 +15,5 @@ ucoeff(2,1,:) = u21; ucoeff(2,2,:) = u22; -[a, b, c, d] = sltd04ad (ucoeff, dcoeff, index, 0) +[a, b, c, d] = __sl_td04ad__ (ucoeff, dcoeff, index, 0) Modified: trunk/octave-forge/main/control/inst/@lti/c2d.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/c2d.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@lti/c2d.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -98,7 +98,7 @@ %! D = [ 1.0 0.0 %! 0.0 -1.0 ].'; %! -%! [Ao, Bo, Co, Do] = slab04md (A, B, C, D, 1.0, 1.0, false); +%! [Ao, Bo, Co, Do] = __sl_ab04md__ (A, B, C, D, 1.0, 1.0, false); %! %! Ae = [ -1.0000 -4.0000 %! -4.0000 -1.0000 ]; Modified: trunk/octave-forge/main/control/inst/@lti/norm.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/norm.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@lti/norm.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -72,7 +72,7 @@ if (! discrete && any (d(:))) # continuous and non-zero feedthrough gain = inf; else - gain = slab13bd (a, b, c, d, discrete); + gain = __sl_ab13bd__ (a, b, c, d, discrete); endif else gain = inf; @@ -88,14 +88,14 @@ tol = max (tol, 100*eps); if (isempty (e)) - [fpeak, gpeak] = slab13dd (a, a, b, c, d, discrete, false, tol, scaled); # TODO: avoid dummy argument + [fpeak, gpeak] = __sl_ab13dd__ (a, a, b, c, d, discrete, false, tol, scaled); # TODO: avoid dummy argument else if (rcond (e) < eps) gain = inf; wpeak = inf; return; else - [fpeak, gpeak] = slab13dd (a, e, b, c, d, discrete, true, tol, scaled); + [fpeak, gpeak] = __sl_ab13dd__ (a, e, b, c, d, discrete, true, tol, scaled); endif endif Modified: trunk/octave-forge/main/control/inst/@lti/prescale.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/prescale.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@lti/prescale.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -103,7 +103,7 @@ %! %! MAXRED = 0.0; %! -%! [Ao, Bo, Co, MAXREDo, SCALEo] = sltb01id (A, B, C, MAXRED); +%! [Ao, Bo, Co, MAXREDo, SCALEo] = __sl_tb01id__ (A, B, C, MAXRED); %! %! Ae = [ 0.0000000D+00 0.1000000D+05 0.0000000D+00 0.0000000D+00 0.0000000D+00 %! -0.1580000D+03 -0.1257000D+04 0.0000000D+00 0.0000000D+00 0.0000000D+00 @@ -156,7 +156,7 @@ %! %! TRESH = 0.0; %! -%! [Ao, Eo, Bo, Co, LSCALEo, RSCALEo] = sltg01ad (A, E, B, C, TRESH); +%! [Ao, Eo, Bo, Co, LSCALEo, RSCALEo] = __sl_tg01ad__ (A, E, B, C, TRESH); %! %! Ae = [ -1.0000 0.0000 0.0000 0.3000 %! 0.0000 0.0000 1.0000 2.0000 Modified: trunk/octave-forge/main/control/inst/@ss/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -40,7 +40,7 @@ beta = 2/tsam; endif if (isempty (sys.e)) - [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, beta, false); + [sys.a, sys.b, sys.c, sys.d] = __sl_ab04md__ (sys.a, sys.b, sys.c, sys.d, 1, beta, false); else [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss_bilin__ (sys.a, sys.b, sys.c, sys.d, sys.e, beta, false); endif Modified: trunk/octave-forge/main/control/inst/@ss/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -42,7 +42,7 @@ beta = 2/tsam; endif if (isempty (sys.e)) - [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, beta, true); + [sys.a, sys.b, sys.c, sys.d] = __sl_ab04md__ (sys.a, sys.b, sys.c, sys.d, 1, beta, true); else [sys.a, sys.b, sys.c, sys.d, sys.e] = __dss_bilin__ (sys.a, sys.b, sys.c, sys.d, sys.e, beta, true); endif Modified: trunk/octave-forge/main/control/inst/@ss/__minreal__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__minreal__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__minreal__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -33,10 +33,10 @@ endif if (isempty (sys.e)) - [a, b, c] = sltb01pd (sys.a, sys.b, sys.c, tol, sys.scaled); + [a, b, c] = __sl_tb01pd__ (sys.a, sys.b, sys.c, tol, sys.scaled); retsys = ss (a, b, c, sys.d); else - [a, e, b, c] = sltg01jd (sys.a, sys.e, sys.b, sys.c, tol, sys.scaled, 0, 0); + [a, e, b, c] = __sl_tg01jd__ (sys.a, sys.e, sys.b, sys.c, tol, sys.scaled, 0, 0); retsys = dss (a, b, c, sys.d, e); endif Modified: trunk/octave-forge/main/control/inst/@ss/__prescale__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__prescale__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__prescale__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -27,12 +27,12 @@ function [retsys, lscale, rscale] = __prescale__ (sys, optarg = 0.0) if (isempty (sys.e)) - [a, b, c, ~, scale] = sltb01id (sys.a, sys.b, sys.c, optarg); + [a, b, c, ~, scale] = __sl_tb01id__ (sys.a, sys.b, sys.c, optarg); retsys = ss (a, b, c, sys.d); lscale = scale.^-1; rscale = scale; else - [a, e, b, c, lscale, rscale] = sltg01ad (sys.a, sys.e, sys.b, sys.c, optarg); + [a, e, b, c, lscale, rscale] = __sl_tg01ad__ (sys.a, sys.e, sys.b, sys.c, optarg); retsys = dss (a, b, c, sys.d, e); endif Modified: trunk/octave-forge/main/control/inst/@ss/__sys2tf__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys2tf__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__sys2tf__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -27,7 +27,7 @@ try [a, b, c, d, tsam, scaled] = ssdata (sys); # system could be a descriptor model - [num, den, ign, igd, md, p, m] = sltb04bd (a, b, c, d, scaled); + [num, den, ign, igd, md, p, m] = __sl_tb04bd__ (a, b, c, d, scaled); num = reshape (num, md, p, m); den = reshape (den, md, p, m); Modified: trunk/octave-forge/main/control/inst/@ss/__zero__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__zero__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@ss/__zero__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -27,12 +27,12 @@ function [zer, gain] = __zero__ (sys, argc) if (isempty (sys.e)) - [zer, gain] = slab08nd (sys.a, sys.b, sys.c, sys.d, sys.scaled); + [zer, gain] = __sl_ab08nd__ (sys.a, sys.b, sys.c, sys.d, sys.scaled); else - zer = slag08bd (sys.a, sys.e, sys.b, sys.c, sys.d, sys.scaled); + zer = __sl_ag08bd__ (sys.a, sys.e, sys.b, sys.c, sys.d, sys.scaled); if (argc > 1 && issiso (sys)) pol = pole (sys); - gain = sltg04bx (sys.a, sys.e, sys.b, sys.c, sys.d, \ + gain = __sl_tg04bx__ (sys.a, sys.e, sys.b, sys.c, sys.d, \ real (pol), imag (pol), real (zer), imag (zer)); else gain = []; Modified: trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -123,7 +123,7 @@ endfor tol = min (sqrt (eps), eps*prod (index)); - [a, b, c, d] = sltd04ad (ucoeff, dcoeff, index, tol); + [a, b, c, d] = __sl_td04ad__ (ucoeff, dcoeff, index, tol); endfunction @@ -144,7 +144,7 @@ c2 = horzcat (zeros (p, p*(max_len_numq-1)), -eye (p)); ## remove uncontrollable part - [a2, e2, b2, c2] = sltg01jd (a2, e2, b2, c2, 0.0, true, 1, 2); + [a2, e2, b2, c2] = __sl_tg01jd__ (a2, e2, b2, c2, 0.0, true, 1, 2); endfunction Modified: trunk/octave-forge/main/control/inst/__conred_sb16ad__.m =================================================================== --- trunk/octave-forge/main/control/inst/__conred_sb16ad__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/__conred_sb16ad__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -169,9 +169,9 @@ ## perform model order reduction - [acr, bcr, ccr, dcr, ncr, hsvc, ncs] = slsb16ad (a, b, c, d, dt, equil, ncr, ordsel, alpha, jobmr, \ - ac, bc, cc, dc, \ - weight, jobc, jobo, tol1, tol2); + [acr, bcr, ccr, dcr, ncr, hsvc, ncs] = __sl_sb16ad__ (a, b, c, d, dt, equil, ncr, ordsel, alpha, jobmr, \ + ac, bc, cc, dc, \ + weight, jobc, jobo, tol1, tol2); ## assemble reduced order controller Kr = ss (acr, bcr, ccr, dcr, tsamc); Modified: trunk/octave-forge/main/control/inst/__dss2ss__.m =================================================================== --- trunk/octave-forge/main/control/inst/__dss2ss__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/__dss2ss__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -29,7 +29,7 @@ elseif (rcond (e) < eps) # check for singularity error ("ss: dss2ss: descriptor matrice 'e' singular"); else - [a, b, c, d] = slsb10jd (a, b, c, d, e); + [a, b, c, d] = __sl_sb10jd__ (a, b, c, d, e); e = []; endif Modified: trunk/octave-forge/main/control/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/main/control/inst/__modred_ab09id__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/__modred_ab09id__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -159,7 +159,7 @@ ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09id (a, b, c, d, dt, equil, nr, ordsel, alpha, job, \ + [ar, br, cr, dr, nr, hsv, ns] = __sl_ab09id__ (a, b, c, d, dt, equil, nr, ordsel, alpha, job, \ av, bv, cv, dv, \ aw, bw, cw, dw, \ weight, jobc, jobo, alphac, alphao, \ Modified: trunk/octave-forge/main/control/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/main/control/inst/__slicot_identification__.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/__slicot_identification__.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -153,7 +153,7 @@ if (nout == 0) ## compute singular values - [sv, nrec] = slib01ad (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); + [sv, nrec] = __sl_ib01ad__ (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); ## there is no 'logbar' function svl = log10 (sv); @@ -170,7 +170,7 @@ grid on else ## perform system identification - [a, b, c, d, q, ry, s, k, x0] = slident (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); + [a, b, c, d, q, ry, s, k, x0] = __sl_ident__ (dat.y, dat.u, nobr, n, meth, alg, conct, ctrl, rcond, tol); ## compute noise variance matrix factor L ## L L' = Ry, e = L v Modified: trunk/octave-forge/main/control/inst/arx.m =================================================================== --- trunk/octave-forge/main/control/inst/arx.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/arx.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -228,7 +228,7 @@ ## this makes only sense for state-space models, therefore convert TF to SS if (nargout > 1) sys = prescale (ss (sys(:,1:m))); - x0 = slib01cd (Y, U, sys.a, sys.b, sys.c, sys.d, 0.0); + x0 = __sl_ib01cd__ (Y, U, sys.a, sys.b, sys.c, sys.d, 0.0); ## return x0 as vector for single-experiment data ## instead of a cell containing one vector if (numel (x0) == 1) Modified: trunk/octave-forge/main/control/inst/bstmodred.m =================================================================== --- trunk/octave-forge/main/control/inst/bstmodred.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/bstmodred.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -278,7 +278,7 @@ endfor ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09hd (a, b, c, d, dt, scaled, job, nr, ordsel, alpha, beta, \ + [ar, br, cr, dr, nr, hsv, ns] = __sl_ab09hd__ (a, b, c, d, dt, scaled, job, nr, ordsel, alpha, beta, \ tol1, tol2); ## assemble reduced order model Modified: trunk/octave-forge/main/control/inst/care.m =================================================================== --- trunk/octave-forge/main/control/inst/care.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/care.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -159,18 +159,18 @@ ## solve the riccati equation if (isempty (e)) if (isempty (s)) - [x, l] = slsb02od (a, b, q, r, b, false, false); + [x, l] = __sl_sb02od__ (a, b, q, r, b, false, false); g = r \ (b.'*x); # gain matrix else - [x, l] = slsb02od (a, b, q, r, s, false, true); + [x, l] = __sl_sb02od__ (a, b, q, r, s, false, true); g = r \ (b.'*x + s.'); # gain matrix endif else if (isempty (s)) - [x, l] = slsg02ad (a, e, b, q, r, b, false, false); + [x, l] = __sl_sg02ad__ (a, e, b, q, r, b, false, false); g = r \ (b.'*x*e); # gain matrix else - [x, l] = slsg02ad (a, e, b, q, r, s, false, true); + [x, l] = __sl_sg02ad__ (a, e, b, q, r, s, false, true); g = r \ (b.'*x*e + s.'); # gain matrix endif endif Modified: trunk/octave-forge/main/control/inst/cfconred.m =================================================================== --- trunk/octave-forge/main/control/inst/cfconred.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/cfconred.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -260,8 +260,8 @@ endif ## perform model order reduction - [acr, bcr, ccr, dcr, ncr, hsv] = slsb16bd (a, b, c, d, dt, equil, ncr, ordsel, jobd, jobmr, \ - F, L, jobcf, tol1, tol2); + [acr, bcr, ccr, dcr, ncr, hsv] = __sl_sb16bd__ (a, b, c, d, dt, equil, ncr, ordsel, jobd, jobmr, \ + F, L, jobcf, tol1, tol2); ## assemble reduced order controller Kr = ss (acr, bcr, ccr, dcr, tsam); Modified: trunk/octave-forge/main/control/inst/ctrbf.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrbf.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/ctrbf.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -80,7 +80,7 @@ error ("ctrbf: tol must be a real scalar"); endif - [ac, bc, cc, z, ncont] = sltb01ud (a, b, c, tol); + [ac, bc, cc, z, ncont] = __sl_tb01ud__ (a, b, c, tol); if (islti) ac = set (sys, "a", ac, "b", bc, "c", cc, "scaled", false); Modified: trunk/octave-forge/main/control/inst/dare.m =================================================================== --- trunk/octave-forge/main/control/inst/dare.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/dare.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -159,18 +159,18 @@ ## solve the riccati equation if (isempty (e)) if (isempty (s)) - [x, l] = slsb02od (a, b, q, r, b, true, false); + [x, l] = __sl_sb02od__ (a, b, q, r, b, true, false); g = (r + b.'*x*b) \ (b.'*x*a); # gain matrix else - [x, l] = slsb02od (a, b, q, r, s, true, true); + [x, l] = __sl_sb02od__ (a, b, q, r, s, true, true); g = (r + b.'*x*b) \ (b.'*x*a + s.'); # gain matrix endif else if (isempty (s)) - [x, l] = slsg02ad (a, e, b, q, r, b, true, false); + [x, l] = __sl_sg02ad__ (a, e, b, q, r, b, true, false); g = (r + b.'*x*b) \ (b.'*x*a); # gain matrix else - [x, l] = slsg02ad (a, e, b, q, r, s, true, true); + [x, l] = __sl_sg02ad__ (a, e, b, q, r, s, true, true); g = (r + b.'*x*b) \ (b.'*x*a + s.'); # gain matrix endif endif Modified: trunk/octave-forge/main/control/inst/dlyap.m =================================================================== --- trunk/octave-forge/main/control/inst/dlyap.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/dlyap.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -62,7 +62,7 @@ inputname (1), inputname (2)); endif - [x, scale] = slsb03md (a, -b, true); # AXA' - X = -B + [x, scale] = __sl_sb03md__ (a, -b, true); # AXA' - X = -B ## x /= scale; # 0 < scale <= 1 @@ -80,7 +80,7 @@ rows (a), columns (b), inputname (3)); endif - x = slsb04qd (-a, b, c); # AXB' - X = -C + x = __sl_sb04qd__ (-a, b, c); # AXB' - X = -C case 4 # generalized Lyapunov equation @@ -106,7 +106,7 @@ inputname (2)); endif - [x, scale] = slsg03ad (a, e, -b, true); # AXA' - EXE' = -B + [x, scale] = __sl_sg03ad__ (a, e, -b, true); # AXA' - EXE' = -B ## x /= scale; # 0 < scale <= 1 Modified: trunk/octave-forge/main/control/inst/dlyapchol.m =================================================================== --- trunk/octave-forge/main/control/inst/dlyapchol.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/dlyapchol.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -63,7 +63,7 @@ inputname (1), inputname (2)); endif - [u, scale] = slsb03od (a.', b.', true); + [u, scale] = __sl_sb03od__ (a.', b.', true); ## NOTE: TRANS = 'T' not suitable because we need U' U, not U U' @@ -87,7 +87,7 @@ inputname (1), inputname (2), inputname (3)); endif - [u, scale] = slsg03bd (a.', e.', b.', true); + [u, scale] = __sl_sg03bd__ (a.', e.', b.', true); ## NOTE: TRANS = 'T' not suitable because we need U' U, not U U' Modified: trunk/octave-forge/main/control/inst/fitfrd.m =================================================================== --- trunk/octave-forge/main/control/inst/fitfrd.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/fitfrd.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -81,7 +81,7 @@ error ("fitfrd: require n <= length (dat.w)"); endif - [a, b, c, d, n] = slsb10yd (real (H), imag (H), w, n, dt, logical (flag)); + [a, b, c, d, n] = __sl_sb10yd__ (real (H), imag (H), w, n, dt, logical (flag)); sys = ss (a, b, c, d, tsam); Modified: trunk/octave-forge/main/control/inst/fwcfconred.m =================================================================== --- trunk/octave-forge/main/control/inst/fwcfconred.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/fwcfconred.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -225,8 +225,8 @@ endif ## perform model order reduction - [acr, bcr, ccr, ncr, hsv] = slsb16cd (a, b, c, d, dt, ncr, ordsel, jobd, jobmr, \ - F, L, jobcf, tol1); + [acr, bcr, ccr, ncr, hsv] = __sl_sb16cd__ (a, b, c, d, dt, ncr, ordsel, jobd, jobmr, \ + F, L, jobcf, tol1); ## assemble reduced order controller Kr = ss (acr, bcr, ccr, [], tsam); Modified: trunk/octave-forge/main/control/inst/h2syn.m =================================================================== --- trunk/octave-forge/main/control/inst/h2syn.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/h2syn.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -129,9 +129,9 @@ ## H-2 synthesis if (isct (P)) # continuous plant - [ak, bk, ck, dk, rcond] = slsb10hd (a, b, c, d, ncon, nmeas); + [ak, bk, ck, dk, rcond] = __sl_sb10hd__ (a, b, c, d, ncon, nmeas); else # discrete plant - [ak, bk, ck, dk, rcond] = slsb10ed (a, b, c, d, ncon, nmeas); + [ak, bk, ck, dk, rcond] = __sl_sb10ed__ (a, b, c, d, ncon, nmeas); endif ## controller Modified: trunk/octave-forge/main/control/inst/hinfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/hinfsyn.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/hinfsyn.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -132,9 +132,9 @@ ## H-infinity synthesis if (isct (P)) # continuous plant - [ak, bk, ck, dk, rcond] = slsb10fd (a, b, c, d, ncon, nmeas, gmax); + [ak, bk, ck, dk, rcond] = __sl_sb10fd__ (a, b, c, d, ncon, nmeas, gmax); else # discrete plant - [ak, bk, ck, dk, rcond] = slsb10dd (a, b, c, d, ncon, nmeas, gmax); + [ak, bk, ck, dk, rcond] = __sl_sb10dd__ (a, b, c, d, ncon, nmeas, gmax); endif ## controller Modified: trunk/octave-forge/main/control/inst/hnamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/hnamodred.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/hnamodred.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -394,7 +394,7 @@ ## perform model order reduction - [ar, br, cr, dr, nr, hsv, ns] = slab09jd (a, b, c, d, dt, scaled, nr, ordsel, alpha, \ + [ar, br, cr, dr, nr, hsv, ns] = __sl_ab09jd__ (a, b, c, d, dt, scaled, nr, ordsel, alpha, \ jobv, av, bv, cv, dv, \ jobw, aw, bw, cw, dw, \ jobinv, tol1, tol2); Modified: trunk/octave-forge/main/control/inst/hsvd.m =================================================================== --- trunk/octave-forge/main/control/inst/hsvd.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/hsvd.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -62,7 +62,7 @@ error ("hsvd: second argument invalid"); endswitch - [hsv, ns] = slab13ad (a, b, c, discrete, alpha, scaled); + [hsv, ns] = __sl_ab13ad__ (a, b, c, discrete, alpha, scaled); if (nargout) hsv_r = hsv; Modified: trunk/octave-forge/main/control/inst/isctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/isctrb.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/isctrb.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -89,9 +89,9 @@ endif if (isempty (e)) - [~, ~, ~, ncont] = slab01od (a, b, tol); + [~, ~, ~, ncont] = __sl_ab01od__ (a, b, tol); else - [~, ~, ~, ~, ~, ~, ncont] = sltg01hd (a, e, b, zeros (1, columns (a)), tol); + [~, ~, ~, ~, ~, ~, ncont] = __sl_tg01hd__ (a, e, b, zeros (1, columns (a)), tol); endif bool = (ncont == rows (a)); Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -103,7 +103,7 @@ if (isempty (e)) ## controllability staircase form - [ac, ~, ~, ncont] = slab01od (a, b, tol); + [ac, ~, ~, ncont] = __sl_ab01od__ (a, b, tol); ## extract uncontrollable part of staircase form uncont_idx = ncont+1 : rows (a); @@ -113,7 +113,7 @@ pol = eig (auncont); else ## controllability staircase form - output matrix c has no influence - [ac, ec, ~, ~, ~, ~, ncont] = sltg01hd (a, e, b, zeros (1, columns (a)), tol); + [ac, ec, ~, ~, ~, ~, ncont] = __sl_tg01hd__ (a, e, b, zeros (1, columns (a)), tol); ## extract uncontrollable part of staircase form uncont_idx = ncont+1 : rows (a); Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -128,7 +128,7 @@ %! A = A.'; # There's a little mistake in the example %! # program of routine AB01OD in SLICOT 5.0 %! -%! [Ac, Bc, U, ncont] = slab01od (A, B, tol); +%! [Ac, Bc, U, ncont] = __sl_ab01od__ (A, B, tol); %! %! Ace = [ 12.8848 3.2345 11.8211 3.3758 -0.8982 %! 4.4741 -12.5544 5.3509 5.9403 1.4360 @@ -178,7 +178,7 @@ %! %! tol = 0; %! -%! [ac, ec, bc, cc, q, z, ncont] = sltg01hd (a, e, b, c, tol); +%! [ac, ec, bc, cc, q, z, ncont] = __sl_tg01hd__ (a, e, b, c, tol); %! %! ncont_e = 3; %! @@ -267,7 +267,7 @@ %! %! tol = 0; %! -%! [ao, eo, bo, co, q, z, nobsv] = sltg01id (a, e, b, c, tol); +%! [ao, eo, bo, co, q, z, nobsv] = __sl_tg01id__ (a, e, b, c, tol); %! %! nobsv_e = 3; %! @@ -391,7 +391,7 @@ %! UCOEFF(2,1,:) = u21; %! UCOEFF(2,2,:) = u22; %! -%! [Ao, Bo, Co, Do] = sltd04ad (UCOEFF, DCOEFF, INDEX, 0); +%! [Ao, Bo, Co, Do] = __sl_td04ad__ (UCOEFF, DCOEFF, INDEX, 0); %! %! Ae = [ 0.5000 -0.8028 0.9387 %! 4.4047 -2.3380 2.5076 Modified: trunk/octave-forge/main/control/inst/lyap.m =================================================================== --- trunk/octave-forge/main/control/inst/lyap.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/lyap.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -63,7 +63,7 @@ endif - [x, scale] = slsb03md (a, -b, false); # AX + XA' = -B + [x, scale] = __sl_sb03md__ (a, -b, false); # AX + XA' = -B ## x /= scale; # 0 < scale <= 1 @@ -81,7 +81,7 @@ rows (a), columns (b), inputname (3)); endif - x = slsb04md (a, b, -c); # AX + XB = -C + x = __sl_sb04md__ (a, b, -c); # AX + XB = -C case 4 # generalized Lyapunov equation @@ -107,7 +107,7 @@ inputname (2)); endif - [x, scale] = slsg03ad (a, e, -b, false); # AXE' + EXA' = -B + [x, scale] = __sl_sg03ad__ (a, e, -b, false); # AXE' + EXA' = -B ## x /= scale; # 0 < scale <= 1 Modified: trunk/octave-forge/main/control/inst/lyapchol.m =================================================================== --- trunk/octave-forge/main/control/inst/lyapchol.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/lyapchol.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -63,7 +63,7 @@ inputname (1), inputname (2)); endif - [u, scale] = slsb03od (a.', b.', false); + [u, scale] = __sl_sb03od__ (a.', b.', false); ## NOTE: TRANS = 'T' not suitable because we need U' U, not U U' @@ -87,7 +87,7 @@ inputname (1), inputname (2), inputname (3)); endif - [u, scale] = slsg03bd (a.', e.', b.', false); + [u, scale] = __sl_sg03bd__ (a.', e.', b.', false); ## NOTE: TRANS = 'T' not suitable because we need U' U, not U U' Modified: trunk/octave-forge/main/control/inst/ncfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/ncfsyn.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/ncfsyn.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -110,11 +110,11 @@ ## synthesis if (isct (Gs)) # continuous-time - [ak, bk, ck, dk, rcond] = slsb10id (a, b, c, d, factor); + [ak, bk, ck, dk, rcond] = __sl_sb10id__ (a, b, c, d, factor); elseif (any (d(:))) # discrete-time, d != 0 - [ak, bk, ck, dk, rcond] = slsb10zd (a, b, c, d, factor, 0.0); + [ak, bk, ck, dk, rcond] = __sl_sb10zd__ (a, b, c, d, factor, 0.0); else # discrete-time, d == 0 - [ak, bk, ck, dk, rcond] = slsb10kd (a, b, c, factor); + [ak, bk, ck, dk, rcond] = __sl_sb10kd__ (a, b, c, factor); endif ## controller @@ -198,7 +198,7 @@ %! %! FACTOR = 1.0; %! -%! [AK, BK, CK, DK, RCOND] = slsb10id (A, B, C, D, FACTOR); +%! [AK, BK, CK, DK, RCOND] = __sl_sb10id__ (A, B, C, D, FACTOR); %! %! AKe = [ -39.0671 9.9293 22.2322 -27.4113 43.8655 %! -6.6117 3.0006 11.0878 -11.4130 15.4269 @@ -304,7 +304,7 @@ %! %! FACTOR = 1.1; %! -%! [AK, BK, CK, DK, RCOND] = slsb10kd (A, B, C, FACTOR); +%! [AK, BK, CK, DK, RCOND] = __sl_sb10kd__ (A, B, C, FACTOR); %! %! AKe = [ 0.0337 0.0222 0.0858 0.1264 -0.1872 0.1547 %! 0.4457 0.0668 -0.2255 -0.3204 -0.4548 -0.0691 @@ -414,7 +414,7 @@ %! %! FACTOR = 1.1; %! -%! [AK, BK, CK, DK, RCOND] = slsb10zd (A, B, C, D, FACTOR, 0.0); +%! [AK, BK, CK, DK, RCOND] = __sl_sb10zd__ (A, B, C, D, FACTOR, 0.0); %! %! AKe = [ 1.0128 0.5101 -0.1546 1.1300 3.3759 0.4911 %! -2.1257 -1.4517 -0.4486 0.3493 -1.5506 -1.4296 Modified: trunk/octave-forge/main/control/inst/place.m =================================================================== --- trunk/octave-forge/main/control/inst/place.m 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/inst/place.m 2012-09-04 09:09:48 UTC (rev 10959) @@ -136,7 +136,7 @@ tol = 0; endif - [f, nfp, nap, nup, z] = slsb01bd (a, b, wr, wi, discrete, alpha, tol); + [f, nfp, nap, nup, z] = __sl_sb01bd__ (a, b, wr, wi, discrete, alpha, tol); f = -f; # A + B*F --> A - B*F info = struct ("nfp", nfp, "nap", nap, "nup", nup, "z", z); Modified: trunk/octave-forge/main/control/src/Makefile =================================================================== --- trunk/octave-forge/main/control/src/Makefile 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/Makefile 2012-09-04 09:09:48 UTC (rev 10959) @@ -11,7 +11,7 @@ endif LFLAGS := $(shell $(MKOCTFILE) -p LFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -all: control_slicot_functions.oct \ +all: __control_slicot_functions__.oct \ is_real_scalar.oct \ is_real_vector.oct \ is_real_matrix.oct \ @@ -35,9 +35,9 @@ rm -rf *.o *.f slicot # slicot functions -control_slicot_functions.oct: control_slicot_functions.cc slicotlibrary.a +__control_slicot_functions__.oct: __control_slicot_functions__.cc slicotlibrary.a LFLAGS="$(LFLAGS)" \ - $(MKOCTFILE) control_slicot_functions.cc common.cc slicotlibrary.a + $(MKOCTFILE) __control_slicot_functions__.cc common.cc slicotlibrary.a # helpers is_real_scalar.oct: is_real_scalar.cc Copied: trunk/octave-forge/main/control/src/__control_slicot_functions__.cc (from rev 10958, trunk/octave-forge/main/control/src/control_slicot_functions.cc) =================================================================== --- trunk/octave-forge/main/control/src/__control_slicot_functions__.cc (rev 0) +++ trunk/octave-forge/main/control/src/__control_slicot_functions__.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -0,0 +1,58 @@ +#include "slab08nd.cc" // transmission zeros of state-space models +#include "slab13dd.cc" // L-infinity norm +#include "slsb10hd.cc" // H-2 controller synthesis - continuous-time +#include "slsb10ed.cc" // H-2 controller synthesis - discrete-time +#include "slab13bd.cc" // H-2 norm +#include "slsb01bd.cc" // Pole assignment +#include "slsb10fd.cc" // H-infinity controller synthesis - continuous-time +#include "slsb10dd.cc" // H-infinity controller synthesis - discrete-time +#include "slsb03md.cc" // Lyapunov equations +#include "slsb04md.cc" // Sylvester equations - continuous-time +#include "slsb04qd.cc" // Sylvester equations - discrete-time +#include "slsg03ad.cc" // generalized Lyapunov equations +#include "slsb02od.cc" // algebraic Riccati equations +#include "slab13ad.cc" // Hankel singular values +#include "slab01od.cc" // staircase form using orthogonal transformations +#include "sltb01pd.cc" // minimal realization of state-space models +#include "slsb03od.cc" // Cholesky factor of Lyapunov equations +#include "slsg03bd.cc" // Cholesky factor of generalized Lyapunov equations +#include "slag08bd.cc" // transmission zeros of descriptor state-space models +#include "sltg01jd.cc" // minimal realization of descriptor state-space models +#include "sltg01hd.cc" // controllability staircase form of descriptor state-space models +#include "sltg01id.cc" // observability staircase form of descriptor state-space models +#include "slsg02ad.cc" // solution of algebraic Riccati equations for descriptor systems +#include "sltg04bx.cc" // gain of descriptor state-space models +#include "sltb01id.cc" // scaling of state-space models +#include "sltg01ad.cc" // scaling of descriptor state-space models +#include "slsb10id.cc" // H-infinity loop shaping - continuous-time +#include "slsb10kd.cc" // H-infinity loop shaping - discrete-time - strictly proper case +#include "slsb10zd.cc" // H-infinity loop shaping - discrete-time - proper case +#include "sltb04bd.cc" // State-space to transfer function conversion +#include "slab04md.cc" // bilinear transformation +#include "slsb10jd.cc" // descriptor to regular state-space conversion +#include "sltd04ad.cc" // transfer function to state-space conversion +#include "sltb01ud.cc" // controllable block Hessenberg realization +#include "slab09hd.cc" // balanced stochastic truncation model reduction +#include "slab09id.cc" // balanced truncation & singular perturbation approximation model reduction +#include "slab09jd.cc" // hankel-norm approximation model reduction +#include "slsb16ad.cc" // balanced truncation & singular perturbation approximation controller reduction +#include "slsb16bd.cc" // coprime factorization state-feedback controller reduction +#include "slsb16cd.cc" // frequency-weighted coprime factorization state-feedback controller reduction +#include "slsb10yd.cc" // fit state-space model to frequency response data +#include "slident.cc" // system identification +#include "slib01cd.cc" // compute initial state vector +#include "slib01ad.cc" // compute singular values + + +// stub function to avoid gen_doc_cache warning upon package installation +DEFUN_DLD (__control_slicot_functions__, args, nargout, + "-*- texinfo -*-\n\ +Slicot Release 5.0\n\ +No argument checking.\n\ +For internal use only.") +{ + octave_value_list retval; + error ("__control_slicot_functions__: for internal use only"); + return retval; +} + Deleted: trunk/octave-forge/main/control/src/control_slicot_functions.cc =================================================================== --- trunk/octave-forge/main/control/src/control_slicot_functions.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/control_slicot_functions.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -1,58 +0,0 @@ -#include "slab08nd.cc" // transmission zeros of state-space models -#include "slab13dd.cc" // L-infinity norm -#include "slsb10hd.cc" // H-2 controller synthesis - continuous-time -#include "slsb10ed.cc" // H-2 controller synthesis - discrete-time -#include "slab13bd.cc" // H-2 norm -#include "slsb01bd.cc" // Pole assignment -#include "slsb10fd.cc" // H-infinity controller synthesis - continuous-time -#include "slsb10dd.cc" // H-infinity controller synthesis - discrete-time -#include "slsb03md.cc" // Lyapunov equations -#include "slsb04md.cc" // Sylvester equations - continuous-time -#include "slsb04qd.cc" // Sylvester equations - discrete-time -#include "slsg03ad.cc" // generalized Lyapunov equations -#include "slsb02od.cc" // algebraic Riccati equations -#include "slab13ad.cc" // Hankel singular values -#include "slab01od.cc" // staircase form using orthogonal transformations -#include "sltb01pd.cc" // minimal realization of state-space models -#include "slsb03od.cc" // Cholesky factor of Lyapunov equations -#include "slsg03bd.cc" // Cholesky factor of generalized Lyapunov equations -#include "slag08bd.cc" // transmission zeros of descriptor state-space models -#include "sltg01jd.cc" // minimal realization of descriptor state-space models -#include "sltg01hd.cc" // controllability staircase form of descriptor state-space models -#include "sltg01id.cc" // observability staircase form of descriptor state-space models -#include "slsg02ad.cc" // solution of algebraic Riccati equations for descriptor systems -#include "sltg04bx.cc" // gain of descriptor state-space models -#include "sltb01id.cc" // scaling of state-space models -#include "sltg01ad.cc" // scaling of descriptor state-space models -#include "slsb10id.cc" // H-infinity loop shaping - continuous-time -#include "slsb10kd.cc" // H-infinity loop shaping - discrete-time - strictly proper case -#include "slsb10zd.cc" // H-infinity loop shaping - discrete-time - proper case -#include "sltb04bd.cc" // State-space to transfer function conversion -#include "slab04md.cc" // bilinear transformation -#include "slsb10jd.cc" // descriptor to regular state-space conversion -#include "sltd04ad.cc" // transfer function to state-space conversion -#include "sltb01ud.cc" // controllable block Hessenberg realization -#include "slab09hd.cc" // balanced stochastic truncation model reduction -#include "slab09id.cc" // balanced truncation & singular perturbation approximation model reduction -#include "slab09jd.cc" // hankel-norm approximation model reduction -#include "slsb16ad.cc" // balanced truncation & singular perturbation approximation controller reduction -#include "slsb16bd.cc" // coprime factorization state-feedback controller reduction -#include "slsb16cd.cc" // frequency-weighted coprime factorization state-feedback controller reduction -#include "slsb10yd.cc" // fit state-space model to frequency response data -#include "slident.cc" // system identification -#include "slib01cd.cc" // compute initial state vector -#include "slib01ad.cc" // compute singular values - - -// stub function to avoid gen_doc_cache warning upon package installation -DEFUN_DLD (control_slicot_functions, args, nargout, - "-*- texinfo -*-\n\ -Slicot Release 5.0\n\ -No argument checking.\n\ -For internal use only.") -{ - octave_value_list retval; - error ("control_slicot_functions: for internal use only"); - return retval; -} - Modified: trunk/octave-forge/main/control/src/slab01od.cc =================================================================== --- trunk/octave-forge/main/control/src/slab01od.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab01od.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -49,8 +49,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab01od", "control_slicot_functions.oct"); -DEFUN_DLD (slab01od, args, nargout, +// PKG_ADD: autoload ("__sl_ab01od__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab01od__, args, nargout, "-*- texinfo -*-\n\ Slicot AB01OD Release 5.0\n\ No argument checking.\n\ @@ -118,10 +118,10 @@ info)); if (f77_exception_encountered) - error ("slab01od: exception in SLICOT subroutine AB01OD"); + error ("__sl_ab01od__: exception in SLICOT subroutine AB01OD"); if (info != 0) - error ("slab01od: AB01OD returned info = %d", info); + error ("__sl_ab01od__: AB01OD returned info = %d", info); // resize a.resize (n, n); Modified: trunk/octave-forge/main/control/src/slab04md.cc =================================================================== --- trunk/octave-forge/main/control/src/slab04md.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab04md.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -47,8 +47,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab04md", "control_slicot_functions.oct"); -DEFUN_DLD (slab04md, args, nargout, +// PKG_ADD: autoload ("__sl_ab04md__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab04md__, args, nargout, "-*- texinfo -*-\n\ Slicot AB04MD Release 5.0\n\ No argument checking.\n\ @@ -113,10 +113,10 @@ info)); if (f77_exception_encountered) - error ("slab04md: exception in SLICOT subroutine AB04MD"); + error ("__sl_ab04md__: exception in SLICOT subroutine AB04MD"); if (info != 0) - error ("slab04md: AB04MD returned info = %d", info); + error ("__sl_ab04md__: AB04MD returned info = %d", info); // return values retval(0) = a; Modified: trunk/octave-forge/main/control/src/slab08nd.cc =================================================================== --- trunk/octave-forge/main/control/src/slab08nd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab08nd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -64,8 +64,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab08nd", "control_slicot_functions.oct"); -DEFUN_DLD (slab08nd, args, nargout, +// PKG_ADD: autoload ("__sl_ab08nd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab08nd__, args, nargout, "-*- texinfo -*-\n\ Slicot AB08ND Release 5.0\n\ No argument checking.\n\ @@ -151,10 +151,10 @@ info)); if (f77_exception_encountered) - error ("ss: zero: slab08nd: exception in SLICOT subroutine AB08ND"); + error ("ss: zero: __sl_ab08nd__: exception in SLICOT subroutine AB08ND"); if (info != 0) - error ("ss: zero: slab08nd: AB08ND returned info = %d", info); + error ("ss: zero: __sl_ab08nd__: AB08ND returned info = %d", info); // DGGEV Part @@ -188,10 +188,10 @@ info2)); if (f77_exception_encountered) - error ("ss: zero: slab08nd: exception in LAPACK subroutine DGGEV"); + error ("ss: zero: __sl_ab08nd__: exception in LAPACK subroutine DGGEV"); if (info2 != 0) - error ("ss: zero: slab08nd: DGGEV returned info = %d", info2); + error ("ss: zero: __sl_ab08nd__: DGGEV returned info = %d", info2); // calculate gain octave_value gain = Matrix (0, 0);; Modified: trunk/octave-forge/main/control/src/slab09hd.cc =================================================================== --- trunk/octave-forge/main/control/src/slab09hd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab09hd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -51,8 +51,8 @@ int& IWARN, int& INFO); } -// PKG_ADD: autoload ("slab09hd", "control_slicot_functions.oct"); -DEFUN_DLD (slab09hd, args, nargout, +// PKG_ADD: autoload ("__sl_ab09hd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab09hd__, args, nargout, "-*- texinfo -*-\n\ Slicot AB09HD Release 5.0\n\ No argument checking.\n\ @@ -105,7 +105,7 @@ job = 'P'; break; default: - error ("slab09hd: argument job invalid"); + error ("__sl_ab09hd__: argument job invalid"); } if (idico == 0) Modified: trunk/octave-forge/main/control/src/slab09id.cc =================================================================== --- trunk/octave-forge/main/control/src/slab09id.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab09id.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -61,8 +61,8 @@ int& IWARN, int& INFO); } -// PKG_ADD: autoload ("slab09id", "control_slicot_functions.oct"); -DEFUN_DLD (slab09id, args, nargout, +// PKG_ADD: autoload ("__sl_ab09id__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab09id__, args, nargout, "-*- texinfo -*-\n\ Slicot AB09ID Release 5.0\n\ No argument checking.\n\ @@ -157,7 +157,7 @@ job = 'P'; break; default: - error ("slab09id: argument job invalid"); + error ("__sl_ab09id__: argument job invalid"); } switch (iweight) @@ -175,7 +175,7 @@ weight = 'B'; break; default: - error ("slab09id: argument weight invalid"); + error ("__sl_ab09id__: argument weight invalid"); } int n = a.rows (); // n: number of states Modified: trunk/octave-forge/main/control/src/slab09jd.cc =================================================================== --- trunk/octave-forge/main/control/src/slab09jd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab09jd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -59,8 +59,8 @@ int& IWARN, int& INFO); } -// PKG_ADD: autoload ("slab09jd", "control_slicot_functions.oct"); -DEFUN_DLD (slab09jd, args, nargout, +// PKG_ADD: autoload ("__sl_ab09jd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab09jd__, args, nargout, "-*- texinfo -*-\n\ Slicot AB09JD Release 5.0\n\ No argument checking.\n\ @@ -128,7 +128,7 @@ jobv = 'R'; break; default: - error ("slab09jd: argument jobv invalid"); + error ("__sl_ab09jd__: argument jobv invalid"); } switch (ijobw) @@ -149,7 +149,7 @@ jobw = 'R'; break; default: - error ("slab09jd: argument jobw invalid"); + error ("__sl_ab09jd__: argument jobw invalid"); } switch (ijobinv) @@ -164,7 +164,7 @@ jobinv = 'A'; break; default: - error ("slab09jd: argument jobinv invalid"); + error ("__sl_ab09jd__: argument jobinv invalid"); } if (idico == 0) Modified: trunk/octave-forge/main/control/src/slab13ad.cc =================================================================== --- trunk/octave-forge/main/control/src/slab13ad.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab13ad.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -46,8 +46,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab13ad", "control_slicot_functions.oct"); -DEFUN_DLD (slab13ad, args, nargout, +// PKG_ADD: autoload ("__sl_ab13ad__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab13ad__, args, nargout, "-*- texinfo -*-\n\ Slicot AB13AD Release 5.0\n\ No argument checking.\n\ @@ -120,10 +120,10 @@ info)); if (f77_exception_encountered) - error ("hsvd: slab13ad: exception in SLICOT subroutine AB13AD"); + error ("hsvd: __sl_ab13ad__: exception in SLICOT subroutine AB13AD"); if (info != 0) - error ("hsvd: slab13ad: AB13AD returned info = %d", info); + error ("hsvd: __sl_ab13ad__: AB13AD returned info = %d", info); // resize hsv.resize (ns); Modified: trunk/octave-forge/main/control/src/slab13bd.cc =================================================================== --- trunk/octave-forge/main/control/src/slab13bd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab13bd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -47,8 +47,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab13bd", "control_slicot_functions.oct"); -DEFUN_DLD (slab13bd, args, nargout, +// PKG_ADD: autoload ("__sl_ab13bd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab13bd__, args, nargout, "-*- texinfo -*-\n\ Slicot AB13BD Release 5.\n\ No argument checking.\n\ @@ -120,13 +120,13 @@ info); if (f77_exception_encountered) - error ("lti: norm: slab13bd: exception in SLICOT subroutine AB13BD"); + error ("lti: norm: __sl_ab13bd__: exception in SLICOT subroutine AB13BD"); if (info != 0) - error ("lti: norm: slab13bd: AB13BD returned info = %d", info); + error ("lti: norm: __sl_ab13bd__: AB13BD returned info = %d", info); if (iwarn != 0) - warning ("lti: norm: slab13bd: AB13BD returned iwarn = %d", iwarn); + warning ("lti: norm: __sl_ab13bd__: AB13BD returned iwarn = %d", iwarn); // return value retval(0) = octave_value (norm); Modified: trunk/octave-forge/main/control/src/slab13dd.cc =================================================================== --- trunk/octave-forge/main/control/src/slab13dd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slab13dd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -51,8 +51,8 @@ int& INFO); } -// PKG_ADD: autoload ("slab13dd", "control_slicot_functions.oct"); -DEFUN_DLD (slab13dd, args, nargout, +// PKG_ADD: autoload ("__sl_ab13dd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ab13dd__, args, nargout, "-*- texinfo -*-\n\ Slicot AB13DD Release 5.0\n\ No argument checking.\n\ @@ -145,10 +145,10 @@ info)); if (f77_exception_encountered) - error ("lti: norm: slab13dd: exception in SLICOT subroutine AB13DD"); + error ("lti: norm: __sl_ab13dd__: exception in SLICOT subroutine AB13DD"); if (info != 0) - error ("lti: norm: slab13dd: AB13DD returned info = %d", info); + error ("lti: norm: __sl_ab13dd__: AB13DD returned info = %d", info); // return values retval(0) = fpeak; Modified: trunk/octave-forge/main/control/src/slag08bd.cc =================================================================== --- trunk/octave-forge/main/control/src/slag08bd.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slag08bd.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -64,8 +64,8 @@ int& INFO); } -// PKG_ADD: autoload ("slag08bd", "control_slicot_functions.oct"); -DEFUN_DLD (slag08bd, args, nargout, +// PKG_ADD: autoload ("__sl_ag08bd__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ag08bd__, args, nargout, "-*- texinfo -*-\n\ Slicot AG08BD Release 5.0\n\ No argument checking.\n\ @@ -154,10 +154,10 @@ info)); if (f77_exception_encountered) - error ("dss: zero: slag08bd: exception in SLICOT subroutine AG08BD"); + error ("dss: zero: __sl_ag08bd__: exception in SLICOT subroutine AG08BD"); if (info != 0) - error ("dss: zero: slag08bd: AG08BD returned info = %d", info); + error ("dss: zero: __sl_ag08bd__: AG08BD returned info = %d", info); // DGGEV Part @@ -197,10 +197,10 @@ info2)); if (f77_exception_encountered) - error ("dss: zero: slag08bd: exception in LAPACK subroutine DGGEV"); + error ("dss: zero: __sl_ag08bd__: exception in LAPACK subroutine DGGEV"); if (info2 != 0) - error ("dss: zero: slag08bd: DGGEV returned info = %d", info2); + error ("dss: zero: __sl_ag08bd__: DGGEV returned info = %d", info2); // assemble complex vector - adapted from DEFUN complex in data.cc // LAPACK DGGEV.f says: Modified: trunk/octave-forge/main/control/src/slib01ad.cc =================================================================== --- trunk/octave-forge/main/control/src/slib01ad.cc 2012-09-04 01:58:03 UTC (rev 10958) +++ trunk/octave-forge/main/control/src/slib01ad.cc 2012-09-04 09:09:48 UTC (rev 10959) @@ -50,8 +50,8 @@ int& IWARN, int& INFO); } -// PKG_ADD: autoload ("slib01ad", "control_slicot_functions.oct"); -DEFUN_DLD (slib01ad, args, nargout, +// PKG_ADD: autoload ("__sl_ib01ad__", "__control_slicot_functions__.oct"); +DEFUN_DLD (__sl_ib01ad__, args, nargout, "-*- texinfo -*-\n\ Slicot IB01AD Release 5.0\n\ No argument checking.\n\ @@ -111,7 +111,7 @@ meth_b = 'C'; break; default: - error ("slib01ad: argument 'meth' invalid"); + error ("__sl_ib01ad__: argument 'meth' invalid"); } switch (ialg) @@ -126,7 +126,7 @@ alg = 'Q'; break; default: - error ("slib01ad: argument 'alg' invalid"); + error ("__sl_ib01ad__: argument 'alg' invalid"); } if (meth_a == 'M') @@ -159,7 +159,7 @@ else if (meth_a == 'N' || (meth_a == 'M' && jobd == 'N')) ldr = 2*(m+l)*nobr; else - ... [truncated message content] |
From: <jo...@us...> - 2012-09-04 01:58:12
|
Revision: 10958 http://octave.svn.sourceforge.net/octave/?rev=10958&view=rev Author: jordigh Date: 2012-09-04 01:58:03 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Fix bwlabeln's input-checking, some futile attempts to optimise Modified Paths: -------------- trunk/octave-forge/main/image/src/bwlabeln.cc Modified: trunk/octave-forge/main/image/src/bwlabeln.cc =================================================================== --- trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-03 20:33:01 UTC (rev 10957) +++ trunk/octave-forge/main/image/src/bwlabeln.cc 2012-09-04 01:58:03 UTC (rev 10958) @@ -19,9 +19,6 @@ #include <set> #include "union-find.h++" - -dim_vector conn26_dim(3,3,3); -boolNDArray conn26(conn26_dim,1); typedef Array<octave_idx_type> coord; bool operator== (const coord& a, const coord& b) @@ -83,8 +80,6 @@ } }; -namespace { - // A few basic utility functions //{ inline @@ -135,7 +130,7 @@ operator- (const coord& a) { octave_idx_type na = a.nelem (); - coord retval( dim_vector(na,1) ); + coord retval (dim_vector(na,1) ); for (octave_idx_type i = 0; i < na; i++) { retval(i) = -a(i); @@ -144,52 +139,10 @@ } //} -bool any_bad_argument (const octave_value_list& args) -{ - return false; - - const int nargin = args.length (); - if (nargin < 1 || nargin > 2) - { - print_usage (); - return true; - } - - if (!args (0).is_bool_type ()) - { - error ("bwlabeln: first input argument must be a 'logical' ND-array"); - return true; - } - - if (nargin == 2) - { - if (!args (1).is_real_scalar () && ! args(1).is_bool_type()) - { - error ("bwlabeln: second input argument must be a real scalar " - "or a 'logical' connectivity array"); - return true; - } - } - - return false; -} - -//debug -#include <iostream> -using namespace std; - -ostream& -operator<< (ostream& os, const coord& aidx) -{ - for (octave_idx_type i = 0; i < aidx.nelem (); i++) - os << aidx(i) + 1 << " "; - return os; -} - -set<coord> +std::set<coord> populate_neighbours(const boolNDArray& conn_mask) { - set<coord> neighbours; + std::set<coord> neighbours; dim_vector conn_size = conn_mask.dims (); coord centre(dim_vector(conn_size.length (), 1), 1); @@ -210,9 +163,114 @@ return neighbours; } +boolNDArray +get_mask(int N){ + bool* mask_ptr; + octave_idx_type n; + + static bool mask4[] = {0, 1, 0, + 1, 0, 1, + 0, 1, 0}; + + static bool mask8[] = {1, 1, 1, + 1, 0, 1, + 1, 0, 1}; + + static bool mask6[] = {0, 0, 0, + 0, 1, 0, + 0, 0, 0, + + 0, 1, 0, + 1, 0, 1, + 0, 1, 0, + + 0, 0, 0, + 0, 1, 0, + 0, 0, 0}; + + static bool mask18[] = {0, 1, 0, + 1, 1, 1, + 0, 1, 0, + + 1, 1, 1, + 1, 0, 1, + 1, 1, 1, + + 0, 1, 0, + 1, 1, 1, + 0, 1, 0}; + + static bool mask26[] = {1, 1, 1, + 1, 1, 1, + 1, 1, 1, + + 1, 1, 1, + 1, 0, 1, + 1, 1, 1, + + 1, 1, 1, + 1, 1, 1, + 1, 1, 1}; + + switch (N){ + case 4: + n = 2; + mask_ptr = mask4; + break; + case 8: + n = 2; + mask_ptr = mask8; + break; + case 6: + n = 3; + mask_ptr = mask6; + break; + case 18: + n = 3; + mask_ptr = mask18; + break; + case 26: + n = 3; + mask_ptr = mask26; + break; + default: + panic_impossible (); + } + + boolNDArray conn_mask; + if (n == 2) + { + conn_mask.resize (dim_vector (3, 3)); + for (octave_idx_type i = 0; i < 9; i++) + conn_mask(i) = mask_ptr[i]; + + } + else + { + conn_mask.resize (dim_vector (3, 3, 3)); + for (octave_idx_type i = 0; i < 27; i++) + conn_mask(i) = mask_ptr[i]; + } + + return conn_mask; +} + +boolNDArray +get_mask (const boolNDArray& BW) +{ + dim_vector mask_dims = BW.dims(); + for (auto i = 0; i < mask_dims.length (); i++) + mask_dims(i) = 3; + + return boolNDArray (mask_dims, 1); +} + +#include <iostream> + DEFUN_DLD(bwlabeln, args, , "\ -*- texinfo -*-\n\ -@deftypefn {Loadable Function} {[@var{l}, @var{num}] =} bwlabeln(@var{bw}, @var{n})\n\ +@deftypefn {Loadable Function} {[@var{l}, @var{num}] =} bwlabeln(@var{bw})\n\ +@deftypefnx {Loadable Function} {[@var{l}, @var{num}] =} bwlabeln(@var{bw}, @var{n})\n\ Label foreground objects in the n-dimensional binary image @var{bw}.\n\ \n\ The optional argument @var{n} sets the connectivity and defaults 26.\n\ @@ -230,27 +288,78 @@ union_find<coord, coord_hash> u_f; - if (any_bad_argument (args)) + octave_idx_type nargin = args.length (); + + if (nargin < 1 || nargin > 2) + { + print_usage (); return rval; + } - boolNDArray BW = args (0).bool_array_value (); + if (!args(0).is_bool_type ()) + { + error ("bwlabeln: first input argument must be a 'logical' ND-array"); + return rval; + } + boolNDArray BW = args(0).bool_array_value (); dim_vector size_vec = BW.dims (); - int nargin = args.length (); - //Connectivity mask boolNDArray conn_mask; - if( nargin == 1) - conn_mask = conn26; //Implement this properly later + + if (nargin == 2) + { + if (args(1).is_real_scalar ()) + { + double N = args(1).scalar_value (); + if (size_vec.length () == 2 && N != 4 && N != 8) + error ("bwlabeln: for 2d arrays, scalar N must be 4 or 8"); + else if (size_vec.length () == 3 && N != 6 && N != 18 && N != 26) + error ("bwlabeln: for 3d arrays, scalar N must be 4 or 8"); + else if (size_vec.length () > 3) + error ("bwlabeln: for higher-dimensional arrays, N must be a " + "connectivity mask"); + else + conn_mask = get_mask (N); + } + else if (args(2).is_bool_type() ) + { + conn_mask = args(2).bool_array_value (); + dim_vector conn_mask_dims = conn_mask.dims (); + if (conn_mask_dims.length () != size_vec.length ()) + error ("bwlabeln: connectivity mask N must have the same " + "dimensions as BW"); + for (octave_idx_type i = 0; i < conn_mask_dims.length (); i++) + { + if (conn_mask_dims(i) != 3) + { + error ("bwlabeln: connectivity mask N must have all " + "dimensions equal to 3"); + } + } + } + else + error ("bwlabeln: second input argument must be a real scalar " + "or a 'logical' connectivity array"); + } else - conn_mask = conn26; + // Get the maximal mask that has same number of dims as BW. + conn_mask = get_mask (BW); + if (error_state) + return rval; + + using std::set; + set<coord> neighbours = populate_neighbours(conn_mask); + std::cout << "Union-finding..." << std::endl;; + + bool* BW_vec = BW.fortran_vec (); for (octave_idx_type idx = 0; idx < BW.nelem (); idx++) { - if (BW(idx)) + if (BW_vec[idx]) { coord aidx = to_coord (size_vec, idx); @@ -259,7 +368,7 @@ //Replace this with C++0x range-based for loop later //(implemented in gcc 4.6) - for (auto nbr = neighbours.begin (); nbr!= neighbours.end (); nbr++) + for (auto nbr = neighbours.begin (); nbr != neighbours.end (); nbr++) { coord n = *nbr + aidx; if (in_range (n,size_vec) and BW(n) ) @@ -297,4 +406,3 @@ rval(1) = ids_to_label.size (); return rval; } -}//anonymous namespace This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-09-03 20:33:07
|
Revision: 10957 http://octave.svn.sourceforge.net/octave/?rev=10957&view=rev Author: cdf Date: 2012-09-03 20:33:01 +0000 (Mon, 03 Sep 2012) Log Message: ----------- remove execution permissions Property Changed: ---------------- trunk/octave-forge/extra/secs1d/inst/secs1d_dd_gummel_map.m trunk/octave-forge/extra/secs1d/inst/secs1d_nlpoisson_newton.m trunk/octave-forge/extra/secs1d/inst/secs1d_silicon_material_properties.m Property changes on: trunk/octave-forge/extra/secs1d/inst/secs1d_dd_gummel_map.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/extra/secs1d/inst/secs1d_nlpoisson_newton.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/extra/secs1d/inst/secs1d_silicon_material_properties.m ___________________________________________________________________ Deleted: svn:executable - * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-03 19:52:18
|
Revision: 10956 http://octave.svn.sourceforge.net/octave/?rev=10956&view=rev Author: prnienhuis Date: 2012-09-03 19:52:12 +0000 (Mon, 03 Sep 2012) Log Message: ----------- Bug fix list updated Modified Paths: -------------- trunk/octave-forge/main/io/NEWS Modified: trunk/octave-forge/main/io/NEWS =================================================================== --- trunk/octave-forge/main/io/NEWS 2012-09-03 19:51:31 UTC (rev 10955) +++ trunk/octave-forge/main/io/NEWS 2012-09-03 19:52:12 UTC (rev 10956) @@ -1,6 +1,19 @@ Summary of important user-visible changes for releases of the io package =============================================================================== +io-1.0.20 Release Date: 2012-TBA Release Manager: Philip Nienhuis +=============================================================================== + +** Bug fixes: +--- xlsopen, xlsclose, odsopen, odsclose: replaced canonicalize_file_name call + with make_absolute_filename for non-windows systems (canonicalize_file_name + doesn't work with non-existent (new) files on *nix) (bug #36677); + Web addresses (URLs) only need two rather than three slashes; +--- xlsopen: matching .jar names to javaclasspath entries worked the wrong way + +** Extended file rename section in odsclose similar to that in xlsclose + +=============================================================================== io-1.0.19 Release Date: 2012-06-08 Release Manager: Philip Nienhuis =============================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-03 19:51:38
|
Revision: 10955 http://octave.svn.sourceforge.net/octave/?rev=10955&view=rev Author: prnienhuis Date: 2012-09-03 19:51:31 +0000 (Mon, 03 Sep 2012) Log Message: ----------- Replaced canonicalize_file_name() calls for *nix systems by make_absolute_filename (bug #36677); 2 rather than 3 slashes for web addresses in UNO sections; code cleanup Modified Paths: -------------- trunk/octave-forge/main/io/inst/odsclose.m trunk/octave-forge/main/io/inst/odsopen.m trunk/octave-forge/main/io/inst/xlsclose.m trunk/octave-forge/main/io/inst/xlsopen.m Modified: trunk/octave-forge/main/io/inst/odsclose.m =================================================================== --- trunk/octave-forge/main/io/inst/odsclose.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/odsclose.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -65,6 +65,7 @@ ## 2011-09-08 FIXME - closing OOo kills all other OOo invocations (known Java-UNO issue) ## 2012-01-26 Fixed "seealso" help string ## 2012-06-08 tabs replaced by double space +## 2012-09-03 Extended file renaming section to xlsclose equivalent function [ ods ] = odsclose (ods, varargs) @@ -78,17 +79,39 @@ if (strcmp (lower (varargin{ii}), "force")) # Close .ods anyway even if write errors occur force = 1; - elseif (~isempty (strfind (tolower (varargin{ii}), '.ods')) || ... - ~isempty (strfind (tolower (varargin{ii}), '.sxc'))) - # Apparently a file name + elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) + # Apparently a file name. First some checks.... if (ods.changed == 0 || ods.changed > 2) warning ("File %s wasn't changed, new filename ignored.", ods.filename); + elseif (~strcmp (xls.xtype, 'UNO') && isempty (strfind ( lower (filename), '.ods'))) + # UNO will write any file type, all other interfaces only .ods + error ('.ods suffix lacking in filename %s', filename); else - if (strfind (tolower (filename), '.sxc') || strfind (tolower (filename), '.ods')) - ods.filename = filename; - else - error ('No .sxc or .ods filename extension specified'); + # All checks passed + if (strcmp (xls.xtype, 'UNO')) + # For UNO, turn filename into URL + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) + # Seems in proper shape for OOo (at first sight) + else + # Transform into URL form + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif + # On Windows, change backslash file separator into forward slash + if (strcmp (filesep, "\\")) + tmp = strsplit (fname, filesep); + flen = numel (tmp); + tmp(2:2:2*flen) = tmp; + tmp(1:2:2*flen) = '/'; + filename = [ 'file://' tmp{:} ]; + endif + endif endif + # Preprocessing / -checking ready. Assign filename arg to file ptr struct + ods.filename = filename; endif endif endfor Modified: trunk/octave-forge/main/io/inst/odsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/odsopen.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/odsopen.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -93,6 +93,9 @@ ## 2012-02-26 Added ";" to suppress echo of filename f UNO ## 2012-06-06 Made interface checking routine less verbose when same requested interface ## was used consecutively +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) +## '' (in UNO section) web adresses need only two consecutive slashes ## ## Latest change on subfunctions below: 2012-06-08 @@ -263,12 +266,18 @@ if (odsinterfaces.UNO && ~odssupport) # First the file name must be transformed into a URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) # Seems in proper shape for OOO (at first sight) else # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); + ## FIXME make_absolute_filename() doesn't work across drive(-letters) so + ## until it is fixed we'll fall back on canonicalize_file_name() there + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif # On Windows, change backslash file separator into forward slash if (strcmp (filesep, "\\")) tmp = strsplit (fname, filesep); Modified: trunk/octave-forge/main/io/inst/xlsclose.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsclose.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/xlsclose.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -71,208 +71,216 @@ ## 2011-05-18 Added experimental UNO support, incl. saving newly created files ## 2011-09-08 Bug fix in check for filename input arg ## 2012-01-26 Fixed "seealso" help string +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) +## '' (in UNO section) web adresses need only two consecutive slashes function [ xls ] = xlsclose (xls, varargs) - force = 0; + force = 0; - if (nargin > 1) - for ii=2:nargin - if (strcmp (lower (varargin{ii}), "force")) - # Close .ods anyway even if write errors occur - force = 1; - elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) - # Apparently a file name - if (xls.changed == 0 || xls.changed > 2) - printf ("File %s wasn't changed, new filename ignored.", xls.filename); - elseif (strcmp (xls.xtype, 'JXL')) - error ("JXL doesn't support changing filename, new filename ignored."); - elseif ~((strcmp (xls.xtype, 'COM') || strcmp (xls.xtype, 'UNO')) && isempty (strfind ( lower (filename), '.xls'))) - # Excel/ActiveX && OOo (UNO bridge) will write any valid filetype; POI/JXL/OXS need .xls[x] - error ('.xls or .xlsx extension lacking in filename %s', filename); - else - ### For multi-user environments, uncomment below AND relevant stanza in xlsopen - # In case of COM, be sure to first close the open workbook - #if (strcmp (xls.xtype, 'COM')) - # xls.app.Application.DisplayAlerts = 0; - # xls.workbook.close(); - # xls.app.Application.DisplayAlerts = 0; - #endif - if (strcmp (xls.xtype, 'UNO')) - # If needed, turn filename into URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) - # Seems in proper shape for OOo (at first sight) - else - # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); - # On Windows, change backslash file separator into forward slash - if (strcmp (filesep, "\\")) - tmp = strsplit (fname, filesep); - flen = numel (tmp); - tmp(2:2:2*flen) = tmp; - tmp(1:2:2*flen) = '/'; - filename = [ 'file://' tmp{:} ]; - endif - endif - endif + if (nargin > 1) + for ii=2:nargin + if (strcmp (lower (varargin{ii}), "force")) + # Close .ods anyway even if write errors occur + force = 1; + elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) + # Apparently a file name. First some checks.... + if (xls.changed == 0 || xls.changed > 2) + warning ("File %s wasn't changed, new filename ignored.", xls.filename); + elseif (strcmp (xls.xtype, 'JXL')) + error ("JXL doesn't support changing filename, new filename ignored."); + elseif ~((strcmp (xls.xtype, 'COM') || strcmp (xls.xtype, 'UNO')) && isempty (strfind ( lower (filename), '.xls'))) + # Excel/ActiveX && OOo (UNO bridge) will write any valid filetype; POI/JXL/OXS need .xls[x] + error ('.xls or .xlsx suffix lacking in filename %s', filename); + else + ### For multi-user environments, uncomment below AND relevant stanza in xlsopen + # In case of COM, be sure to first close the open workbook + #if (strcmp (xls.xtype, 'COM')) + # xls.app.Application.DisplayAlerts = 0; + # xls.workbook.close(); + # xls.app.Application.DisplayAlerts = 0; + #endif + # All checks passed + if (strcmp (xls.xtype, 'UNO')) + # If needed, turn filename into URL + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) + # Seems in proper shape for OOo (at first sight) + else + # Transform into URL form + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif + # On Windows, change backslash file separator into forward slash + if (strcmp (filesep, "\\")) + tmp = strsplit (fname, filesep); + flen = numel (tmp); + tmp(2:2:2*flen) = tmp; + tmp(1:2:2*flen) = '/'; + filename = [ 'file://' tmp{:} ]; + endif + endif + endif # Preprocessing / -checking ready. Assign filename arg to file ptr struct - xls.filename = filename; - endif - endif - endfor - endif + xls.filename = filename; + endif + endif + endfor + endif - if (strcmp (xls.xtype, 'COM')) - # If file has been changed, write it out to disk. - # - # Note: COM / VB supports other Excel file formats as FileFormatNum: - # 4 = .wks - Lotus 1-2-3 / Microsoft Works - # 6 = .csv - # -4158 = .txt - # 36 = .prn - # 50 = .xlsb - xlExcel12 (Excel Binary Workbook in 2007 with or without macro's) - # 51 = .xlsx - xlOpenXMLWorkbook (without macro's in 2007) - # 52 = .xlsm - xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007) - # 56 = .xls - xlExcel8 (97-2003 format in Excel 2007) - # (see Excel Help, VB reference, Enumerations, xlFileType) - - # xls.changed = 0: no changes: just close; - # 1: existing file with changes: save, close. - # 2: new file with data added: save, close - # 3: new file, no added added (empty): close & delete on disk + if (strcmp (xls.xtype, 'COM')) + # If file has been changed, write it out to disk. + # + # Note: COM / VB supports other Excel file formats as FileFormatNum: + # 4 = .wks - Lotus 1-2-3 / Microsoft Works + # 6 = .csv + # -4158 = .txt + # 36 = .prn + # 50 = .xlsb - xlExcel12 (Excel Binary Workbook in 2007 with or without macro's) + # 51 = .xlsx - xlOpenXMLWorkbook (without macro's in 2007) + # 52 = .xlsm - xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007) + # 56 = .xls - xlExcel8 (97-2003 format in Excel 2007) + # (see Excel Help, VB reference, Enumerations, xlFileType) + + # xls.changed = 0: no changes: just close; + # 1: existing file with changes: save, close. + # 2: new file with data added: save, close + # 3: new file, no added added (empty): close & delete on disk - xls.app.Application.DisplayAlerts = 0; - try - if (xls.changed > 0 && xls.changed < 3) - if (xls.changed == 2) - # Probably a newly created, or renamed, Excel file - printf ("Saving file %s ...\n", xls.filename); - xls.workbook.SaveAs (canonicalize_file_name (xls.filename)); - elseif (xls.changed == 1) - # Just updated existing Excel file - xls.workbook.Save (); - endif - xls.changed = 0; - xls.workbook.Close (canonicalize_file_name (xls.filename)); - endif - xls.app.Quit (); - delete (xls.workbook); # This statement actually closes the workbook - delete (xls.app); # This statement actually closes down Excel - catch - xls.app.Application.DisplayAlerts = 1; - end_try_catch - - elseif (strcmp (xls.xtype, 'POI')) - if (xls.changed > 0 && xls.changed < 3) - try - xlsout = java_new ("java.io.FileOutputStream", xls.filename); - bufout = java_new ("java.io.BufferedOutputStream", xlsout); - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.write (bufout); - bufout.flush (); - bufout.close (); - xlsout.close (); - xls.changed = 0; - catch -# xlsout.close (); - end_try_catch - endif + xls.app.Application.DisplayAlerts = 0; + try + if (xls.changed > 0 && xls.changed < 3) + if (xls.changed == 2) + # Probably a newly created, or renamed, Excel file + printf ("Saving file %s ...\n", xls.filename); + xls.workbook.SaveAs (canonicalize_file_name (xls.filename)); + elseif (xls.changed == 1) + # Just updated existing Excel file + xls.workbook.Save (); + endif + xls.changed = 0; + xls.workbook.Close (canonicalize_file_name (xls.filename)); + endif + xls.app.Quit (); + delete (xls.workbook); # This statement actually closes the workbook + delete (xls.app); # This statement actually closes down Excel + catch + xls.app.Application.DisplayAlerts = 1; + end_try_catch + + elseif (strcmp (xls.xtype, 'POI')) + if (xls.changed > 0 && xls.changed < 3) + try + xlsout = java_new ("java.io.FileOutputStream", xls.filename); + bufout = java_new ("java.io.BufferedOutputStream", xlsout); + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.write (bufout); + bufout.flush (); + bufout.close (); + xlsout.close (); + xls.changed = 0; + catch +# xlsout.close (); + end_try_catch + endif - elseif (strcmp (xls.xtype, 'JXL')) - if (xls.changed > 0 && xls.changed < 3) - try - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.write (); - xls.workbook.close (); - if (xls.changed == 3) - # Upon entering write mode, JExcelAPI always makes a disk file - # Incomplete new files (no data added) had better be deleted. - xls.workbook.close (); - delete (xls.filename); - endif - xls.changed = 0; - catch - end_try_catch - endif + elseif (strcmp (xls.xtype, 'JXL')) + if (xls.changed > 0 && xls.changed < 3) + try + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.write (); + xls.workbook.close (); + if (xls.changed == 3) + # Upon entering write mode, JExcelAPI always makes a disk file + # Incomplete new files (no data added) had better be deleted. + xls.workbook.close (); + delete (xls.filename); + endif + xls.changed = 0; + catch + end_try_catch + endif - elseif (strcmp (xls.xtype, 'OXS')) - if (xls.changed > 0 && xls.changed < 3) - try - xlsout = java_new ("java.io.FileOutputStream", xls.filename); - bufout = java_new ("java.io.BufferedOutputStream", xlsout); - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.writeBytes (bufout); - xls.workbook.close (); - bufout.flush (); - bufout.close (); - xlsout.close (); - xls.changed = 0; - catch -# xlsout.close (); - end_try_catch - else - xls.workbook.close (); - endif + elseif (strcmp (xls.xtype, 'OXS')) + if (xls.changed > 0 && xls.changed < 3) + try + xlsout = java_new ("java.io.FileOutputStream", xls.filename); + bufout = java_new ("java.io.BufferedOutputStream", xlsout); + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.writeBytes (bufout); + xls.workbook.close (); + bufout.flush (); + bufout.close (); + xlsout.close (); + xls.changed = 0; + catch +# xlsout.close (); + end_try_catch + else + xls.workbook.close (); + endif - elseif (strcmp (xls.xtype, 'UNO')) - # Java & UNO bridge - try - if (xls.changed && xls.changed < 3) - # Workaround: - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); - xModel = xls.workbook.queryInterface (unotmp); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XModifiable'); - xModified = xModel.queryInterface (unotmp); - if (xModified.isModified ()) - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XStorable'); # isReadonly() ? - xStore = xls.app.xComp.queryInterface (unotmp); - if (xls.changed == 2) - # Some trickery as Octave Java cannot create non-numeric arrays - lProps = javaArray ('com.sun.star.beans.PropertyValue', 1); - lProp = java_new ('com.sun.star.beans.PropertyValue', "Overwrite", 0, true, []); - lProps(1) = lProp; - # OK, store file - xStore.storeAsURL (xls.filename, lProps); - else - xStore.store (); - endif - endif - endif - xls.changed = -1; # Needed for check on properly shutting down OOo - # Workaround: - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); - xModel = xls.app.xComp.queryInterface (unotmp); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XCloseable'); - xClosbl = xModel.queryInterface (unotmp); - xClosbl.close (true); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); - xDesk = xls.app.aLoader.queryInterface (unotmp); - xDesk.terminate(); - xls.changed = 0; - catch - if (force) - # Force closing OOo - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); - xDesk = xls.app.aLoader.queryInterface (unotmp); - xDesk.terminate(); - else - warning ("Error closing xls pointer (UNO)"); - endif - return - end_try_catch + elseif (strcmp (xls.xtype, 'UNO')) + # Java & UNO bridge + try + if (xls.changed && xls.changed < 3) + # Workaround: + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); + xModel = xls.workbook.queryInterface (unotmp); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XModifiable'); + xModified = xModel.queryInterface (unotmp); + if (xModified.isModified ()) + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XStorable'); # isReadonly() ? + xStore = xls.app.xComp.queryInterface (unotmp); + if (xls.changed == 2) + # Some trickery as Octave Java cannot create non-numeric arrays + lProps = javaArray ('com.sun.star.beans.PropertyValue', 1); + lProp = java_new ('com.sun.star.beans.PropertyValue', "Overwrite", 0, true, []); + lProps(1) = lProp; + # OK, store file + xStore.storeAsURL (xls.filename, lProps); + else + xStore.store (); + endif + endif + endif + xls.changed = -1; # Needed for check on properly shutting down OOo + # Workaround: + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); + xModel = xls.app.xComp.queryInterface (unotmp); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XCloseable'); + xClosbl = xModel.queryInterface (unotmp); + xClosbl.close (true); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); + xDesk = xls.app.aLoader.queryInterface (unotmp); + xDesk.terminate(); + xls.changed = 0; + catch + if (force) + # Force closing OOo + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); + xDesk = xls.app.aLoader.queryInterface (unotmp); + xDesk.terminate(); + else + warning ("Error closing xls pointer (UNO)"); + endif + return + end_try_catch -# elseif <other interfaces here> - - endif +# elseif <other interfaces here> + + endif - if (xls.changed && xls.changed < 3) - warning (sprintf ("File %s could not be saved. Read-only or in use elsewhere?\nFile pointer preserved.", xls.filename)); - if (force) - xls = []; - endif - else - xls = []; - endif + if (xls.changed && xls.changed < 3) + warning (sprintf ("File %s could not be saved. Read-only or in use elsewhere?\nFile pointer preserved.", xls.filename)); + if (force) + xls = []; + endif + else + xls = []; + endif endfunction Modified: trunk/octave-forge/main/io/inst/xlsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsopen.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/xlsopen.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -108,8 +108,11 @@ ## 2012-06-06 Improved interface detection logic. No more messages if same interface is ## requested & used consecutively ## 2012-06-07 Fixed mixed-up lastintf assignments for POI and JXL +## 2012-09-02 (in UNO section) web adresses need only two consecutive slashes +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) ## -## Latest subfunction update: 2012-06-06 +## Latest subfunction update: 2012-09-03 function [ xls ] = xlsopen (filename, xwrite=0, reqinterface=[]) @@ -327,12 +330,18 @@ if (xlsinterfaces.UNO && ~xlssupport) # First, the file name must be transformed into a URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) # Seems in proper shape for OOo (at first sight) else - # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); + # Transform into URL form. + ## FIXME make_absolute_filename() doesn't work across drive(-letters) so + ## until it is fixed we'll fall back on canonicalize_file_name() there + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif # On Windows, change backslash file separator into forward slash if (strcmp (filesep, "\\")) tmp = strsplit (fname, filesep); @@ -468,6 +477,7 @@ ## '' Improved logic for finding out what interfaces to check ## '' Fixed bugs with Java interface checking (tmp1 initialization) ## 2012-06-06 Improved & simplified Java check code +## 2012-09-03 Check for matching .jar names & javaclasspath was reversed (oops) function [xlsinterfaces] = getxlsinterfaces (xlsinterfaces) @@ -558,7 +568,7 @@ # under Windows we need the following more subtle, platform-independent approach: for ii=1:length (jcp) for jj=1:length (entries1) - if (isempty (strfind (tolower (jcp{ii}), entries1{jj}))), ++jpchk1; endif + if (~isempty (strfind (tolower (jcp{ii}), entries1{jj}))), ++jpchk1; endif endfor endfor if (jpchk1 > 1) @@ -569,7 +579,7 @@ jpchk2 = 0; entries2 = {"xbean", "poi-ooxml-schemas", "dom4j"}; for ii=1:length (jcp) for jj=1:length (entries2) - if (isempty (strfind (lower (jcp{ii}), entries2{jj}))), ++jpchk2; endif + if (~isempty (strfind (lower (jcp{ii}), entries2{jj}))), ++jpchk2; endif endfor endfor if (jpchk2 > 2), printf (" (& OOXML)"); endif @@ -584,7 +594,7 @@ jpchk = 0; entries = {"jxl"}; for ii=1:length (jcp) for jj=1:length (entries) - if (isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif + if (~isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif endfor endfor if (jpchk > 0) @@ -600,7 +610,7 @@ jpchk = 0; entries = {"openxls"}; for ii=1:length (jcp) for jj=1:length (entries) - if (isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif + if (~isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif endfor endfor if (jpchk > 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ean...@us...> - 2012-09-02 22:39:49
|
Revision: 10954 http://octave.svn.sourceforge.net/octave/?rev=10954&view=rev Author: eandrius Date: 2012-09-02 22:39:41 +0000 (Sun, 02 Sep 2012) Log Message: ----------- instrument-control: merged serial and i2c packages Added Paths: ----------- trunk/octave-forge/main/instrument-control/ trunk/octave-forge/main/instrument-control/COPYING trunk/octave-forge/main/instrument-control/DESCRIPTION trunk/octave-forge/main/instrument-control/INDEX trunk/octave-forge/main/instrument-control/NEWS trunk/octave-forge/main/instrument-control/PKG_ADD trunk/octave-forge/main/instrument-control/src/ trunk/octave-forge/main/instrument-control/src/Makefile trunk/octave-forge/main/instrument-control/src/i2c/ trunk/octave-forge/main/instrument-control/src/i2c/Makefile trunk/octave-forge/main/instrument-control/src/i2c/i2c.cc trunk/octave-forge/main/instrument-control/src/i2c/i2c.h trunk/octave-forge/main/instrument-control/src/i2c/i2c_addr.cc trunk/octave-forge/main/instrument-control/src/i2c/i2c_close.cc trunk/octave-forge/main/instrument-control/src/i2c/i2c_read.cc trunk/octave-forge/main/instrument-control/src/i2c/i2c_write.cc trunk/octave-forge/main/instrument-control/src/serial/ trunk/octave-forge/main/instrument-control/src/serial/Makefile trunk/octave-forge/main/instrument-control/src/serial/serial.cc trunk/octave-forge/main/instrument-control/src/serial/serial.h trunk/octave-forge/main/instrument-control/src/serial/srl_baudrate.cc trunk/octave-forge/main/instrument-control/src/serial/srl_bytesize.cc trunk/octave-forge/main/instrument-control/src/serial/srl_close.cc trunk/octave-forge/main/instrument-control/src/serial/srl_flush.cc trunk/octave-forge/main/instrument-control/src/serial/srl_parity.cc trunk/octave-forge/main/instrument-control/src/serial/srl_read.cc trunk/octave-forge/main/instrument-control/src/serial/srl_stopbits.cc trunk/octave-forge/main/instrument-control/src/serial/srl_timeout.cc trunk/octave-forge/main/instrument-control/src/serial/srl_write.cc Removed Paths: ------------- trunk/octave-forge/main/i2c/ trunk/octave-forge/main/serial/ Added: trunk/octave-forge/main/instrument-control/COPYING =================================================================== --- trunk/octave-forge/main/instrument-control/COPYING (rev 0) +++ trunk/octave-forge/main/instrument-control/COPYING 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. Added: trunk/octave-forge/main/instrument-control/DESCRIPTION =================================================================== --- trunk/octave-forge/main/instrument-control/DESCRIPTION (rev 0) +++ trunk/octave-forge/main/instrument-control/DESCRIPTION 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,11 @@ +Name: instrument-control +Version: 0.1.0 +Date: 2012-09-02 +Author: Andrius Sutas <and...@gm...> +Maintainer: Andrius Sutas <and...@gm...> +Title: Instrument Control Toolbox +Description: Low level I/O functions for serial, i2c and parallel interfaces. +Categories: instrument-control +Depends: octave (>= 3.2.0) +Autoload: no +License: LGPLv3+ Added: trunk/octave-forge/main/instrument-control/INDEX =================================================================== --- trunk/octave-forge/main/instrument-control/INDEX (rev 0) +++ trunk/octave-forge/main/instrument-control/INDEX 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,12 @@ +instrument-control >> Low level I/O functions + +Serial + serial + srl_read + srl_write + srl_close + +I2C + i2c + i2c_read + i2c_write Added: trunk/octave-forge/main/instrument-control/NEWS =================================================================== --- trunk/octave-forge/main/instrument-control/NEWS (rev 0) +++ trunk/octave-forge/main/instrument-control/NEWS 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,9 @@ +Summary of important user-visible changes for instrument-control 0.1.0: +------------------------------------------------------------------- + + ** Initial release + + ** Support for parallel port I/O + + ** The following functions are new: + parport Added: trunk/octave-forge/main/instrument-control/PKG_ADD =================================================================== --- trunk/octave-forge/main/instrument-control/PKG_ADD (rev 0) +++ trunk/octave-forge/main/instrument-control/PKG_ADD 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,18 @@ +# Serial +autoload ("srl_timeout", "instrument-control.oct"); +autoload ("serial", "instrument-control.oct"); +autoload ("srl_stopbits", "instrument-control.oct"); +autoload ("srl_read", "instrument-control.oct"); +autoload ("srl_parity", "instrument-control.oct"); +autoload ("srl_close", "instrument-control.oct"); +autoload ("srl_bytesize", "instrument-control.oct"); +autoload ("srl_write", "instrument-control.oct"); +autoload ("srl_flush", "instrument-control.oct"); +autoload ("srl_baudrate", "instrument-control.oct"); + +# I2C +autoload ("i2c_addr", "instrument-control.oct"); +autoload ("i2c", "instrument-control.oct"); +autoload ("i2c_read", "instrument-control.oct"); +autoload ("i2c_close", "instrument-control.oct"); +autoload ("i2c_write", "instrument-control.oct"); Added: trunk/octave-forge/main/instrument-control/src/Makefile =================================================================== --- trunk/octave-forge/main/instrument-control/src/Makefile (rev 0) +++ trunk/octave-forge/main/instrument-control/src/Makefile 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,12 @@ +OCT = instrument-control +SUBDIRS = i2c serial + +MKOCTFILE ?= mkoctfile + +all: + @for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done + $(MKOCTFILE) i2c/*.o serial/*.o -o $(OCT) + +clean: + @for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean; done + rm -f *.oct Added: trunk/octave-forge/main/instrument-control/src/i2c/Makefile =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/Makefile (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/Makefile 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,21 @@ +OCT := i2c.oct +OBJ := i2c.o i2c_close.o i2c_addr.o i2c_write.o i2c_read.o + +MKOCTFILE ?= mkoctfile + +all: $(OBJ) + +oct: $(OCT) + +%.oct: $(OBJ) + $(MKOCTFILE) $^ + +%.o: %.cc + $(MKOCTFILE) -c -s $< + + +clean: + rm -f *.oct *.o + + +.PHONY: all clean Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,122 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <linux/i2c-dev.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + +using std::string; + +#include "i2c.h" + +DEFINE_OCTAVE_ALLOCATOR (octave_i2c); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_i2c, "octave_i2c", "octave_i2c"); + +static bool type_loaded = false; + + + +DEFUN_DLD (helloworld, args, nargout, + "Hello World Help String") + { + int nargin = args.length (); + octave_stdout << "Hello World has " << nargin + << " input arguments and " + << nargout << " output arguments.\n"; + return octave_value_list (); + } + + +octave_i2c::octave_i2c() +{ + this->fd = -1; +} + +octave_i2c::octave_i2c(string path, int flags) +{ + this->fd = open(path.c_str(), flags, 0); +} + +octave_i2c::~octave_i2c() +{ + this->i2c_close(); +} + +int octave_i2c::i2c_get_fd() +{ + return this->fd; +} + +void octave_i2c::print (std::ostream& os, bool pr_as_read_syntax ) const +{ + print_raw(os, pr_as_read_syntax); + newline(os); +} + +void octave_i2c::print_raw (std::ostream& os, bool pr_as_read_syntax) const +{ + os << this->fd; +} + +// PKG_ADD: autoload ("i2c", "instrument-control.oct"); +DEFUN_DLD (i2c, args, nargout, "i2c() function has one mandatory output argument") +{ +#ifdef __WIN32__ + error("i2c: Windows platform support is not yet implemented, go away..."); + return octave_value(); +#endif + + int nargin = args.length(); + + // Default values + int oflags = O_RDWR; + string path("/dev/i2c-0"); + + // Do not open interface if return value is not assigned + if (nargout != 1) + { + print_usage(); + return octave_value(); + } + + // Open the interface + octave_i2c* retval = new octave_i2c(path, oflags); + + if (retval->i2c_get_fd() < 0) + { + error("i2c: Error opening the interface: %s\n", strerror(errno)); + return octave_value(); + } + + return octave_value(retval); +} Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c.h =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c.h (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c.h 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,72 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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/>. + +#ifndef i2c_H +#define i2c_H + +#include <octave/oct.h> +#include <octave/ov-int32.h> + +#include <string> + +using std::string; + +class octave_i2c : public octave_base_value +{ +public: + octave_i2c(); + octave_i2c(string, int); + ~octave_i2c(); + + int i2c_get_fd(); + int i2c_close(); + + int i2c_set_addr(int); + int i2c_get_addr(); + + // Simple i2c commands + int i2c_write(unsigned char*, int); + int i2c_read(char*, unsigned int); + + + // Overloaded base functions + double i2c_value() const + { + return (double)this->fd; + } + + virtual double scalar_value (bool frc_str_conv = false) const + { + return (double)this->fd; + } + + void print (std::ostream& os, bool pr_as_read_syntax = false) const; + void print_raw (std::ostream& os, bool pr_as_read_syntax) const; + + // Properties + bool is_constant (void) const { return true;} + bool is_defined (void) const { return true;} + bool print_as_scalar (void) const { return true;} + +private: + int fd; + int addr; + + DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA +}; + + +#endif Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c_addr.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c_addr.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c_addr.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,89 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <linux/i2c-dev.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + +#include "i2c.h" + +// PKG_ADD: autoload ("i2c_addr", "instrument-control.oct"); +DEFUN_DLD (i2c_addr, args, nargout, "Hello World Help String") +{ + if (args.length() > 2 || + args(0).type_id() != octave_i2c::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_i2c* i2c = NULL; + + const octave_base_value& rep = args(0).get_rep(); + i2c = &((octave_i2c &)rep); + + + // Setting new slave address + if (args.length() > 1) + { + if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) + { + print_usage(); + return octave_value(-1); + } + + i2c->i2c_set_addr(args(1).int_value()); + + return octave_value(); + } + + // Returning current slave address + return octave_value(i2c->i2c_get_addr()); +} + +int octave_i2c::i2c_set_addr(int addr) +{ + + if (::ioctl(i2c_get_fd(), I2C_SLAVE, addr) < 0) + { + error("i2c: Error setting slave address: %s\n", strerror(errno)); + return false; + } + + return true; +} + +int octave_i2c::i2c_get_addr() +{ + return this->addr; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c_close.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c_close.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c_close.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,66 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <linux/i2c-dev.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + +using std::string; + +#include "i2c.h" + +// PKG_ADD: autoload ("i2c_close", "instrument-control.oct"); +DEFUN_DLD (i2c_close, args, nargout, "Hello World Help String") +{ + if (args.length() != 1 || args(0).type_id() != octave_i2c::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_i2c* i2c = NULL; + + const octave_base_value& rep = args(0).get_rep(); + i2c = &((octave_i2c &)rep); + + i2c->i2c_close(); + + return octave_value(); +} + +int octave_i2c::i2c_close() +{ + int retval = ::close(this->i2c_get_fd()); + this->fd = -1; + return retval; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c_read.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c_read.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c_read.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,101 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <linux/i2c-dev.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + + +#include "i2c.h" + +// PKG_ADD: autoload ("i2c_read", "instrument-control.oct"); +DEFUN_DLD (i2c_read, args, nargout, "Hello World Help String") +{ + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_i2c::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + char *buffer = NULL; + unsigned int buffer_len = 1; + + if (args.length() > 1) + { + if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) + { + print_usage(); + return octave_value(-1); + } + + buffer_len = args(1).int_value(); + } + + buffer = new char [buffer_len + 1]; + + if (buffer == NULL) + { + error("i2c_read: cannot allocate requested memory..."); + return octave_value(-1); + } + + octave_i2c* i2c = NULL; + + const octave_base_value& rep = args(0).get_rep(); + i2c = &((octave_i2c &)rep); + + int retval; + + retval = i2c->i2c_read(buffer, buffer_len); + + octave_value_list return_list; + uint8NDArray data(retval); + + for (int i = 0; i < retval; i++) + data(i) = buffer[i]; + + return_list(1) = retval; + return_list(0) = data; + + delete[] buffer; + + return return_list; +} + +int octave_i2c::i2c_read(char *buf, unsigned int len) +{ + int retval = ::read(i2c_get_fd(), buf, len); + + if (retval != len) + error("i2c: Failed to read from the i2c bus: %s\n", strerror(errno)); + + return retval; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/i2c/i2c_write.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/i2c/i2c_write.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/i2c/i2c_write.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,90 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <linux/i2c-dev.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + + +#include "i2c.h" + +// PKG_ADD: autoload ("i2c_write", "instrument-control.oct"); +DEFUN_DLD (i2c_write, args, nargout, "Hello World Help String") +{ + if (args.length() != 2 || args(0).type_id() != octave_i2c::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_i2c* i2c = NULL; + + const octave_base_value& rep = args(0).get_rep(); + i2c = &((octave_i2c &)rep); + + const octave_base_value& data = args(1).get_rep(); + int retval; + + if (data.is_string()) + { + string buf = data.string_value(); + retval = i2c->i2c_write((unsigned char*)buf.c_str(), buf.length()); + } + else if (data.byte_size() == data.numel()) + { + NDArray dtmp = data.array_value(); + unsigned char* buf = new unsigned char [dtmp.length()]; + + for (int i = 0; i < dtmp.length(); i++) + buf[i] = (unsigned char)dtmp(i); + + retval = i2c->i2c_write(buf, data.byte_size()); + + delete[] buf; + } + else + { + print_usage(); + return octave_value(-1); + } + + return octave_value(retval); +} + +int octave_i2c::i2c_write(unsigned char *buf, int len) +{ + int retval = ::write(i2c_get_fd(), buf, len); + + if (retval < 0) + error("i2c: Failed to write to the i2c bus: %s\n", strerror(errno)); + + return retval; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/Makefile =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/Makefile (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/Makefile 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,21 @@ +OCT := serial.oct +OBJ := serial.o srl_baudrate.o srl_timeout.o srl_bytesize.o srl_flush.o \ + srl_parity.o srl_stopbits.o srl_write.o srl_close.o srl_read.o + +MKOCTFILE ?= mkoctfile + +all: $(OBJ) + +oct: $(OCT) + +%.oct: $(OBJ) + $(MKOCTFILE) $^ + +%.o: %.cc + $(MKOCTFILE) -c -s $< + +clean: + rm -f *.oct *.o + + +.PHONY: all clean Added: trunk/octave-forge/main/instrument-control/src/serial/serial.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/serial.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/serial.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,187 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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/>. + +// TODO: Implement Flow Control +// TODO: Implement H/W handshaking +// TODO: Check if interface is opened first + +#include <octave/oct.h> +#include <octave/ov-int32.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +DEFINE_OCTAVE_ALLOCATOR (octave_serial); +DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_serial, "octave_serial", "octave_serial"); + +static bool type_loaded = false; + +octave_serial::octave_serial() +{ + this->fd = -1; +} + +octave_serial::octave_serial(string path, int flags) +{ + this->fd = open(path.c_str(), flags, 0); + + if (this->fd > 0) + { + tcgetattr(this->fd, &this->config); + this->blocking_read = true; + } +} + +octave_serial::~octave_serial() +{ + this->close(); +} + +void octave_serial::print (std::ostream& os, bool pr_as_read_syntax ) const +{ + print_raw(os, pr_as_read_syntax); + newline(os); +} + +void octave_serial::print_raw (std::ostream& os, bool pr_as_read_syntax) const +{ + os << this->fd; +} + +// PKG_ADD: autoload ("serial", "instrument-control.oct"); +DEFUN_DLD (serial, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {@var{serial} = } serial ([@var{path}], [@var{baudrate}], [@var{timeout}])\n \ +\n\ +Open serial interface.\n \ +\n\ +@var{path} - the interface path of type String. If omitted defaults to '/dev/ttyUSB0'. @*\ +@var{baudrate} - the baudrate of interface. If omitted defaults to 115200. @*\ +@var{timeout} - the interface timeout value. If omitted defaults to blocking call.\n \ +\n\ +The serial() shall return instance of @var{octave_serial} class as the result @var{serial}.\n \ +@end deftypefn") +{ +#ifdef __WIN32__ + error("serial: Windows platform support is not yet implemented, go away..."); + return octave_value(); +#endif + + int nargin = args.length(); + + // Do not open interface if return value is not assigned + if (nargout != 1) + { + print_usage(); + return octave_value(); + } + + // Default values + string path("/dev/ttyUSB0"); + unsigned int baud_rate = 115200; + short timeout = -1; + + unsigned short bytesize = 8; + string parity("N"); + unsigned short stopbits = 1; + int oflags = O_RDWR | O_NOCTTY | O_SYNC; + // O_SYNC - All writes immediately effective, no buffering + + if (!type_loaded) + { + octave_serial::register_type(); + type_loaded = true; + } + + // Parse the function arguments + if (args.length() > 0) + { + if (args(0).is_string()) + { + path = args(0).string_value(); + } + else + { + print_usage(); + return octave_value(); + } + + } + + // is_float_type() is or'ed to allow expression like ("", 123), without user + // having to use ("", int32(123)), as we still only take "int_value" + if (args.length() > 1) + { + if (args(1).is_integer_type() || args(1).is_float_type()) + { + baud_rate = args(1).int_value(); + } + else + { + print_usage(); + return octave_value(); + } + } + + if (args.length() > 2) + { + if (args(2).is_integer_type() || args(2).is_float_type()) + { + timeout = args(2).int_value(); + } + else + { + print_usage(); + return octave_value(); + } + } + + // Open the interface + octave_serial* retval = new octave_serial(path, oflags); + + if (retval->get_fd() < 0) + { + error("serial: Error opening the interface: %s\n", strerror(errno)); + return octave_value(); + } + + retval->set_baudrate(baud_rate); + + if (timeout >= 0) { + retval->set_timeout(timeout); + } + + retval->set_parity(parity); + retval->set_bytesize(bytesize); + retval->set_stopbits(stopbits); + + //retval->flush(2); + + return octave_value(retval); +} Added: trunk/octave-forge/main/instrument-control/src/serial/serial.h =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/serial.h (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/serial.h 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,89 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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/>. + +#ifndef SERIAL_H +#define SERIAL_H + +#include <octave/oct.h> +#include <octave/ov-int32.h> + +#include <string> + +#define BITMASK_SET(x,y) ((x) |= (y)) +#define BITMASK_CLEAR(x,y) ((x) &= (~(y))) +#define BITMASK_TOGGLE(x,y) ((x) ^= (y)) +#define BITMASK_CHECK(x,y) ((x) & (y)) + +class octave_serial : public octave_base_value +{ +public: + octave_serial(); + octave_serial(string, int); + ~octave_serial(); + + int write(string); + int write(unsigned char*, int); + + int read(char *, unsigned int); + + int close(); + + int flush(unsigned short); + + int set_timeout(short); + int get_timeout(); + + int set_baudrate(unsigned int); + int get_baudrate(); + + int set_bytesize(unsigned short); + int get_bytesize(); + + int set_parity(string); + string get_parity(); + + int set_stopbits(unsigned short); + int get_stopbits(); + + int get_fd() { return this->fd; } + + // Overloaded base functions + double serial_value() const { return (double)this->fd; } + + virtual double scalar_value (bool frc_str_conv = false) const + { + return (double)this->fd; + } + + void print (std::ostream& os, bool pr_as_read_syntax = false) const; + void print_raw (std::ostream& os, bool pr_as_read_syntax) const; + + // Properties + bool is_constant (void) const { return true;} + bool is_defined (void) const { return true;} + bool print_as_scalar (void) const { return true;} + +private: + int fd; + struct termios config; + + bool blocking_read; + + DECLARE_OCTAVE_ALLOCATOR + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA +}; + + +#endif Added: trunk/octave-forge/main/instrument-control/src/serial/srl_baudrate.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_baudrate.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_baudrate.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,193 @@ +#include <octave/oct.h> +#include <octave/ov-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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 <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +// PKG_ADD: autoload ("srl_baudrate", "instrument-control.oct"); +DEFUN_DLD (srl_baudrate, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_baudrate (@var{serial}, @var{baudrate})\n \ +@deftypefnx {Loadable Function} {@var{br} = } srl_baudrate (@var{serial})\n \ +\n\ +Set new or get existing serial interface baudrate parameter. Only standard values are supported.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{baudrate} - the baudrate value used. Supported values: 0, 50, 75, 110, \ +134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600 19200, 38400, 57600, \ +115200 and 230400.\n \ +\n\ +If @var{baudrate} parameter is omitted, the srl_baudrate() shall return current baudrate value as the result @var{br}.\n \ +@end deftypefn") +{ + if (args.length() < 1 || args.length() > 2 || + args(0).type_id() != octave_serial::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + + // Setting new baudrate + if (args.length() > 1) + { + if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) + { + error("srl_baudrate: expecting second argument of type integer..."); + return octave_value(-1); + } + + serial->set_baudrate(args(1).int_value()); + + return octave_value(); + } + + // Returning current baud rate + return octave_value(serial->get_baudrate()); +} + +int octave_serial::set_baudrate(unsigned int baud) +{ + speed_t baud_rate = 0; + + switch (baud) + { + case 0: + baud_rate = B0; break; + case 50: + baud_rate = B50; break; + case 75: + baud_rate = B75; break; + case 110: + baud_rate = B110; break; + case 134: + baud_rate = B134; break; + case 150: + baud_rate = B150; break; + case 200: + baud_rate = B200; break; + case 300: + baud_rate = B300; break; + case 600: + baud_rate = B600; break; + case 1200: + baud_rate = B1200; break; + case 1800: + baud_rate = B1800; break; + case 2400: + baud_rate = B2400; break; + case 4800: + baud_rate = B4800; break; + case 9600: + baud_rate = B9600; break; + case 19200: + baud_rate = B19200; break; + case 38400: + baud_rate = B38400; break; + case 57600: + baud_rate = B57600; break; + case 115200: + baud_rate = B115200; break; + case 230400: + baud_rate = B230400; break; + default: + error("srl_baudrate: currently only 0, 50, 75, 110, \ + 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, \ + 9600 19200, 38400, 57600, 115200 and 230400 baud rates are supported..."); + return false; + } + + cfsetispeed(&this->config, baud_rate); + cfsetospeed(&this->config, baud_rate); + + if (tcsetattr(this->get_fd(), TCSANOW, &this->config) < 0) { + error("srl_baudrate: error setting baud rate: %s\n", strerror(errno)); + return false; + } + + return true; +} + +int octave_serial::get_baudrate() +{ + int retval = -1; + + speed_t baudrate = cfgetispeed(&this->config); + + if (baudrate == B0) + retval = 0; + else if (baudrate == B50) + retval = 50; + else if (baudrate == B75) + retval = 75; + else if (baudrate == B110) + retval = 110; + else if (baudrate == B134) + retval = 134; + else if (baudrate == B150) + retval = 150; + else if (baudrate == B200) + retval = 200; + else if (baudrate == B300) + retval = 300; + else if (baudrate == B600) + retval = 600; + else if (baudrate == B1200) + retval = 1200; + else if (baudrate == B1800) + retval = 1800; + else if (baudrate == B2400) + retval = 2400; + else if (baudrate == B4800) + retval = 4800; + else if (baudrate == B9600) + retval = 9600; + else if (baudrate == B19200) + retval = 19200; + else if (baudrate == B38400) + retval = 38400; + else if (baudrate == B57600) + retval = 57600; + else if (baudrate == B115200) + retval = 115200; + else if (baudrate == B230400) + retval = 230400; + + return retval; + +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/srl_bytesize.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_bytesize.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_bytesize.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,125 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +// PKG_ADD: autoload ("srl_bytesize", "instrument-control.oct"); +DEFUN_DLD (srl_bytesize, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_bytesize (@var{serial}, @var{bsize})\n \ +@deftypefnx {Loadable Function} {@var{bs} = } srl_bytesize (@var{serial})\n \ +\n\ +Set new or get existing serial interface byte size parameter.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{bsize} - byte size of type Integer. Supported values: 5/6/7/8.\n \ +\n\ +If @var{bsize} parameter is omitted, the srl_bytesize() shall return current byte size value or in case of unsupported setting -1, as the result @var{bs}.\n \ +@end deftypefn") +{ + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + + // Setting new byte size + if (args.length() > 1) + { + if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) + { + print_usage(); + return octave_value(-1); + } + + serial->set_bytesize(args(1).int_value()); + + return octave_value(); + } + + // Returning current byte size + return octave_value(serial->get_bytesize()); +} + +int octave_serial::set_bytesize(unsigned short bytesize) +{ + tcflag_t c_bytesize = 0; + + switch (bytesize) + { + case 5: c_bytesize = CS5; break; + case 6: c_bytesize = CS6; break; + case 7: c_bytesize = CS7; break; + case 8: c_bytesize = CS8; break; + + default: + error("srl_bytesize: expecting value between [5..8]..."); + return false; + } + + // Clear bitmask CSIZE + BITMASK_CLEAR(this->config.c_cflag, CSIZE); + + // Apply new + BITMASK_SET(this->config.c_cflag, c_bytesize); + + if (tcsetattr(this->get_fd(), TCSANOW, &this->config) < 0) { + error("srl_bytesize: error setting byte size: %s\n", strerror(errno)); + return false; + } + + return true; +} + +int octave_serial::get_bytesize() +{ + int retval = -1; + + if (BITMASK_CHECK(this->config.c_cflag, CS5)) + retval = 5; + else if (BITMASK_CHECK(this->config.c_cflag, CS6)) + retval = 6; + else if (BITMASK_CHECK(this->config.c_cflag, CS7)) + retval = 7; + else if (BITMASK_CHECK(this->config.c_cflag, CS8)) + retval = 8; + + return retval; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/srl_close.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_close.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_close.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,67 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +// PKG_ADD: autoload ("srl_close", "instrument-control.oct"); +DEFUN_DLD (srl_close, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_close (@var{serial})\n \ +\n\ +Close the interface and release a file descriptor.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@end deftypefn") +{ + if (args.length() != 1 || args(0).type_id() != octave_serial::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + + serial->close(); + + return octave_value(); +} + +int octave_serial::close() +{ + int retval = ::close(this->get_fd()); + this->fd = -1; + return retval; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/srl_flush.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_flush.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_flush.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,100 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +// PKG_ADD: autoload ("srl_flush", "instrument-control.oct"); +DEFUN_DLD (srl_flush, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_flush (@var{serial}, [@var{q}])\n \ +\n\ +Flush the pending input/output.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{q} - queue selector of type Integer. Supported values: 0 - flush untransmitted output, \ +1 - flush pending input, 2 - flush both pending input and untransmitted output.\n \ +\n\ +If @var{q} parameter is omitted, the srl_flush() shall flush both, input and output buffers.\n \ +@end deftypefn") +{ + int queue_selector = 2; // Input and Output + + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + if (args.length() > 1) + { + if (!(args(1).is_integer_type() || args(1).is_float_type())) + { + print_usage(); + return octave_value(-1); + } + + queue_selector = args(1).int_value(); + } + + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + + serial->flush(queue_selector); + + return octave_value(); +} + +int octave_serial::flush(unsigned short queue_selector) +{ + /* + * TCIOFLUSH Flush both pending input and untransmitted output. + * TCOFLUSH Flush untransmitted output. + * TCIFLUSH Flush pending input. + */ + + int flag; + + switch (queue_selector) + { + case 0: flag = TCOFLUSH; break; + case 1: flag = TCIFLUSH; break; + case 2: flag = TCIOFLUSH; break; + default: + error("srl_flush: only [0..2] values are accepted..."); + return false; + } + + return ::tcflush(this->get_fd(), flag); +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/srl_parity.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_parity.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_parity.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,136 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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-int32.h> +//#include <octave/ops.h> +//#include <octave/ov-typeinfo.h> + +#include <iostream> +#include <string> +#include <algorithm> + +#ifndef __WIN32__ +#include <stdio.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <termios.h> +#include <unistd.h> +#endif + +using std::string; + +#include "serial.h" + +// PKG_ADD: autoload ("srl_parity", "instrument-control.oct"); +DEFUN_DLD (srl_parity, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_parity (@var{serial}, @var{parity})\n \ +@deftypefnx {Loadable Function} {@var{p} = } srl_parity (@var{serial})\n \ +\n\ +Set new or get existing serial interface parity parameter. Even/Odd/None values are supported.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{parity} - parity value of type String. Supported values: Even/Odd/None (case insensitive, can be abbreviated to the first letter only).\n \ +\n\ +If @var{parity} parameter is omitted, the srl_parity() shall return current parity value as the result @var{p}.\n \ +@end deftypefn") +{ + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) + { + print_usage(); + return octave_value(-1); + } + + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + + // Setting new parity + if (args.length() > 1) + { + if ( !(args(1).is_string()) ) + { + print_usage(); + return octave_value(-1); + } + + serial->set_parity(args(1).string_value()); + + return octave_value(); + } + + // Returning current parity + return octave_value(serial->get_parity()); +} + +int octave_serial::set_parity(string parity) +{ + // Convert string to lowercase + std::transform(parity.begin(), parity.end(), parity.begin(), ::tolower); + + /* + * PARENB Enable parity generation on output and parity checking for input. + * PARODD If set, then parity for input and output is odd; otherwise even parity is used. + */ + + if (parity == "n" || parity == "none") + { + // Disable parity generation/checking + BITMASK_CLEAR(this->config.c_cflag, PARENB); + } + else if (parity == "e" || parity == "even") + { + // Enable parity generation/checking + BITMASK_SET(this->config.c_cflag, PARENB); + + // Set to Even + BITMASK_CLEAR(this->config.c_cflag, PARODD); + + } + else if (parity == "o" || parity == "odd") + { + // Enable parity generation/checking + BITMASK_SET(this->config.c_cflag, PARENB); + + // Set to Odd + BITMASK_SET(this->config.c_cflag, PARODD); + + } + else + { + error("srl_parity: Only [N]one, [E]ven or [O]dd parities are supported..."); + return false; + } + + if (tcsetattr(this->get_fd(), TCSANOW, &this->config) < 0) { + error("srl_parity: error setting parity: %s\n", strerror(errno)); + return false; + } + + return true; +} + +string octave_serial::get_parity() +{ + if (!BITMASK_CHECK(this->config.c_cflag, PARENB)) + return "None"; + else if (BITMASK_CHECK(this->config.c_cflag, PARODD)) + return "Odd"; + else + return "Even"; +} \ No newline at end of file Added: trunk/octave-forge/main/instrument-control/src/serial/srl_read.cc =================================================================== --- trunk/octave-forge/main/instrument-control/src/serial/srl_read.cc (rev 0) +++ trunk/octave-forge/main/instrument-control/src/serial/srl_read.cc 2012-09-02 22:39:41 UTC (rev 10954) @@ -0,0 +1,110 @@ +// Copyright (C) 2012 Andrius Sutas <and...@gm...> +// +// 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 progra... [truncated message content] |
From: <cd...@us...> - 2012-09-02 18:04:14
|
Revision: 10953 http://octave.svn.sourceforge.net/octave/?rev=10953&view=rev Author: cdf Date: 2012-09-02 18:04:08 +0000 (Sun, 02 Sep 2012) Log Message: ----------- cleanup Modified Paths: -------------- trunk/octave-forge/extra/bim/doc/fiume.geo trunk/octave-forge/extra/bim/inst/bim3c_mesh_properties.m Modified: trunk/octave-forge/extra/bim/doc/fiume.geo =================================================================== --- trunk/octave-forge/extra/bim/doc/fiume.geo 2012-09-02 18:02:13 UTC (rev 10952) +++ trunk/octave-forge/extra/bim/doc/fiume.geo 2012-09-02 18:04:08 UTC (rev 10953) @@ -1,116 +1,22 @@ -Point (1) = {0, 0, 0, 0.1}; -Point (2) = {1, 1, 0, 0.1}; -Point (3) = {0.2, 0.1, 0, 0.1}; -Point (4) = {0.3, 0.3, 0, 0.1}; -Point (5) = {0.3, 0.5, 0, 0.1}; -Point (6) = {0.5, 0.6, 0, 0.1}; -Point (7) = {0.7, 0.7, 0, 0.1}; -Point (8) = {0.9, 0.8, 0, 0.1}; -Point (9) = {1, 0.9, 0, 0.1}; -Point (10) = {0.9, 1, 0, 0.1}; -Point (11) = {0.8, 0.9, 0, 0.1}; -Point (12) = {0.6, 0.8, 0, 0.1}; -Point (13) = {0.4, 0.7, 0, 0.1}; -Point (14) = {0.3, 0.6, 0, 0.1}; -Point (15) = {0.2, 0.5, 0, 0.1}; -Point (16) = {0.2, 0.3, 0, 0.1}; -Point (17) = {0.1, 0.2, 0, 0.1}; -Point (18) = {0, 0.1, 0, 0.1}; -Line (1) = {1, 3}; -Line (2) = {3, 4}; -Line (3) = {4, 5}; -Line (4) = {5, 6}; -Line (5) = {6, 7}; -Line (6) = {7, 8}; -Line (7) = {8, 9}; -Line (8) = {9, 2}; -Line (9) = {2, 10}; -Line (10) = {10, 11}; -Line (11) = {11, 12}; -Line (12) = {12, 13}; -Line (13) = {13, 14}; -Line (14) = {14, 15}; -Line (15) = {15, 16}; -Line (16) = {16, 17}; -Line (17) = {17, 18}; -Line (18) = {18, 1}; -Line Loop(19) = {5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,2,3,4}; -Plane Surface(20) = {19}; -Delete { - Surface{20}; -} -Delete { - Line{9,10,11,12,13,14,15,16,17,1,2,3,4,5,6,7}; -} -BSpline(20) = {1,3,4,5,6,7,8,9}; -Delete { - Line{20}; -} -CatmullRom(20) = {1,3,4,5,6,7,8,9}; -CatmullRom(21) = {2,10,11,12,13,14,15,16,17,18}; -Delete { - Line{21}; -} -Delete { - Point{10}; -} -CatmullRom(21) = {2,11,12,13,14,15,16,17,18}; -Translate {0,0,1} { - Duplicata { Point{14}; } -} -Delete { - Point{19}; -} -Delete { - Point{14}; -} -Delete { - Point{14}; -} -Delete { - Line{21}; -} -Delete { - Point{14}; -} -CatmullRom(21) = {2,11,12,13,15,16,17,18}; -Line Loop(22) = {20,8,21,18}; -Plane Surface(23) = {22}; -Delete { - Surface{23}; -} -Delete { - Line{20}; -} -Delete { - Line{21}; -} -Delete { - Point{11,8,12,7}; -} -Delete { - Point{13,6}; -} -Delete { - Point{5,15}; -} -Delete { - Point{16,4}; -} -Delete { - Point{3,17}; -} -Point(19) = {0.3,0.1,-0,0.1}; -Point(20) = {0.4,0.4,-0,0.1}; -Point(21) = {0.5,0.6,0,0.1}; -Point(22) = {0.6,0.9,0,0.1}; -Point(23) = {0.8,0.8,0,0.1}; -Point(24) = {0.2,0.2,-0,0.1}; -Point(25) = {0.3,0.5,0,0.1}; -Point(26) = {0.4,0.7,0,0.1}; -Point(27) = {0.5,1,0,0.1}; -Point(28) = {0.8,0.9,0,0.1}; -CatmullRom(23) = {1,19,20,21,22,23,9}; -CatmullRom(24) = {18,24,25,26,27,28,2}; -Line Loop(25) = {23,8,-24,18}; -Plane Surface(26) = {25}; +Point (1) = {0, 0, 0, 0.1}; +Point (2) = {1, 1, 0, 0.1}; +Point (3) = {1, 0.9, 0, 0.1}; +Point (4) = {0, 0.1, 0, 0.1}; +Point (5) = {0.3,0.1,-0,0.1}; +Point (6) = {0.4,0.4,-0,0.1}; +Point (7) = {0.5,0.6,0,0.1}; +Point (8) = {0.6,0.9,0,0.1}; +Point (9) = {0.8,0.8,0,0.1}; +Point (10) = {0.2,0.2,-0,0.1}; +Point (11) = {0.3,0.5,0,0.1}; +Point (12) = {0.4,0.7,0,0.1}; +Point (13) = {0.5,1,0,0.1}; +Point (14) = {0.8,0.9,0,0.1}; + +Line (1) = {3, 2}; +Line (2) = {4, 1}; + +CatmullRom(3) = {1,5,6,7,8,9,3}; +CatmullRom(4) = {4,10,11,12,13,14,2}; +Line Loop(15) = {3,1,-4,2}; +Plane Surface(16) = {15}; Modified: trunk/octave-forge/extra/bim/inst/bim3c_mesh_properties.m =================================================================== --- trunk/octave-forge/extra/bim/inst/bim3c_mesh_properties.m 2012-09-02 18:02:13 UTC (rev 10952) +++ trunk/octave-forge/extra/bim/inst/bim3c_mesh_properties.m 2012-09-02 18:04:08 UTC (rev 10953) @@ -29,29 +29,28 @@ ## @seealso{bim3a_reaction, bim3a_rhs, bim3a_laplacian} ## @end deftypefn -function [omesh] = bim3c_mesh_properties(imesh) +function [omesh] = bim3c_mesh_properties (imesh) ## Check input if nargin != 1 error("bim3c_mesh_properties: wrong number of input parameters."); - elseif !(isstruct(imesh) && isfield(imesh,"p") && - isfield (imesh,"t") && isfield(imesh,"e")) - error("bim3c_mesh_properties: first input is not a valid mesh structure."); + elseif (! isstruct (imesh) || any (! isfield (imesh, {"p", "e", "t"}))) + error ("bim3c_mesh_properties: first input is not a valid mesh structure."); endif ## Compute properties omesh = imesh; - [omesh.wjacdet,omesh.area,omesh.shg,omesh.shp] = \ - msh3m_geometrical_properties(imesh,"wjacdet","area","shg","shp"); + [omesh.wjacdet,omesh.area,omesh.shg,omesh.shp] = ... + msh3m_geometrical_properties (imesh, "wjacdet", "area", "shg", "shp"); endfunction %!shared mesh % x = y = z = linspace(0,1,4); -% [mesh] = msh3m_structured_mesh(x,y,z,1,1:6); -% [mesh] = bim3c_mesh_properties(mesh); +% mesh = msh3m_structured_mesh(x,y,z,1,1:6); +% mesh = bim3c_mesh_properties (mesh); %!test -% tmp = msh3m_geometrical_properties(mesh,"wjacdet"); +% tmp = msh3m_geometrical_properties (mesh, "wjacdet"); % assert(mesh.wjacdet,tmp); %!test % tmp = msh3m_geometrical_properties(mesh,"shg"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-09-02 18:02:19
|
Revision: 10952 http://octave.svn.sourceforge.net/octave/?rev=10952&view=rev Author: cdf Date: 2012-09-02 18:02:13 +0000 (Sun, 02 Sep 2012) Log Message: ----------- simple overloaded method Modified Paths: -------------- trunk/octave-forge/extra/nurbs/src/tbasisfun.cc Modified: trunk/octave-forge/extra/nurbs/src/tbasisfun.cc =================================================================== --- trunk/octave-forge/extra/nurbs/src/tbasisfun.cc 2012-09-02 18:00:49 UTC (rev 10951) +++ trunk/octave-forge/extra/nurbs/src/tbasisfun.cc 2012-09-02 18:02:13 UTC (rev 10952) @@ -87,6 +87,8 @@ return; } +void onebasisfun__ (double u, double p, RowVector U, double *N) +{ onebasisfun__ (u, static_cast<octave_idx_type> (p), U, N); } void onebasisfunder__ (double u, octave_idx_type p, RowVector U, double *N, double *Nder) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-09-02 18:00:56
|
Revision: 10951 http://octave.svn.sourceforge.net/octave/?rev=10951&view=rev Author: cdf Date: 2012-09-02 18:00:49 +0000 (Sun, 02 Sep 2012) Log Message: ----------- prepare for release Modified Paths: -------------- trunk/octave-forge/extra/msh/DESCRIPTION trunk/octave-forge/extra/msh/inst/msh3m_gmsh.m trunk/octave-forge/extra/msh/inst/msh3m_structured_mesh.m Modified: trunk/octave-forge/extra/msh/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/msh/DESCRIPTION 2012-09-02 03:52:17 UTC (rev 10950) +++ trunk/octave-forge/extra/msh/DESCRIPTION 2012-09-02 18:00:49 UTC (rev 10951) @@ -1,13 +1,12 @@ Name: msh -Version: 1.0.2 -Date: 2010-04-04 +Version: 1.0.4 +Date: 2012-08-2 Author: Carlo de Falco, Massimiliano Culpo Maintainer: Carlo de Falco, Massimiliano Culpo Title: MeSHing software package for octave Description: Create and manage triangular and tetrahedral meshes for Finite Element or Finite Volume PDE solvers. Use a mesh data structure compatible with PDEtool. Rely on gmsh for unstructured mesh generation. Depends: octave (>= 3.0), splines -SystemRequirements: gmsh (>= 1.6.5), awk +SystemRequirements: gmsh (>= 1.6.5 (optional)), awk (optional) Autoload: no License: GPL version 2 or later Url: http://octave.sf.net, http://www.geuz.org/gmsh -SVNRelease: 7154 \ No newline at end of file Modified: trunk/octave-forge/extra/msh/inst/msh3m_gmsh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/msh3m_gmsh.m 2012-09-02 03:52:17 UTC (rev 10950) +++ trunk/octave-forge/extra/msh/inst/msh3m_gmsh.m 2012-09-02 18:00:49 UTC (rev 10951) @@ -21,7 +21,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{mesh}]} = @ -## msh3m_gmsh(@var{geometry},@var{option},@var{value},...) +## msh3m_gmsh(@var{geometry}, @var{option}, @var{value}, ...) ## ## Construct an unstructured tetrahedral 3D mesh making use of the free ## software gmsh. @@ -39,11 +39,11 @@ ## @seealso{msh3m_structured_mesh, msh2m_gmsh, msh2m_mesh_along_spline} ## @end deftypefn -function [mesh] = msh3m_gmsh(geometry,varargin) +function mesh = msh3m_gmsh (geometry, varargin) ## Check input ## Number of input - if !mod(nargin,2) + if !(mod (nargin,2)) warning("WRONG NUMBER OF INPUT."); print_usage; endif Modified: trunk/octave-forge/extra/msh/inst/msh3m_structured_mesh.m =================================================================== --- trunk/octave-forge/extra/msh/inst/msh3m_structured_mesh.m 2012-09-02 03:52:17 UTC (rev 10950) +++ trunk/octave-forge/extra/msh/inst/msh3m_structured_mesh.m 2012-09-02 18:00:49 UTC (rev 10951) @@ -73,14 +73,14 @@ ## msh3m_join_structured_mesh, msh3m_submesh} ## @end deftypefn -function [mesh] = msh3m_structured_mesh(x,y,z,region,sides) +function mesh = msh3m_structured_mesh (x, y, z, region, sides) ## Check input if (nargin != 5) # Number of input parameters - error("msh3m_structured_mesh: wrong number of input parameters."); - elseif !(isvector(x) && isnumeric(x) && - isvector(y) && isnumeric(y) && - isvector(z) && isnumeric(z) ) + print_usage (); + elseif !(isvector(x) && isnumeric(x) + && isvector(y) && isnumeric(y) + && isvector(z) && isnumeric(z)) error("msh3m_structured_mesh: X, Y, Z must be valid numeric vectors."); elseif !isscalar(region) error("msh3m_structured_mesh: REGION must be a valid scalar."); @@ -90,86 +90,94 @@ ## Build mesh ## Sort point coordinates - x = sort(x); - y = sort(y); - z = sort(z); + x = sort (x); + y = sort (y); + z = sort (z); ## Compute # of points in each direction - nx = length(x); - ny = length(y); - nz = length(z); + nx = length (x); + ny = length (y); + nz = length (z); ## Generate vertices - [XX,YY,ZZ] = meshgrid(x,y,z); - p = [XX(:),YY(:),ZZ(:)]'; + [XX, YY, ZZ] = meshgrid (x, y, z); + p = [XX(:), YY(:), ZZ(:)]'; - iiv (ny,nx,nz)=0; - iiv(:)=1:nx*ny*nz; - iiv(end,:,:)=[]; - iiv(:,end,:)=[]; - iiv(:,:,end)=[]; - iiv=iiv(:)'; + [t, e] = __t6_connections__ (nx, ny, nz); + ## Assemble structure + mesh = struct ('p', p, 'e', e, 't', t); + mesh.e (9,:) = region; + mesh.t (5,:) = region; + +endfunction + +function [t, e] = __t6_connections__ (nx, ny, nz) + ## Generate connections: + iiv = reshape (1:nx*ny*nz, [ny, nx, nz]); + iiv(end,:,:) = []; + iiv(:,end,:) = []; + iiv(:,:,end) = []; + iiv = iiv(:)'; + n1 = iiv; # bottom faces n2 = iiv + 1; n3 = iiv + ny; n4 = iiv + ny + 1; - + N1 = iiv + nx * ny; # top faces N2 = N1 + 1; N3 = N1 + ny; N4 = N3 + 1; - t = [... - [n1; n3; n2; N2],... + t = [[n1; n3; n2; N2],... [N1; N2; N3; n3],... [N1; N2; n3; n1],... [N2; n3; n2; n4],... [N3; n3; N2; N4],... - [N4; n3; N2; n4],... - ]; + [N4; n3; N2; n4]]; ## Generate boundary face list ## left - T = t; - T(:) = p(1,t)'==x(1); - [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + T = t; + T(:) = p(1, t)' == x(1); + [~, order] = sort (T, 1); + ii = (find(sum(T,1)==3)); order(1,:) = []; - for jj=1:length(ii) - e1(:,jj) = t(order(:,ii(jj)),ii(jj)); + for jj=1:length (ii) + e1(:,jj) = t(order(:,ii(jj)),ii(jj)); endfor - e1(10,:) = sides(1); + e1(10,:) = sides (1); ## right - T(:) = p(1,t)'==x(end); - [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + T(:) = p(1,t)' == x(end); + [~, order] = sort(T,1); + ii = (find(sum(T,1)==3)); order(1,:) = []; - for jj=1:length(ii) - e2(:,jj) = t(order(:,ii(jj)),ii(jj)); + for jj=1:length (ii) + e2(:,jj) = t(order(:,ii(jj)),ii(jj)); end e2(10,:) = sides(2); ## front - T(:) = p(2,t)'==y(1); - [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + T(:) = p(2,t)' == y(1); + [~, order] = sort(T,1); + ii = (find (sum (T,1) == 3)); order(1,:) = []; - for jj=1:length(ii) - e3(:,jj) = t(order(:,ii(jj)),ii(jj)); + for jj=1:length (ii) + e3(:,jj) = t(order(:,ii(jj)),ii(jj)); endfor e3(10,:) = sides(3); ## back - T(:) = p(2,t)'==y(end); - [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + T(:) = p(2,t)' == y(end); + [~,order] = sort (T,1); + ii = (find (sum (T,1) == 3)); order(1,:) = []; - for jj=1:length(ii) - e4(:,jj) = t(order(:,ii(jj)),ii(jj)); + for jj=1:length (ii) + e4(:,jj) = t(order(:,ii(jj)),ii(jj)); endfor e4(10,:) = sides(4); @@ -177,7 +185,7 @@ T = t; T(:) = p(3,t)'==z(1); [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + ii = (find (sum (T,1)==3)); order(1,:) = []; for jj=1:length(ii) e5(:,jj) = t(order(:,ii(jj)),ii(jj)); @@ -188,43 +196,40 @@ T = t; T(:) = p(3,t)'==z(end); [ignore,order] = sort(T,1); - ii = (find(sum(T,1)==3)); + ii = (find (sum (T,1) == 3)); order(1,:) = []; for jj=1:length(ii) e6(:,jj) = t(order(:,ii(jj)),ii(jj)); endfor e6(10,:) = sides(6); - ## Assemble structure - mesh.e = [e1,e2,e3,e4,e5,e6]; - mesh.t = t; - mesh.e (9,:) = region; - mesh.t (5,:) = region; - mesh.p = p; + e = [e1, e2, e3, e4, e5, e6]; endfunction + + %!test -% x = y = z = linspace(0,1,2) -% [mesh] = msh3m_structured_mesh(x,y,z,1,1:6) -% assert = (columns(mesh.p),8) -% assert = (columns(mesh.t),6) -% assert = (columns(mesh.e),12) +% x = y = z = linspace (0,1,2) +% [mesh] = msh3m_structured_mesh (x, y, z, 1, 1:6) +% assert = (columns (mesh.p), 8) +% assert = (columns (mesh.t), 6) +% assert = (columns (mesh.e), 12) %!test -% x = y = z = linspace(0,1,3) -% [mesh] = msh3m_structured_mesh(x,y,z,1,1:6) -% assert = (columns(mesh.p),27) -% assert = (columns(mesh.t),48) -% assert = (columns(mesh.e),48) +% x = y = z = linspace (0,1,3) +% [mesh] = msh3m_structured_mesh (x, y, z, 1, 1:6) +% assert = (columns (mesh.p), 27) +% assert = (columns (mesh.t), 48) +% assert = (columns (mesh.e), 48) %!test -% x = y = z = linspace(0,1,4) -% [mesh] = msh3m_structured_mesh(x,y,z,1,1:6) -% assert = (columns(mesh.p),64) -% assert = (columns(mesh.t),162) -% assert = (columns(mesh.e),108) +% x = y = z = linspace (0,1,4) +% [mesh] = msh3m_structured_mesh (x, y, z, 1, 1:6) +% assert = (columns (mesh.p), 64) +% assert = (columns (mesh.t), 162) +% assert = (columns (mesh.e), 108) %!test -% x = y = z = linspace(0,1,1) -% fail([mesh] = msh3m_structured_mesh(x,y,z,1,1:6),"warning","x, y, z cannot be scalar numbers!") +% x = y = z = linspace (0,1,1) +% fail([mesh] = msh3m_structured_mesh (x, y, z, 1, 1:6), "warning", "x, y, z cannot be scalar numbers!") %!test % x = y = z = eye(2) -% fail([mesh] = msh3m_structured_mesh(x,y,z,1,1:6),"warning","x, y, z cannot be matrices!") \ No newline at end of file +% fail([mesh] = msh3m_structured_mesh (x, y, z, 1, 1:6),"warning", "x, y, z cannot be matrices!") \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 03:52:23
|
Revision: 10950 http://octave.svn.sourceforge.net/octave/?rev=10950&view=rev Author: carandraug Date: 2012-09-02 03:52:17 +0000 (Sun, 02 Sep 2012) Log Message: ----------- iscolormap: also check class and number of dimensions Modified Paths: -------------- trunk/octave-forge/main/image/inst/iptcheckmap.m trunk/octave-forge/main/image/inst/iscolormap.m Modified: trunk/octave-forge/main/image/inst/iptcheckmap.m =================================================================== --- trunk/octave-forge/main/image/inst/iptcheckmap.m 2012-09-02 03:41:40 UTC (rev 10949) +++ trunk/octave-forge/main/image/inst/iptcheckmap.m 2012-09-02 03:52:17 UTC (rev 10950) @@ -43,7 +43,7 @@ ## error ends in \n so the back trace of the error is not show. This is on ## purpose since the whole idea of this function is already to give a properly ## formatted error message - if (!strcmp (class(in), "double") || columns (in) != 3 || ndims (in) != 2 || !isreal (in) || min (in(:) < 0) || max (in(:) > 1)) + if (!iscolormap (in)) error ("Function %s expected input number %d, %s, to be a valid colormap.\n... Valid colormaps must be nonempty, double, 2-D matrices with 3 columns.\n", ... func_name, pos, var_name); Modified: trunk/octave-forge/main/image/inst/iscolormap.m =================================================================== --- trunk/octave-forge/main/image/inst/iscolormap.m 2012-09-02 03:41:40 UTC (rev 10949) +++ trunk/octave-forge/main/image/inst/iscolormap.m 2012-09-02 03:52:17 UTC (rev 10950) @@ -31,7 +31,8 @@ endif bool = false; - if (ismatrix (cm) && isnumeric (cm) && columns(cm) == 3 && + if (ismatrix (cm) && isreal (cm) isnumeric (cm) && columns(cm) == 3 && + ndims (cm) == 2 && strcmp (class (cm), "double") && min (cm(:)) >= 0 && max (cm(:)) <= 1) bool = true; endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 03:41:46
|
Revision: 10949 http://octave.svn.sourceforge.net/octave/?rev=10949&view=rev Author: carandraug Date: 2012-09-02 03:41:40 +0000 (Sun, 02 Sep 2012) Log Message: ----------- is_double_image: new private function to check if an image of class double is valid Modified Paths: -------------- trunk/octave-forge/main/image/inst/isgray.m trunk/octave-forge/main/image/inst/isrgb.m Added Paths: ----------- trunk/octave-forge/main/image/inst/private/is_double_image.m Modified: trunk/octave-forge/main/image/inst/isgray.m =================================================================== --- trunk/octave-forge/main/image/inst/isgray.m 2012-09-02 03:33:55 UTC (rev 10948) +++ trunk/octave-forge/main/image/inst/isgray.m 2012-09-02 03:41:40 UTC (rev 10949) @@ -43,7 +43,7 @@ elseif (ndims (img) == 2) switch (class (img)) case "double" - bool = ispart (@is_gray_double, img); + bool = ispart (@is_double_image, img); case {"uint8", "uint16"} bool = true; endswitch @@ -51,10 +51,6 @@ endfunction -function bool = is_gray_double (img) - bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); -endfunction - %!shared a %! a = rand (100); %!assert (isgray (a), true); Modified: trunk/octave-forge/main/image/inst/isrgb.m =================================================================== --- trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:33:55 UTC (rev 10948) +++ trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:41:40 UTC (rev 10949) @@ -44,7 +44,7 @@ elseif (ndims (img) == 3 && size (img, 3) == 3) switch (class (img)) case "double" - bool = ispart (@is_rgb_double, img); + bool = ispart (@is_double_image, img); case {"uint8", "uint16"} bool = true; endswitch @@ -52,10 +52,6 @@ endfunction -function bool = is_rgb_double (img) - bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); -endfunction - %!# Non-matrix %!assert(isrgb("this is not a RGB image"),false); Added: trunk/octave-forge/main/image/inst/private/is_double_image.m =================================================================== --- trunk/octave-forge/main/image/inst/private/is_double_image.m (rev 0) +++ trunk/octave-forge/main/image/inst/private/is_double_image.m 2012-09-02 03:41:40 UTC (rev 10949) @@ -0,0 +1,21 @@ +## Copyright (C) 2012 Carnë Draug <car...@gm...> +## +## 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/>. + +## simple check used by some functions. Images of the double class must have +## all their values between 0 and 1 or be NaN + +function bool = is_double_image (img) + bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |