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: <car...@us...> - 2012-09-02 03:34:02
|
Revision: 10948 http://octave.svn.sourceforge.net/octave/?rev=10948&view=rev Author: carandraug Date: 2012-09-02 03:33:55 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isrgb: use shared private functions for checks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isrgb.m Modified: trunk/octave-forge/main/image/inst/isrgb.m =================================================================== --- trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:32:21 UTC (rev 10947) +++ trunk/octave-forge/main/image/inst/isrgb.m 2012-09-02 03:33:55 UTC (rev 10948) @@ -39,15 +39,12 @@ endif bool = false; - if (ismatrix (img) && ndims (img) == 3 && size (img, 3) == 3 && !issparse (img) && !isempty (img)) + if (!isimage (img)) + bool = false; + elseif (ndims (img) == 3 && size (img, 3) == 3) switch (class (img)) case "double" - ## to speed this up, we can look at a sample of the image first - bool = is_rgb_double (img(1:ceil (rows (img) /100), 1:ceil (columns (img) /100))); - if (bool) - ## sample was true, we better make sure it's real - bool = is_rgb_double (img); - endif + bool = ispart (@is_rgb_double, img); case {"uint8", "uint16"} bool = true; endswitch @@ -59,10 +56,6 @@ bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); endfunction -%!demo -%! isrgb(rand(1,2,3)) -%! # A 1-by-2-by-3 double matrix with elements between 0 and 1 is a RGB image. - %!# Non-matrix %!assert(isrgb("this is not a RGB image"),false); 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:32:27
|
Revision: 10947 http://octave.svn.sourceforge.net/octave/?rev=10947&view=rev Author: carandraug Date: 2012-09-02 03:32:21 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: also check part first for speedup Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 03:17:47 UTC (rev 10946) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 03:32:21 UTC (rev 10947) @@ -42,7 +42,7 @@ elseif (ndims (img) == 2) switch (class (img)) case "double" - bool = isindex (img); + bool = ispart (@isindex, img); case {"uint8", "uint16"} bool = true; endswitch 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:17:53
|
Revision: 10946 http://octave.svn.sourceforge.net/octave/?rev=10946&view=rev Author: carandraug Date: 2012-09-02 03:17:47 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isimage: also check if input is real Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m trunk/octave-forge/main/image/inst/private/isimage.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:48:30 UTC (rev 10945) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 03:17:47 UTC (rev 10946) @@ -39,7 +39,7 @@ bool = false; if (!isimage (img)) bool = false; - elseif (ndims (img) == 2 && isreal (img)) + elseif (ndims (img) == 2) switch (class (img)) case "double" bool = isindex (img); Modified: trunk/octave-forge/main/image/inst/private/isimage.m =================================================================== --- trunk/octave-forge/main/image/inst/private/isimage.m 2012-09-02 02:48:30 UTC (rev 10945) +++ trunk/octave-forge/main/image/inst/private/isimage.m 2012-09-02 03:17:47 UTC (rev 10946) @@ -18,7 +18,7 @@ function bool = isimage (img) bool = true; - if (!ismatrix (img) || issparse (img) || isempty (img)) + if (!ismatrix (img) || issparse (img) || isempty (img) || !isreal (img)) bool = false; endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:48:36
|
Revision: 10945 http://octave.svn.sourceforge.net/octave/?rev=10945&view=rev Author: carandraug Date: 2012-09-02 02:48:30 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: use builtin function isindex Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:44:23 UTC (rev 10944) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:48:30 UTC (rev 10945) @@ -42,7 +42,7 @@ elseif (ndims (img) == 2 && isreal (img)) switch (class (img)) case "double" - bool = ispart (@is_ind_double, img); + bool = isindex (img); case {"uint8", "uint16"} bool = true; endswitch @@ -50,10 +50,6 @@ endfunction -function bool = is_ind_double (img) - bool = all (img(:) == fix (img(:))) && all (img(:) >= 1); -endfunction - %!fail(isind([])) ## should fail for empty matrix %!assert(isind(1:10)) %!assert(!isind(0:10)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:44:29
|
Revision: 10944 http://octave.svn.sourceforge.net/octave/?rev=10944&view=rev Author: carandraug Date: 2012-09-02 02:44:23 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isind: use shared private functions for checks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isind.m Modified: trunk/octave-forge/main/image/inst/isind.m =================================================================== --- trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:37:12 UTC (rev 10943) +++ trunk/octave-forge/main/image/inst/isind.m 2012-09-02 02:44:23 UTC (rev 10944) @@ -37,15 +37,12 @@ endif bool = false; - if (ismatrix (img) && ndims (img) == 2 && !issparse (img) && isreal (img) && !isempty (img)) + if (!isimage (img)) + bool = false; + elseif (ndims (img) == 2 && isreal (img)) switch (class (img)) case "double" - ## to speed this up, we can look at a sample of the image first - bool = is_ind_double (img(1:ceil (rows (img) /100), 1:ceil (columns (img) /100))); - if (bool) - ## sample was true, we better make sure it's real - bool = is_ind_double (img); - endif + bool = ispart (@is_ind_double, img); case {"uint8", "uint16"} bool = true; endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:37:18
|
Revision: 10943 http://octave.svn.sourceforge.net/octave/?rev=10943&view=rev Author: carandraug Date: 2012-09-02 02:37:12 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isgray: use shared private functions for checks and added test blocks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isbw.m trunk/octave-forge/main/image/inst/isgray.m Modified: trunk/octave-forge/main/image/inst/isbw.m =================================================================== --- trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 02:33:14 UTC (rev 10942) +++ trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 02:37:12 UTC (rev 10943) @@ -62,7 +62,7 @@ endfunction function bool = is_bw_nonlogical (BW) - bool = all ((BW == 1)(:) + (BW == 0)(:)); + bool = all ((BW(:) == 1) + (BW(:) == 0)); endfunction %!shared a Modified: trunk/octave-forge/main/image/inst/isgray.m =================================================================== --- trunk/octave-forge/main/image/inst/isgray.m 2012-09-02 02:33:14 UTC (rev 10942) +++ trunk/octave-forge/main/image/inst/isgray.m 2012-09-02 02:37:12 UTC (rev 10943) @@ -38,15 +38,12 @@ endif bool = false; - if (ismatrix (img) && ndims (img) == 2 && !issparse (img) && !isempty (img)) + if (!isimage (img)) + bool = false; + elseif (ndims (img) == 2) switch (class (img)) case "double" - ## to speed this up, we can look at a sample of the image first - bool = is_gray_double (img(1:ceil (rows (img) /100), 1:ceil (columns (img) /100))); - if (bool) - ## sample was true, we better make sure it's real - bool = is_gray_double (img); - endif + bool = ispart (@is_gray_double, img); case {"uint8", "uint16"} bool = true; endswitch @@ -57,3 +54,13 @@ function bool = is_gray_double (img) bool = all ((img(:) >= 0 & img(:) <= 1) | isnan (img(:))); endfunction + +%!shared a +%! a = rand (100); +%!assert (isgray (a), true); +%! a(50, 50) = 2; +%!assert (isgray (a), false); +%! a = uint8 (randi (255, 100)); +%!assert (isgray (a), true); +%! a = int8 (a); +%!assert (isgray (a), false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:33:20
|
Revision: 10942 http://octave.svn.sourceforge.net/octave/?rev=10942&view=rev Author: carandraug Date: 2012-09-02 02:33:14 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isbw: fix bug when input image has more than 2D. Modified Paths: -------------- trunk/octave-forge/main/image/inst/isbw.m Modified: trunk/octave-forge/main/image/inst/isbw.m =================================================================== --- trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 02:31:53 UTC (rev 10941) +++ trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 02:33:14 UTC (rev 10942) @@ -62,7 +62,7 @@ endfunction function bool = is_bw_nonlogical (BW) - bool = all (all ((BW == 1) + (BW == 0))); + bool = all ((BW == 1)(:) + (BW == 0)(:)); endfunction %!shared a This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 02:31:59
|
Revision: 10941 http://octave.svn.sourceforge.net/octave/?rev=10941&view=rev Author: carandraug Date: 2012-09-02 02:31:53 +0000 (Sun, 02 Sep 2012) Log Message: ----------- isbw: delegate checks to new shared private functions and add test blocks Modified Paths: -------------- trunk/octave-forge/main/image/inst/isbw.m Added Paths: ----------- trunk/octave-forge/main/image/inst/private/isimage.m trunk/octave-forge/main/image/inst/private/ispart.m Modified: trunk/octave-forge/main/image/inst/isbw.m =================================================================== --- trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 01:53:19 UTC (rev 10940) +++ trunk/octave-forge/main/image/inst/isbw.m 2012-09-02 02:31:53 UTC (rev 10941) @@ -17,12 +17,12 @@ ## -*- texinfo -*- ## @deftypefn {Function File} @var{bool} = isbw (@var{img}) ## @deftypefnx {Function File} @var{bool} = isbw (@var{img}, @var{logic}) -## Return true if @var{img} is a black-white image. +## Return true if @var{img} is a black and white image. ## -## The optional argument @var{logic} must be the string `logical' or -## `non-logical'. The first defines a black and white image as a logical matrix, -## while the second defines it as a matrix comprised of the values 1 and 0 -## only. Defaults to `logical'. +## The optional argument @var{logic} defines what is considered a black and +## white image. Possible values are the strings `logical' or `non-logical'. The +## first defines it as a logical matrix, while the second defines it as a matrix +## where the only values are 1 and 0. Defaults to `logical'. ## ## @seealso{isgray, isind, islogical, isrgb} ## @end deftypefn @@ -36,32 +36,27 @@ error ("second argument must either be a string 'logical' or 'non-logical'") endif - ## an image cannot be a sparse matrix - if (!ismatrix (BW) || issparse (BW) || isempty (BW)) + bool = false; + if (!isimage (BW)) bool = false; elseif (strcmpi (logic, "logical")) ## this is the matlab compatible way (before they removed the function) bool = islogical (BW); - ## the following block is just temporary to keep backwards compatibility - if (!islogical (BW) && is_bw_nonlogical (BW)) + ## FIXME the following block is just temporary to keep backwards compatibility + if (nargin == 1 && !islogical (BW) && isbw (BW, "non-logical")) persistent warned = false; if (! warned) warned = true; warning ("isbw: image is not logical matrix and therefore not binary but all values are either 0 and 1.") - warning ("isbw: future versions of this function will return true. Consider using the call isbw (img, \"non-logical\").") + warning ("isbw: future versions of this function will return true. Consider using the call `isbw (img, \"non-logical\")'.") endif bool = true; endif ## end of temporary block for backwards compatibility elseif (strcmpi (logic, "non-logical")) - ## to speed this up, we can look at a sample of the image first - bool = is_bw_nonlogical (BW(1:ceil (rows (BW) /100), 1:ceil (columns (BW) /100))); - if (bool) - ## sample was true, we better make sure it's real - bool = is_bw_nonlogical (BW); - endif + bool = ispart (@is_bw_nonlogical, BW); endif endfunction @@ -69,3 +64,12 @@ function bool = is_bw_nonlogical (BW) bool = all (all ((BW == 1) + (BW == 0))); endfunction + +%!shared a +%! a = round(rand(100)); +%!assert (isbw (a, "non-logical"), true); +%!assert (isbw (a, "logical"), false); +%!assert (isbw (logical(a), "logical"), true); +%!assert (isbw (logical(a), "non-logical"), true); +%! a(50, 50) = 2; +%!assert (isbw (a, "non-logical"), false); Added: trunk/octave-forge/main/image/inst/private/isimage.m =================================================================== --- trunk/octave-forge/main/image/inst/private/isimage.m (rev 0) +++ trunk/octave-forge/main/image/inst/private/isimage.m 2012-09-02 02:31:53 UTC (rev 10941) @@ -0,0 +1,24 @@ +## 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/>. + +## This a private function for the is... type of functions for the image package +## It simply checks if the input really is an image. + +function bool = isimage (img) + bool = true; + if (!ismatrix (img) || issparse (img) || isempty (img)) + bool = false; + endif +endfunction Added: trunk/octave-forge/main/image/inst/private/ispart.m =================================================================== --- trunk/octave-forge/main/image/inst/private/ispart.m (rev 0) +++ trunk/octave-forge/main/image/inst/private/ispart.m 2012-09-02 02:31:53 UTC (rev 10941) @@ -0,0 +1,25 @@ +## 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/>. + +## This a private function for the is... type of functions for the image package +## Rather than checking the whol image, there can be a speed up by checking only +## a corner of the image first and then the rest if that part is true. + +function bool = ispart (foo, in) + bool = foo (in(1:ceil (rows (in) /100), 1:ceil (columns (in) /100))); + if (bool) + bool = foo (in); + endif +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 01:53:26
|
Revision: 10940 http://octave.svn.sourceforge.net/octave/?rev=10940&view=rev Author: carandraug Date: 2012-09-02 01:53:19 +0000 (Sun, 02 Sep 2012) Log Message: ----------- graythresh: return goodness of computed value. Prepare code for multiple algorithms. Avoid var names that shadow core functions. Modified Paths: -------------- trunk/octave-forge/main/image/NEWS trunk/octave-forge/main/image/inst/graythresh.m Modified: trunk/octave-forge/main/image/NEWS =================================================================== --- trunk/octave-forge/main/image/NEWS 2012-09-02 00:51:46 UTC (rev 10939) +++ trunk/octave-forge/main/image/NEWS 2012-09-02 01:53:19 UTC (rev 10940) @@ -30,6 +30,9 @@ imginfo + ** The function `graythresh' now returns a second value representing the + ``goodness'' of the computed threshold value. + ** The following functions have been deprecated (see their help text for the recommended alternatives): Modified: trunk/octave-forge/main/image/inst/graythresh.m =================================================================== --- trunk/octave-forge/main/image/inst/graythresh.m 2012-09-02 00:51:46 UTC (rev 10939) +++ trunk/octave-forge/main/image/inst/graythresh.m 2012-09-02 01:53:19 UTC (rev 10940) @@ -1,4 +1,6 @@ ## Copyright (C) 2005 Barre-Piquot +## Copyright (C) 2007 Søren Hauberg +## 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 @@ -14,73 +16,133 @@ ## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{level}=} graythresh (@var{I}) -## Compute global image threshold using Otsu's method. +## @deftypefn {Function File} {[@var{level}, @var{sep}] =} graythresh (@var{img}) +## @deftypefnx {Function File} {[@var{level}, @var{sep}] =} graythresh (@var{img}, @var{algo}) +## Compute global image threshold. ## -## The output @var{level} is a global threshold (level) that can be used to convert -## an intensity image to a binary image with @code{im2bw}. -## @var{level} is a normalized intensity value that lies in the range [0, 1]. -## -## The function uses Otsu's method, which chooses the threshold to -## minimize the intraclass variance of the black and white pixels. -## -## Color images are converted grayscale before @var{level} is computed. +## Given an image @var{img} finds the optimal threshold value @var{level} for +## conversion to a binary image with @code{im2bw}. Color images are converted +## to grayscale before @var{level} is computed. +## +## The optional argument @var{method} is the algorithm to be used (default's to +## Otsu). The available algorithms are: +## +## @table @asis +## @item "Otsu" (default) +## Implements Otsu's method as described in @cite{Nobuyuki Otsu (1979). "A +## threshold selection method from gray-level histograms". IEEE Trans. Sys., +## Man., Cyber. 9 (1): 62-66}. This algorithm chooses the threshold to minimize +## the intraclass variance of the black and white pixels. The second output, +## @var{sep} represents the ``goodness'' (or separability) of the threshold at +## @var{level}. +## +## @item Huang +## Not yet implemented. +## +## @item ImageJ +## Not yet implemented. +## +## @item intermodes +## Not yet implemented. +## +## @item IsoData +## Not yet implemented. +## +## @item Li +## Not yet implemented. +## +## @item MaxEntropy +## Not yet implemented. +## +## @item mean +## Not yet implemented. +## +## @item MinError +## Not yet implemented. +## +## @item minimum +## Not yet implemented. +## +## @item moments +## Not yet implemented. +## +## @item percentile +## Not yet implemented. +## +## @item RenyiEntropy +## Not yet implemented. +## +## @item Shanbhag +## Not yet implemented. +## +## @item triangle +## Not yet implemented. +## +## @item Yen +## Not yet implemented. +## @end table +## ## @seealso{im2bw} ## @end deftypefn -## Note: -## This function is taken from -## http://www.irit.fr/~Philippe.Joly/Teaching/M2IRR/IRR05/ -## I added texinfo documentation, error checking and sanitised the code. -## -- Søren Hauberg +## Notes: +## * Otsu's method is a function taken from +## http://www.irit.fr/~Philippe.Joly/Teaching/M2IRR/IRR05/ Søren Hauberg +## added texinfo documentation, error checking and sanitised the code. -function level = graythresh (I) +function [level, goodness] = graythresh (img, algo = "otsu") ## Input checking - if (nargin != 1) + if (nargin < 1 || nargin > 2) print_usage(); + elseif (!isgray (img) && !isrgb (img)) + error ("graythresh: input must be an image"); endif - if (!isgray(I) && !isrgb(I)) - error("graythresh: input must be an image"); - endif - + ## If the image is RGB convert it to grayscale - if (isrgb(I)) - I = rgb2gray(I); + if (isrgb(img)) + img = rgb2gray (img); endif - ## Calculation of the normalized histogram - n = 256; - h = hist(I(:), 1:n); - h = h/(length(I(:))+1); - - ## Calculation of the cumulated histogram and the mean values - w = cumsum(h); - mu = zeros(n, 1); mu(1) = h(1); - for i=2:n - mu(i) = mu(i-1) + i*h(i); - end - - ## Initialisation of the values used for the threshold calculation - level = find (h > 0, 1); - w0 = w(level); - w1 = 1-w0; - mu0 = mu(level)/w0; - mu1 = (mu(end)-mu(level))/w1; - max = w0*w1*(mu1-mu0)*(mu1-mu0); - - ## For each step of the histogram, calculation of the threshold and storing of the maximum - for i = find (h > 0) - w0 = w(i); - w1 = 1-w0; - mu0 = mu(i)/w0; - mu1 = (mu(end)-mu(i))/w1; - s = w0*w1*(mu1-mu0)*(mu1-mu0); - if (s > max) - max = s; - level = i; - endif - endfor - - ## Normalisation of the threshold - level /= n; + switch tolower (algo) + case {"otsu"} + ## Calculation of the normalized histogram + n = intmax (class (img)) + 1; + h = hist (img(:), 1:n); + h = h / (length (img(:)) + 1); + + ## Calculation of the cumulated histogram and the mean values + w = cumsum (h); + mu = zeros (n, 1); + mu(1) = h(1); + for i = 2:n + mu(i) = mu(i-1) + i * h(i); + endfor + + ## Initialisation of the values used for the threshold calculation + level = find (h > 0, 1); + w0 = w(level); + w1 = 1 - w0; + mu0 = mu(level) / w0; + mu1 = (mu(end) - mu(level)) / w1; + goodness = w0 * w1 * (mu1 - mu0) * (mu1 - mu0); + + ## For each step of the histogram, calculation of the threshold + ## and storing of the maximum + for i = find (h > 0) + w0 = w(i); + w1 = 1 - w0; + mu0 = mu(i) / w0; + mu1 = (mu(end) - mu(i)) / w1; + s = w0 * w1 * (mu1 - mu0) * (mu1 - mu0); + if (s > max) + goodness = s; + level = i; + endif + endfor + + ## Normalisation of the threshold + level /= n; + otherwise + error ("graythresh: unknown method '%s'", algo); + endswitch endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-02 00:51:52
|
Revision: 10939 http://octave.svn.sourceforge.net/octave/?rev=10939&view=rev Author: carandraug Date: 2012-09-02 00:51:46 +0000 (Sun, 02 Sep 2012) Log Message: ----------- graythresh: update link to original code Modified Paths: -------------- trunk/octave-forge/main/image/inst/graythresh.m Modified: trunk/octave-forge/main/image/inst/graythresh.m =================================================================== --- trunk/octave-forge/main/image/inst/graythresh.m 2012-09-01 16:27:40 UTC (rev 10938) +++ trunk/octave-forge/main/image/inst/graythresh.m 2012-09-02 00:51:46 UTC (rev 10939) @@ -30,7 +30,7 @@ ## Note: ## This function is taken from -## http://www.irit.fr/recherches/SAMOVA/MEMBERS/JOLY/Homepage_files/IRR05/Barre-Piquot/graythresh.m +## http://www.irit.fr/~Philippe.Joly/Teaching/M2IRR/IRR05/ ## I added texinfo documentation, error checking and sanitised the code. ## -- Søren Hauberg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-01 16:27:46
|
Revision: 10938 http://octave.svn.sourceforge.net/octave/?rev=10938&view=rev Author: paramaniac Date: 2012-09-01 16:27:40 +0000 (Sat, 01 Sep 2012) Log Message: ----------- quaternion: remove completed tasks from projects file Modified Paths: -------------- trunk/octave-forge/main/quaternion/devel/PROJECTS Modified: trunk/octave-forge/main/quaternion/devel/PROJECTS =================================================================== --- trunk/octave-forge/main/quaternion/devel/PROJECTS 2012-09-01 16:25:33 UTC (rev 10937) +++ trunk/octave-forge/main/quaternion/devel/PROJECTS 2012-09-01 16:27:40 UTC (rev 10938) @@ -9,12 +9,7 @@ ------- General: ------- - - * Add missing features to quaternion_oo such that it can replace quaternion-1.0.0. - * Rename the existion main/quaternion package to extra/quaternion-legacy. - Rename extra/quaternion_oo to main/quaternion and release it as quaternion-2.0.0. - * See if LaTEX code from Scottedward Hodel's quaternion.ps document is available. Update it to use the commands from quaternion-2.0.0. @@ -30,8 +25,6 @@ * Add functionality of qderiv and qtrans from quaternion-1.0.0. - * Finish q2rot and rot2q. - ------ Always: ------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-01 16:25:39
|
Revision: 10937 http://octave.svn.sourceforge.net/octave/?rev=10937&view=rev Author: paramaniac Date: 2012-09-01 16:25:33 +0000 (Sat, 01 Sep 2012) Log Message: ----------- quaternion: style fixes Modified Paths: -------------- trunk/octave-forge/main/quaternion/inst/@quaternion/eq.m trunk/octave-forge/main/quaternion/inst/@quaternion/minus.m trunk/octave-forge/main/quaternion/inst/@quaternion/mrdivide.m trunk/octave-forge/main/quaternion/inst/@quaternion/mtimes.m trunk/octave-forge/main/quaternion/inst/@quaternion/plus.m trunk/octave-forge/main/quaternion/inst/@quaternion/power.m trunk/octave-forge/main/quaternion/inst/@quaternion/rdivide.m trunk/octave-forge/main/quaternion/inst/@quaternion/times.m trunk/octave-forge/main/quaternion/inst/@quaternion/uminus.m trunk/octave-forge/main/quaternion/inst/@quaternion/uplus.m Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/eq.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/eq.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/eq.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,17 +18,16 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 function flg = eq (a, b) - if (! isa (a, "quaternion")) - a = quaternion (a); + if (nargin != 2) + error ("quaternion: eq: this is a binary operator"); endif - if (! isa (b, "quaternion")) - b = quaternion (b); - endif + a = quaternion (a); + b = quaternion (b); flg = (a.w == b.w) && (a.x == b.x) && (a.y == b.y) && (a.z == a.z); Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/minus.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/minus.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/minus.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,21 +18,22 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 -function a = minus (a, b) +function q = minus (a, b) - if (! isa (a, "quaternion")) - a = quaternion (a); + if (nargin != 2) + error ("quaternion: minus: this is a binary operator"); endif - if (! isa (b, "quaternion")) - b = quaternion (b); - endif + a = quaternion (a); + b = quaternion (b); - a.w = a.w - b.w; - a.x = a.x - b.x; - a.y = a.y - b.y; - a.z = a.z - b.z; + w = a.w - b.w; + x = a.x - b.x; + y = a.y - b.y; + z = a.z - b.z; + q = quaternion (w, x, y, z); + endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/mrdivide.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/mrdivide.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/mrdivide.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,10 +18,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 function q = mrdivide (a, b) + if (nargin != 2) + error ("quaternion: mrdivide: this is a binary operator"); + endif + q = a * inv (b); endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/mtimes.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/mtimes.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/mtimes.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,26 +18,22 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 -function a = mtimes (a, b) +function q = mtimes (a, b) - if (! isa (a, "quaternion")) - a = quaternion (a); + if (nargin != 2) + error ("quaternion: mtimes: this is a binary operator"); endif - if (! isa (b, "quaternion")) - b = quaternion (b); - endif + a = quaternion (a); + b = quaternion (b); w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z; x = a.y*b.z - a.z*b.y + a.w*b.x + a.x*b.w; y = a.z*b.x - a.x*b.z + a.w*b.y + a.y*b.w; z = a.x*b.y - a.y*b.x + a.w*b.z + a.z*b.w; - a.w = w; - a.x = x; - a.y = y; - a.z = z; + q = quaternion (w, x, y, z); endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/plus.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/plus.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/plus.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,21 +18,17 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 -function a = plus (a, b) +function q = plus (varargin) - if (! isa (a, "quaternion")) - a = quaternion (a); - endif + tmp = cellfun (@quaternion, varargin); # uniformoutput = true ! - if (! isa (b, "quaternion")) - b = quaternion (b); - endif + w = plus (tmp.w); + x = plus (tmp.x); + y = plus (tmp.y); + z = plus (tmp.z); - a.w = a.w + b.w; - a.x = a.x + b.x; - a.y = a.y + b.y; - a.z = a.z + b.z; + q = quaternion (w, x, y, z); endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/power.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/power.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/power.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010, 2011 Lukas F. Reichlin +## Copyright (C) 2010, 2011, 2012 Lukas F. Reichlin ## Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> ## ## This program is free software: you can redistribute it and/or modify @@ -20,10 +20,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.3 +## Version: 0.4 function a = power (a, b) + if (nargin != 2) + error ("quaternion: power: this is a binary operator"); + endif + if (isa (b, "quaternion")) # exponent is a quaternion a = exp (log (a) .* b); # a could be real, but log doesn't care elseif (! isreal (b)) Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/rdivide.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/rdivide.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/rdivide.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,10 +18,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 function q = rdivide (a, b) + if (nargin != 2) + error ("quaternion: rdivide: this is a binary operator"); + endif + q = a .* b.^-1; endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/times.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/times.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/times.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,26 +18,22 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 -function a = times (a, b) +function q = times (a, b) - if (! isa (a, "quaternion")) - a = quaternion (a); + if (nargin != 2) + error ("quaternion: times: this is a binary operator"); endif - if (! isa (b, "quaternion")) - b = quaternion (b); - endif + a = quaternion (a); + b = quaternion (b); w = a.w .* b.w - a.x .* b.x - a.y .* b.y - a.z .* b.z; x = a.y .* b.z - a.z .* b.y + a.w .* b.x + a.x .* b.w; y = a.z .* b.x - a.x .* b.z + a.w .* b.y + a.y .* b.w; z = a.x .* b.y - a.y .* b.x + a.w .* b.z + a.z .* b.w; - a.w = w; - a.x = x; - a.y = y; - a.z = z; + q = quaternion (w, x, y, z); endfunction Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/uminus.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/uminus.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/uminus.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## 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 @@ -18,10 +18,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2010 -## Version: 0.1 +## Version: 0.2 function a = uminus (a) + if (nargin != 1) + error ("quaternion: uminus: this is an unary operator"); + endif + a.w = -a.w; a.x = -a.x; a.y = -a.y; Modified: trunk/octave-forge/main/quaternion/inst/@quaternion/uplus.m =================================================================== --- trunk/octave-forge/main/quaternion/inst/@quaternion/uplus.m 2012-08-31 15:35:11 UTC (rev 10936) +++ trunk/octave-forge/main/quaternion/inst/@quaternion/uplus.m 2012-09-01 16:25:33 UTC (rev 10937) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 Lukas F. Reichlin +## Copyright (C) 2011, 2012 Lukas F. Reichlin ## ## 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 @@ -18,10 +18,14 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2011 -## Version: 0.1 +## Version: 0.2 function a = uplus (a) + if (nargin != 1) + error ("quaternion: uplus: this is an unary operator"); + endif + ## nothing to do here endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-08-31 15:35:17
|
Revision: 10936 http://octave.svn.sourceforge.net/octave/?rev=10936&view=rev Author: jordigh Date: 2012-08-31 15:35:11 +0000 (Fri, 31 Aug 2012) Log Message: ----------- Make bwlabeln compile Modified Paths: -------------- trunk/octave-forge/main/image/src/Makefile Modified: trunk/octave-forge/main/image/src/Makefile =================================================================== --- trunk/octave-forge/main/image/src/Makefile 2012-08-30 22:17:16 UTC (rev 10935) +++ trunk/octave-forge/main/image/src/Makefile 2012-08-31 15:35:11 UTC (rev 10936) @@ -5,5 +5,8 @@ %.oct: %.cc mkoctfile -Wall $< +bwlabeln.oct: bwlabeln.cc + CXXFLAGS='-g -O2 -std=c++0x -Wall' mkoctfile $< + clean: rm -f *.o octave-core core *.oct *~ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ean...@us...> - 2012-08-30 22:17:22
|
Revision: 10935 http://octave.svn.sourceforge.net/octave/?rev=10935&view=rev Author: eandrius Date: 2012-08-30 22:17:16 +0000 (Thu, 30 Aug 2012) Log Message: ----------- serial: texinfo help strings Modified Paths: -------------- trunk/octave-forge/main/serial/src/serial.cc trunk/octave-forge/main/serial/src/serial.h trunk/octave-forge/main/serial/src/srl_baudrate.cc trunk/octave-forge/main/serial/src/srl_bytesize.cc trunk/octave-forge/main/serial/src/srl_close.cc trunk/octave-forge/main/serial/src/srl_flush.cc trunk/octave-forge/main/serial/src/srl_parity.cc trunk/octave-forge/main/serial/src/srl_read.cc trunk/octave-forge/main/serial/src/srl_stopbits.cc trunk/octave-forge/main/serial/src/srl_timeout.cc trunk/octave-forge/main/serial/src/srl_write.cc Modified: trunk/octave-forge/main/serial/src/serial.cc =================================================================== --- trunk/octave-forge/main/serial/src/serial.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/serial.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -13,16 +13,12 @@ // 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: Include more detailed error messages (perror?) // TODO: Implement Flow Control // TODO: Implement H/W handshaking -// TODO: Implement read timeout // TODO: Check if interface is opened first #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -64,14 +60,9 @@ octave_serial::~octave_serial() { - this->srl_close(); + this->close(); } -int octave_serial::srl_get_fd() -{ - return this->fd; -} - void octave_serial::print (std::ostream& os, bool pr_as_read_syntax ) const { print_raw(os, pr_as_read_syntax); @@ -84,7 +75,18 @@ } // PKG_ADD: autoload ("serial", "serial.oct"); -DEFUN_DLD (serial, args, nargout, "Hello World Help String") +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..."); @@ -163,23 +165,23 @@ // Open the interface octave_serial* retval = new octave_serial(path, oflags); - if (retval->srl_get_fd() < 0) + if (retval->get_fd() < 0) { error("serial: Error opening the interface: %s\n", strerror(errno)); return octave_value(); } - retval->srl_baudrate(baud_rate); + retval->set_baudrate(baud_rate); if (timeout >= 0) { - retval->srl_timeout(timeout); + retval->set_timeout(timeout); } - retval->srl_parity(parity); - retval->srl_bytesize(bytesize); - retval->srl_stopbits(stopbits); + retval->set_parity(parity); + retval->set_bytesize(bytesize); + retval->set_stopbits(stopbits); - retval->srl_flush(); + //retval->flush(2); return octave_value(retval); } Modified: trunk/octave-forge/main/serial/src/serial.h =================================================================== --- trunk/octave-forge/main/serial/src/serial.h 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/serial.h 2012-08-30 22:17:16 UTC (rev 10935) @@ -18,8 +18,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <string> @@ -35,30 +33,36 @@ octave_serial(string, int); ~octave_serial(); - int srl_get_fd(); + int write(string); + int write(unsigned char*, int); + + int read(char *, unsigned int); + + int close(); - int srl_write(string); - int srl_write(unsigned char*, int); - int srl_read(char *, unsigned int); - int srl_close(); + int flush(unsigned short); - int srl_flush(unsigned short); - int srl_flush(); + 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 srl_timeout(short); - int srl_baudrate(unsigned int); - int srl_bytesize(unsigned short); - int srl_parity(string); - int srl_stopbits(unsigned short); + int get_fd() { return this->fd; } - // Overloaded base functions - double serial_value() const - { - return (double)this->fd; - } + double serial_value() const { return (double)this->fd; } - virtual double scalar_value (bool frc_str_conv = false) const + virtual double scalar_value (bool frc_str_conv = false) const { return (double)this->fd; } Modified: trunk/octave-forge/main/serial/src/srl_baudrate.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_baudrate.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_baudrate.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -36,7 +36,20 @@ #include "serial.h" // PKG_ADD: autoload ("srl_baudrate", "serial.oct"); -DEFUN_DLD (srl_baudrate, args, nargout, "Hello World Help String") +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()) @@ -44,7 +57,12 @@ 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) { @@ -54,23 +72,16 @@ return octave_value(-1); } - octave_serial* serial = NULL; + serial->set_baudrate(args(1).int_value()); - const octave_base_value& rep = args(0).get_rep(); - serial = &((octave_serial &)rep); - - serial->srl_baudrate(args(1).int_value()); - return octave_value(); } // Returning current baud rate - // TODO: return current baudrate - - return octave_value(-115200); + return octave_value(serial->get_baudrate()); } -int octave_serial::srl_baudrate(unsigned int baud) +int octave_serial::set_baudrate(unsigned int baud) { speed_t baud_rate = 0; @@ -117,17 +128,66 @@ default: error("srl_baudrate: currently only 0, 50, 75, 110, \ 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, \ - 9600 19200, 38400, 5760, 115200 and 230400 baud rates are supported..."); + 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->srl_get_fd(), TCSANOW, &this->config) < 0) { + 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 Modified: trunk/octave-forge/main/serial/src/srl_bytesize.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_bytesize.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_bytesize.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -36,14 +36,30 @@ #include "serial.h" // PKG_ADD: autoload ("srl_bytesize", "serial.oct"); -DEFUN_DLD (srl_bytesize, args, nargout, "Hello World Help String") +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) { @@ -53,23 +69,16 @@ return octave_value(-1); } - octave_serial* serial = NULL; + serial->set_bytesize(args(1).int_value()); - const octave_base_value& rep = args(0).get_rep(); - serial = &((octave_serial &)rep); - - serial->srl_bytesize(args(1).int_value()); - return octave_value(); } // Returning current byte size - // TODO: return current byte size - - return octave_value(-8); + return octave_value(serial->get_bytesize()); } -int octave_serial::srl_bytesize(unsigned short bytesize) +int octave_serial::set_bytesize(unsigned short bytesize) { tcflag_t c_bytesize = 0; @@ -85,24 +94,32 @@ return false; } - // Clear previous config flags - /* - BITMASK_CLEAR(this->config.c_cflag, CS5); - BITMASK_CLEAR(this->config.c_cflag, CS6); - BITMASK_CLEAR(this->config.c_cflag, CS7); - BITMASK_CLEAR(this->config.c_cflag, CS8); - */ - // Clear bitmask CSIZE BITMASK_CLEAR(this->config.c_cflag, CSIZE); // Apply new - this->config.c_cflag |= c_bytesize; + BITMASK_SET(this->config.c_cflag, c_bytesize); - if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { + 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 Modified: trunk/octave-forge/main/serial/src/srl_close.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_close.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_close.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -15,8 +15,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -36,7 +34,14 @@ #include "serial.h" // PKG_ADD: autoload ("srl_close", "serial.oct"); -DEFUN_DLD (srl_close, args, nargout, "Hello World Help String") +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()) { @@ -49,14 +54,14 @@ const octave_base_value& rep = args(0).get_rep(); serial = &((octave_serial &)rep); - serial->srl_close(); + serial->close(); return octave_value(); } -int octave_serial::srl_close() +int octave_serial::close() { - int retval = ::close(this->srl_get_fd()); + int retval = ::close(this->get_fd()); this->fd = -1; return retval; } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_flush.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -15,8 +15,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -36,7 +34,18 @@ #include "serial.h" // PKG_ADD: autoload ("srl_flush", "serial.oct"); -DEFUN_DLD (srl_flush, args, nargout, "Hello World Help String") +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 @@ -62,12 +71,12 @@ const octave_base_value& rep = args(0).get_rep(); serial = &((octave_serial &)rep); - serial->srl_flush(queue_selector); + serial->flush(queue_selector); return octave_value(); } -int octave_serial::srl_flush(unsigned short queue_selector) +int octave_serial::flush(unsigned short queue_selector) { /* * TCIOFLUSH Flush both pending input and untransmitted output. @@ -87,10 +96,5 @@ return false; } - return ::tcflush(this->srl_get_fd(), flag); -} - -int octave_serial::srl_flush() -{ - return srl_flush(2); + return ::tcflush(this->get_fd(), flag); } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_parity.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_parity.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_parity.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -36,14 +36,30 @@ #include "serial.h" // PKG_ADD: autoload ("srl_parity", "serial.oct"); -DEFUN_DLD (srl_parity, args, nargout, "Hello World Help String") +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) { @@ -53,23 +69,16 @@ return octave_value(-1); } - octave_serial* serial = NULL; + serial->set_parity(args(1).string_value()); - const octave_base_value& rep = args(0).get_rep(); - serial = &((octave_serial &)rep); - - serial->srl_parity(args(1).string_value()); - return octave_value(); } // Returning current parity - // TODO: return current parity - - return octave_value("-N"); + return octave_value(serial->get_parity()); } -int octave_serial::srl_parity(string parity) +int octave_serial::set_parity(string parity) { // Convert string to lowercase std::transform(parity.begin(), parity.end(), parity.begin(), ::tolower); @@ -108,10 +117,20 @@ return false; } - if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { + 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 Modified: trunk/octave-forge/main/serial/src/srl_read.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_read.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_read.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -16,8 +16,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> #include <octave/ov-uint8.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -37,7 +35,17 @@ #include "serial.h" // PKG_ADD: autoload ("srl_read", "serial.oct"); -DEFUN_DLD (srl_read, args, nargout, "Hello World Help String") +DEFUN_DLD (srl_read, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {[@var{data}, @var{count}] = } srl_read (@var{serial}, @var{n})\n \ +\n\ +Read from serial interface.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{n} - number of bytes to attempt to read of type Integer.\n \ +\n\ +The srl_read() shall return number of bytes successfully read in @var{count} as Integer and the bytes themselves in @var{data} as uint8 array.\n \ +@end deftypefn") { if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { @@ -77,7 +85,7 @@ // While buffer not full and not timeout while (buffer_read < buffer_len && read_retval != 0) { - read_retval = serial->srl_read(buffer + buffer_read, buffer_len - buffer_read); + read_retval = serial->read(buffer + buffer_read, buffer_len - buffer_read); buffer_read += read_retval; } @@ -86,9 +94,7 @@ // TODO: clean this up for (int i = 0; i < buffer_read; i++) - { data(i) = buffer[i]; - } return_list(1) = buffer_read; return_list(0) = data; @@ -98,7 +104,7 @@ return return_list; } -int octave_serial::srl_read(char *buf, unsigned int len) +int octave_serial::read(char *buf, unsigned int len) { - return ::read(srl_get_fd(), buf, len); + return ::read(get_fd(), buf, len); } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_stopbits.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_stopbits.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_stopbits.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -15,8 +15,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -36,7 +34,18 @@ #include "serial.h" // PKG_ADD: autoload ("srl_stopbits", "serial.oct"); -DEFUN_DLD (srl_stopbits, args, nargout, "Hello World Help String") +DEFUN_DLD (srl_stopbits, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_stopbits (@var{serial}, @var{stopb})\n \ +@deftypefnx {Loadable Function} {@var{sb} = } srl_stopbits (@var{serial})\n \ +\n\ +Set new or get existing serial interface stop bits parameter. Only 1 or 2 stop bits are supported.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{stopb} - number of stop bits used. Supported values: 1, 2.\n \ +\n\ +If @var{stopb} parameter is omitted, the srl_stopbits() shall return current stop bits value as the result @var{sb}.\n \ +@end deftypefn") { if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { @@ -44,6 +53,11 @@ return octave_value(-1); } + octave_serial* serial = NULL; + + const octave_base_value& rep = args(0).get_rep(); + serial = &((octave_serial &)rep); + // Setting new stop bits if (args.length() > 1) { @@ -53,24 +67,16 @@ return octave_value(-1); } - octave_serial* serial = NULL; + serial->set_stopbits(args(1).int_value()); - const octave_base_value& rep = args(0).get_rep(); - serial = &((octave_serial &)rep); - - serial->srl_stopbits(args(1).int_value()); - return octave_value(); } // Returning current stop bits - - // TODO: return current stop bits - - return octave_value(-1); + return octave_value(serial->get_stopbits()); } -int octave_serial::srl_stopbits(unsigned short stopbits) +int octave_serial::set_stopbits(unsigned short stopbits) { /* * CSTOPB Send two stop bits, else one. @@ -92,10 +98,18 @@ return false; } - if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { + if (tcsetattr(this->get_fd(), TCSANOW, &this->config) < 0) { error("srl_stopbits: error setting stop bits: %s\n", strerror(errno)); return false; } return true; +} + +int octave_serial::get_stopbits() +{ + if (BITMASK_CHECK(this->config.c_cflag, CSTOPB)) + return 2; + else + return 1; } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_timeout.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_timeout.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_timeout.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -15,8 +15,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -36,14 +34,30 @@ #include "serial.h" // PKG_ADD: autoload ("srl_timeout", "serial.oct"); -DEFUN_DLD (srl_timeout, args, nargout, "Hello World Help String") +DEFUN_DLD (srl_timeout, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {} srl_timeout (@var{serial}, @var{timeout})\n \ +@deftypefnx {Loadable Function} {@var{t} = } srl_timeout (@var{serial})\n \ +\n\ +Set new or get existing serial interface timeout parameter used for srl_read() requests. The timeout value is specified in tenths of a second.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{timeout} - srl_read() timeout value in tenths of a second. Maximum value of 255 (i.e. 25.5 seconds).\n \ +\n\ +If @var{timeout} parameter is omitted, the srl_timeout() shall return current timeout value as the result @var{t}.\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 timeout if (args.length() > 1) { @@ -53,24 +67,16 @@ return octave_value(-1); } - octave_serial* serial = NULL; + serial->set_timeout(args(1).int_value()); - const octave_base_value& rep = args(0).get_rep(); - serial = &((octave_serial &)rep); - - serial->srl_timeout(args(1).int_value()); - - return octave_value(); + return octave_value(); // Should it return by default? } // Returning current timeout - - // TODO: return current timeout - - return octave_value(0); + return octave_value(serial->get_timeout()); } -int octave_serial::srl_timeout(short timeout) +int octave_serial::set_timeout(short timeout) { if (timeout < 0 || timeout > 255) { @@ -87,18 +93,26 @@ this->config.c_cc[VMIN] = 1; this->config.c_cc[VTIME] = 0; } - */ - + */ + // Enable timeout, disable blocking read this->blocking_read = false; BITMASK_CLEAR(this->config.c_lflag, ICANON); // Set non-canonical mode this->config.c_cc[VMIN] = 0; this->config.c_cc[VTIME] = (unsigned) timeout; // Set timeout of 'timeout * 10' seconds - - if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { + + if (tcsetattr(this->get_fd(), TCSANOW, &this->config) < 0) { error("srl_timeout: error setting stop bits..."); return false; } return true; +} + +int octave_serial::get_timeout() +{ + if (blocking_read) + return -1; + else + return this->config.c_cc[VTIME]; } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_write.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-30 09:15:20 UTC (rev 10934) +++ trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-30 22:17:16 UTC (rev 10935) @@ -15,8 +15,6 @@ #include <octave/oct.h> #include <octave/ov-int32.h> -//#include <octave/ops.h> -//#include <octave/ov-typeinfo.h> #include <iostream> #include <string> @@ -36,7 +34,17 @@ #include "serial.h" // PKG_ADD: autoload ("srl_write", "serial.oct"); -DEFUN_DLD (srl_write, args, nargout, "Hello World Help String") +DEFUN_DLD (srl_write, args, nargout, +"-*- texinfo -*-\n\ +@deftypefn {Loadable Function} {@var{n} = } srl_write (@var{serial}, @var{data})\n \ +\n\ +Write data to a serial interface.\n \ +\n\ +@var{serial} - instance of @var{octave_serial} class.@*\ +@var{data} - data to be written to the serial interface. Can be either of String or uint8 type.\n \ +\n\ +Upon successful completion, srl_write() shall return the number of bytes written as the result @var{n}.\n \ +@end deftypefn") { if (args.length() != 2 || args(0).type_id() != octave_serial::static_type_id()) { @@ -52,7 +60,7 @@ if (args(1).is_string()) // String { - retval = serial->srl_write(args(1).string_value()); + retval = serial->write(args(1).string_value()); } else if (args(1).byte_size() == args(1).numel()) // uint8_t { @@ -63,7 +71,7 @@ for (int i = 0; i < data.length(); i++) buf[i] = (unsigned char)data(i); - retval = serial->srl_write(buf, data.length()); + retval = serial->write(buf, data.length()); delete[] buf; } @@ -76,12 +84,12 @@ return octave_value(retval); } -int octave_serial::srl_write(string str) +int octave_serial::write(string str) { - return ::write(srl_get_fd(), str.c_str(), str.length()); + return ::write(get_fd(), str.c_str(), str.length()); } -int octave_serial::srl_write(unsigned char *buf, int len) +int octave_serial::write(unsigned char *buf, int len) { - return ::write(srl_get_fd(), buf, len); + return ::write(get_fd(), buf, len); } \ 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: <cd...@us...> - 2012-08-30 09:15:29
|
Revision: 10934 http://octave.svn.sourceforge.net/octave/?rev=10934&view=rev Author: cdf Date: 2012-08-30 09:15:20 +0000 (Thu, 30 Aug 2012) Log Message: ----------- corrected typo in NEWS file Modified Paths: -------------- trunk/octave-forge/extra/fpl/NEWS Modified: trunk/octave-forge/extra/fpl/NEWS =================================================================== --- trunk/octave-forge/extra/fpl/NEWS 2012-08-30 07:28:18 UTC (rev 10933) +++ trunk/octave-forge/extra/fpl/NEWS 2012-08-30 09:15:20 UTC (rev 10934) @@ -1,9 +1,9 @@ -Summary of important user-visible changes for dataframe 1.3.1: +Summary of important user-visible changes for fpl 1.3.1: ------------------------------------------------------------------- * 1.3.1 is just a bugfix release to fix some issues in 1.3.0 -Summary of important user-visible changes for dataframe 1.3.0: +Summary of important user-visible changes for fpl 1.3.0: ------------------------------------------------------------------- * Old OpenDX based functions have been deprecated This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-30 07:28:24
|
Revision: 10933 http://octave.svn.sourceforge.net/octave/?rev=10933&view=rev Author: paramaniac Date: 2012-08-30 07:28:18 +0000 (Thu, 30 Aug 2012) Log Message: ----------- control: fix a problem where an error was raised about an "undefined" function issiso Modified Paths: -------------- trunk/octave-forge/main/control/NEWS trunk/octave-forge/main/control/inst/sensitivity.m Modified: trunk/octave-forge/main/control/NEWS =================================================================== --- trunk/octave-forge/main/control/NEWS 2012-08-30 06:02:40 UTC (rev 10932) +++ trunk/octave-forge/main/control/NEWS 2012-08-30 07:28:18 UTC (rev 10933) @@ -7,6 +7,10 @@ ** plot A selection of experiments from iddata identification datasets can be plotted by plot (dat, exp) instead of plot (dat(:,:,:,exp)). + +** sensitivity + Fixed a problem where an error was raised about an undefined function + "issiso". =============================================================================== Modified: trunk/octave-forge/main/control/inst/sensitivity.m =================================================================== --- trunk/octave-forge/main/control/inst/sensitivity.m 2012-08-30 06:02:40 UTC (rev 10932) +++ trunk/octave-forge/main/control/inst/sensitivity.m 2012-08-30 07:28:18 UTC (rev 10933) @@ -109,12 +109,12 @@ if (length (Ms) > 1) error ("sensitivity: plotting only works for a single controller"); endif + if (iscell (L)) + L = L{1}; + endif if (! issiso (L)) error ("sensitivity: Nyquist plot requires SISO systems"); endif - if (iscell (L)) - L = L{1}; - endif [H, w] = __frequency_response__ (L, [], false, 0, "ext"); H = H(:); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-30 06:02:49
|
Revision: 10932 http://octave.svn.sourceforge.net/octave/?rev=10932&view=rev Author: paramaniac Date: 2012-08-30 06:02:40 +0000 (Thu, 30 Aug 2012) Log Message: ----------- control: support the selection of certain experiments when plotting datasets Modified Paths: -------------- trunk/octave-forge/main/control/NEWS trunk/octave-forge/main/control/inst/@iddata/plot.m Modified: trunk/octave-forge/main/control/NEWS =================================================================== --- trunk/octave-forge/main/control/NEWS 2012-08-29 23:18:40 UTC (rev 10931) +++ trunk/octave-forge/main/control/NEWS 2012-08-30 06:02:40 UTC (rev 10932) @@ -1,6 +1,15 @@ Summary of important user-visible changes for releases of the control package =============================================================================== +control-2.3.54 Release Date: 2012-xx-yy Release Manager: Lukas Reichlin +=============================================================================== + +** plot + A selection of experiments from iddata identification datasets can be + plotted by plot (dat, exp) instead of plot (dat(:,:,:,exp)). + + +=============================================================================== control-2.3.53 Release Date: 2012-08-27 Release Manager: Lukas Reichlin =============================================================================== Modified: trunk/octave-forge/main/control/inst/@iddata/plot.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/plot.m 2012-08-29 23:18:40 UTC (rev 10931) +++ trunk/octave-forge/main/control/inst/@iddata/plot.m 2012-08-30 06:02:40 UTC (rev 10932) @@ -17,23 +17,37 @@ ## -*- texinfo -*- ## @deftypefn {Function File} plot (@var{dat}) +## @deftypefnx {Function File} plot (@var{dat}, @var{exp}) ## Plot signals of iddata identification datasets on the screen. ## The signals are plotted experiment-wise, either in time- or ## frequency-domain. For multi-experiment datasets, ## press any key to switch to the next experiment. ## If the plot of a single experiment should be saved by the -## @command{print} command, use @code{plot(dat(:,:,:,exp))}, +## @command{print} command, use @code{plot(dat,exp)}, ## where @var{exp} denotes the desired experiment. ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: February 2012 -## Version: 0.1 +## Version: 0.2 -function plot (dat) +function plot (dat, exp = ":") + if (nargin > 2) # nargin == 0 is handled by built-in plot + print_usage (); + endif + + if (nargin == 2 && ! is_real_vector (exp)) + error ("iddata: plot: second argument must be a vector of indices"); + endif + + expname = __labels__ (dat.expname, "exp"); + expname = expname(exp); + + idx = substruct ("()", {":", ":", ":", exp}); + dat = subsref (dat, idx); + [n, p, m, e] = size (dat); - expname = __labels__ (dat.expname, "exp"); if (dat.timedomain) if (m == 0) # time series This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ean...@us...> - 2012-08-29 23:18:48
|
Revision: 10931 http://octave.svn.sourceforge.net/octave/?rev=10931&view=rev Author: eandrius Date: 2012-08-29 23:18:40 +0000 (Wed, 29 Aug 2012) Log Message: ----------- serial: srl_write now also accepts uint8 array as data argument Modified Paths: -------------- trunk/octave-forge/main/serial/src/serial.cc trunk/octave-forge/main/serial/src/serial.h trunk/octave-forge/main/serial/src/srl_flush.cc trunk/octave-forge/main/serial/src/srl_write.cc Modified: trunk/octave-forge/main/serial/src/serial.cc =================================================================== --- trunk/octave-forge/main/serial/src/serial.cc 2012-08-29 21:57:44 UTC (rev 10930) +++ trunk/octave-forge/main/serial/src/serial.cc 2012-08-29 23:18:40 UTC (rev 10931) @@ -179,5 +179,7 @@ retval->srl_bytesize(bytesize); retval->srl_stopbits(stopbits); + retval->srl_flush(); + return octave_value(retval); } Modified: trunk/octave-forge/main/serial/src/serial.h =================================================================== --- trunk/octave-forge/main/serial/src/serial.h 2012-08-29 21:57:44 UTC (rev 10930) +++ trunk/octave-forge/main/serial/src/serial.h 2012-08-29 23:18:40 UTC (rev 10931) @@ -38,10 +38,12 @@ int srl_get_fd(); int srl_write(string); + int srl_write(unsigned char*, int); int srl_read(char *, unsigned int); int srl_close(); int srl_flush(unsigned short); + int srl_flush(); int srl_timeout(short); int srl_baudrate(unsigned int); Modified: trunk/octave-forge/main/serial/src/srl_flush.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-29 21:57:44 UTC (rev 10930) +++ trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-29 23:18:40 UTC (rev 10931) @@ -88,4 +88,9 @@ } return ::tcflush(this->srl_get_fd(), flag); +} + +int octave_serial::srl_flush() +{ + return srl_flush(2); } \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_write.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-29 21:57:44 UTC (rev 10930) +++ trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-29 23:18:40 UTC (rev 10931) @@ -35,29 +35,53 @@ #include "serial.h" -// TODO: implement uint8 array as input type // PKG_ADD: autoload ("srl_write", "serial.oct"); DEFUN_DLD (srl_write, args, nargout, "Hello World Help String") { - if (args.length() != 2 || - args(0).type_id() != octave_serial::static_type_id() || - !args(1).is_string()) + if (args.length() != 2 || args(0).type_id() != octave_serial::static_type_id()) { print_usage(); return octave_value(-1); } - + octave_serial* serial = NULL; + int retval; const octave_base_value& rep = args(0).get_rep(); serial = &((octave_serial &)rep); - serial->srl_write(args(1).string_value()); + if (args(1).is_string()) // String + { + retval = serial->srl_write(args(1).string_value()); + } + else if (args(1).byte_size() == args(1).numel()) // uint8_t + { + NDArray data = args(1).array_value(); + unsigned char* buf = new unsigned char[data.length()]; + + // memcpy? + for (int i = 0; i < data.length(); i++) + buf[i] = (unsigned char)data(i); + + retval = serial->srl_write(buf, data.length()); + + delete[] buf; + } + else + { + print_usage(); + return octave_value(-1); + } - return octave_value(); + return octave_value(retval); } int octave_serial::srl_write(string str) { return ::write(srl_get_fd(), str.c_str(), str.length()); +} + +int octave_serial::srl_write(unsigned char *buf, int len) +{ + return ::write(srl_get_fd(), buf, len); } \ 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: <ean...@us...> - 2012-08-29 21:57:50
|
Revision: 10930 http://octave.svn.sourceforge.net/octave/?rev=10930&view=rev Author: eandrius Date: 2012-08-29 21:57:44 +0000 (Wed, 29 Aug 2012) Log Message: ----------- serial: better error reporting Modified Paths: -------------- trunk/octave-forge/main/serial/src/serial.cc trunk/octave-forge/main/serial/src/srl_baudrate.cc trunk/octave-forge/main/serial/src/srl_bytesize.cc trunk/octave-forge/main/serial/src/srl_close.cc trunk/octave-forge/main/serial/src/srl_flush.cc trunk/octave-forge/main/serial/src/srl_parity.cc trunk/octave-forge/main/serial/src/srl_read.cc trunk/octave-forge/main/serial/src/srl_stopbits.cc trunk/octave-forge/main/serial/src/srl_timeout.cc trunk/octave-forge/main/serial/src/srl_write.cc Modified: trunk/octave-forge/main/serial/src/serial.cc =================================================================== --- trunk/octave-forge/main/serial/src/serial.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/serial.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -54,8 +54,12 @@ octave_serial::octave_serial(string path, int flags) { this->fd = open(path.c_str(), flags, 0); - tcgetattr(this->fd, &this->config); - this->blocking_read = true; + + if (this->fd > 0) + { + tcgetattr(this->fd, &this->config); + this->blocking_read = true; + } } octave_serial::~octave_serial() @@ -82,21 +86,20 @@ // PKG_ADD: autoload ("serial", "serial.oct"); DEFUN_DLD (serial, args, nargout, "Hello World Help String") { +#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) { - error("serial: serial() function has one mandatory output argument"); + print_usage(); return octave_value(); } - - -#ifdef __WIN32__ - error("serial: Windows platform support is not yet implemented, go away..."); - return octave_value(); -#endif - + // Default values string path("/dev/ttyUSB0"); unsigned int baud_rate = 115200; @@ -123,7 +126,7 @@ } else { - error("serial: 1st argument must be an interface path of type string..."); + print_usage(); return octave_value(); } @@ -139,7 +142,7 @@ } else { - error("serial: 2nd argument must be an interface baud rate of type integer..."); + print_usage(); return octave_value(); } } @@ -152,7 +155,7 @@ } else { - error("serial: 3rd argument must be an timeout of type integer..."); + print_usage(); return octave_value(); } } @@ -162,10 +165,10 @@ if (retval->srl_get_fd() < 0) { - error("serial: Error opening the interface..."); + error("serial: Error opening the interface: %s\n", strerror(errno)); return octave_value(); } - + retval->srl_baudrate(baud_rate); if (timeout >= 0) { Modified: trunk/octave-forge/main/serial/src/srl_baudrate.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_baudrate.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_baudrate.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -115,7 +115,9 @@ case 230400: baud_rate = B230400; break; default: - error("srl_baudrate: currently only standard baud rates are supported..."); + error("srl_baudrate: currently only 0, 50, 75, 110, \ + 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, \ + 9600 19200, 38400, 5760, 115200 and 230400 baud rates are supported..."); return false; } @@ -123,7 +125,7 @@ cfsetospeed(&this->config, baud_rate); if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { - error("srl_baudrate: error setting baud rate..."); + error("srl_baudrate: error setting baud rate: %s\n", strerror(errno)); return false; } Modified: trunk/octave-forge/main/serial/src/srl_bytesize.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_bytesize.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_bytesize.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -38,24 +38,18 @@ // PKG_ADD: autoload ("srl_bytesize", "serial.oct"); DEFUN_DLD (srl_bytesize, args, nargout, "Hello World Help String") { - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_bytesize: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_bytesize: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - // Setting new byte size if (args.length() > 1) { if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) { - error("srl_bytesize: expecting second argument of type integer..."); + print_usage(); return octave_value(-1); } @@ -106,7 +100,7 @@ this->config.c_cflag |= c_bytesize; if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { - error("srl_bytesize: error setting byte size..."); + error("srl_bytesize: error setting byte size: %s\n", strerror(errno)); return false; } Modified: trunk/octave-forge/main/serial/src/srl_close.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_close.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_close.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -38,18 +38,12 @@ // PKG_ADD: autoload ("srl_close", "serial.oct"); DEFUN_DLD (srl_close, args, nargout, "Hello World Help String") { - if (args.length() != 1) + if (args.length() != 1 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_close: expecting one argument..."); + print_usage(); return octave_value(-1); } - - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_close: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - + octave_serial* serial = NULL; const octave_base_value& rep = args(0).get_rep(); Modified: trunk/octave-forge/main/serial/src/srl_flush.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_flush.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -36,52 +36,21 @@ #include "serial.h" // PKG_ADD: autoload ("srl_flush", "serial.oct"); -int octave_serial::srl_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->srl_get_fd(), flag); -} - -// PKG_ADD: autoload ("srl_flush", "serial.oct"); DEFUN_DLD (srl_flush, args, nargout, "Hello World Help String") { int queue_selector = 2; // Input and Output - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_write: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_write: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - - if (args.length() > 1) { if (!(args(1).is_integer_type() || args(1).is_float_type())) { - error("srl_write: expecting second argument of type integer..."); + print_usage(); return octave_value(-1); } @@ -97,3 +66,26 @@ return octave_value(); } + +int octave_serial::srl_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->srl_get_fd(), flag); +} \ No newline at end of file Modified: trunk/octave-forge/main/serial/src/srl_parity.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_parity.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_parity.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -38,24 +38,18 @@ // PKG_ADD: autoload ("srl_parity", "serial.oct"); DEFUN_DLD (srl_parity, args, nargout, "Hello World Help String") { - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_parity: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_parity: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - // Setting new parity if (args.length() > 1) { if ( !(args(1).is_string()) ) { - error("srl_parity: expecting second argument of type string..."); + print_usage(); return octave_value(-1); } @@ -115,7 +109,7 @@ } if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { - error("srl_parity: error setting parity..."); + error("srl_parity: error setting parity: %s\n", strerror(errno)); return false; } Modified: trunk/octave-forge/main/serial/src/srl_read.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_read.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_read.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -39,18 +39,12 @@ // PKG_ADD: autoload ("srl_read", "serial.oct"); DEFUN_DLD (srl_read, args, nargout, "Hello World Help String") { - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_read: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_read: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - char *buffer = NULL; unsigned int buffer_len = 1; @@ -58,7 +52,7 @@ { if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) { - error("srl_read: expecting second argument of type integer..."); + print_usage(); return octave_value(-1); } @@ -69,7 +63,7 @@ if (buffer == NULL) { - error("srl_read: cannot allocate requested memory..."); + error("srl_read: cannot allocate requested memory: %s\n", strerror(errno)); return octave_value(-1); } Modified: trunk/octave-forge/main/serial/src/srl_stopbits.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_stopbits.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_stopbits.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -38,24 +38,18 @@ // PKG_ADD: autoload ("srl_stopbits", "serial.oct"); DEFUN_DLD (srl_stopbits, args, nargout, "Hello World Help String") { - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_stopbits: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_stopbits: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - // Setting new stop bits if (args.length() > 1) { if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) { - error("srl_stopbits: expecting second argument of type integer..."); + print_usage(); return octave_value(-1); } @@ -99,7 +93,7 @@ } if (tcsetattr(this->srl_get_fd(), TCSANOW, &this->config) < 0) { - error("srl_stopbits: error setting stop bits..."); + error("srl_stopbits: error setting stop bits: %s\n", strerror(errno)); return false; } Modified: trunk/octave-forge/main/serial/src/srl_timeout.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_timeout.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_timeout.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -38,24 +38,18 @@ // PKG_ADD: autoload ("srl_timeout", "serial.oct"); DEFUN_DLD (srl_timeout, args, nargout, "Hello World Help String") { - if (args.length() < 1 || args.length() > 2) + if (args.length() < 1 || args.length() > 2 || args(0).type_id() != octave_serial::static_type_id()) { - error("srl_timeout: expecting one or two arguments..."); + print_usage(); return octave_value(-1); } - if (args(0).type_id() != octave_serial::static_type_id()) - { - error("srl_timeout: expecting first argument of type octave_serial..."); - return octave_value(-1); - } - // Setting new timeout if (args.length() > 1) { if ( !(args(1).is_integer_type() || args(1).is_float_type()) ) { - error("srl_timeout: expecting second argument of type integer..."); + print_usage(); return octave_value(-1); } Modified: trunk/octave-forge/main/serial/src/srl_write.cc =================================================================== --- trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-29 19:31:12 UTC (rev 10929) +++ trunk/octave-forge/main/serial/src/srl_write.cc 2012-08-29 21:57:44 UTC (rev 10930) @@ -39,7 +39,7 @@ // PKG_ADD: autoload ("srl_write", "serial.oct"); DEFUN_DLD (srl_write, args, nargout, "Hello World Help String") { - if (args.length() != 2) || + if (args.length() != 2 || args(0).type_id() != octave_serial::static_type_id() || !args(1).is_string()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nir...@us...> - 2012-08-29 19:31:18
|
Revision: 10929 http://octave.svn.sourceforge.net/octave/?rev=10929&view=rev Author: nir-krakauer Date: 2012-08-29 19:31:12 +0000 (Wed, 29 Aug 2012) Log Message: ----------- fixed some typos in zscore help text Modified Paths: -------------- trunk/octave-forge/extra/NaN/inst/zscore.m Modified: trunk/octave-forge/extra/NaN/inst/zscore.m =================================================================== --- trunk/octave-forge/extra/NaN/inst/zscore.m 2012-08-29 16:54:42 UTC (rev 10928) +++ trunk/octave-forge/extra/NaN/inst/zscore.m 2012-08-29 19:31:12 UTC (rev 10929) @@ -1,13 +1,13 @@ function [i,v,m] = zscore(i,DIM) -% ZSCORE removes the mean and normalizes the data -% to a variance of 1. Can be used for Pre-Whitening of the data, too. +% ZSCORE removes the mean and normalizes data +% to a variance of 1. Can be used for pre-whitening of data, too. % % [z,r,m] = zscore(x,DIM) % z z-score of x along dimension DIM % r is the inverse of the standard deviation % m is the mean of x % -% The data x can be reconstrated with +% The data x can be reconstucted with % x = z*diag(1./r) + repmat(m,size(z)./size(m)) % z = x*diag(r) - repmat(m.*v,size(z)./size(m)) % @@ -61,4 +61,4 @@ v = 1./sqrt(mean(i.^2,DIM,W)); i = i.*repmat(v,size(i)./size(v)); % scale to var=1 - \ 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: <cd...@us...> - 2012-08-29 16:54:53
|
Revision: 10928 http://octave.svn.sourceforge.net/octave/?rev=10928&view=rev Author: cdf Date: 2012-08-29 16:54:42 +0000 (Wed, 29 Aug 2012) Log Message: ----------- improve first help sentences Modified Paths: -------------- trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Finalize.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Finalized.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Get_processor_name.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Init.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Initialized.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Iprobe.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc Removed Paths: ------------- trunk/octave-forge/main/openmpi_ext/inst/allnodes Deleted: trunk/octave-forge/main/openmpi_ext/inst/allnodes =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/allnodes 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/inst/allnodes 2012-08-29 16:54:42 UTC (rev 10928) @@ -1,7 +0,0 @@ -#!/bin/bash -# this script will run an Octave script using MPI with a given hostfile, -# using a given number of ranks. Edit it to set the hostfile and number of nodes -# then use it as follows: allnodes <your_script_name.m> -HOSTFILE="/home/user/tmp/bhosts" -NUMBER_OF_NODES="33" -mpirun --hostfile $HOSTFILE -np $NUMBER_OF_NODES octave -q --eval $1 Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -28,9 +28,9 @@ DEFUN_DLD (NAME, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} @var{INFO} = MPI_Barrier (@var{COMM})\n\ -Blocks until all processes in the communicator have reached this routine.\n\ -If @var{COMM} octave comunicator object loaded with MPI_Comm_Load is omitted \n\ -returns an error. \n\ +Block processes in the communicator @var{COMM} untill the call to this routine has been reached by all.\n\ +The communicator object @var{COMM} (loaded with MPI_Comm_Load) must be specified otherwise \n\ +an error occurs. \n\ @example\n\ @group\n\ @var{INFO} (int) return code\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -17,7 +17,7 @@ #include "simple.h" DEFUN_DLD(MPI_Comm_Test, args, ,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} @var{DESCRIPTION} = MPI_Comm_Test (@var{COMM})\n\ -Return @var{DESCRIPTION} string description of the MPI_Communicator @var{COMM}\n\ +Return @var{DESCRIPTION} string description of the MPI_Communicator @var{COMM}.\n\ For\n\ example,\n\ \n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -26,9 +26,9 @@ #include "simple.h" DEFUN_DLD(NAME, args,nargout ,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} [@var{RANK} @var{INFO}] = MPI_Comm_rank (@var{COMM})\n\ -Determines rank of calling process in communicator.\n\ -If @var{COMM} octave comunicator object loaded with MPI_Comm_Load is omitted \n\ -returns an error. \n\ +Return the rank of the calling process in the specified communicator.\n\ +If the comunicator object @var{COMM} (loaded with MPI_Comm_Load) is omitted \n\ +an error is thrown. \n\ @example\n\ @group\n\ @var{RANK} rank of the calling process in group of communicator\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -26,9 +26,9 @@ #include "simple.h" DEFUN_DLD(NAME, args,nargout ,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} [@var{RANK} @var{INFO}] = MPI_Comm_size (@var{COMM})\n\ -Determines size of calling process in communicator.\n\ -If @var{COMM} octave comunicator object loaded with MPI_Comm_Load is omitted \n\ -returns an error. \n\ +Return the size of a communicator.\n\ +The comunicator object @var{COMM} (loaded with MPI_Comm_Load) must be sepcified \n\ +or otherwise an error occurs. \n\ @example\n\ @group\n\ @var{exprank} rank of the calling process in group of communicator\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Finalize.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Finalize.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Finalize.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -27,8 +27,8 @@ #include <octave/oct.h> DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} @var{INFO} = MPI_Finalize()\n\ - Terminates MPI execution environment\n\ +@deftypefn {Loadable Function} {} @var{INFO} = MPI_Finalize ()\n\ +Terminate the MPI execution environment.\n\ \n\ @example\n\ @group\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Finalized.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Finalized.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Finalized.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -24,8 +24,8 @@ #include "mpi.h" #include <octave/oct.h> DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} [@var{FLAG} @var{INFO}] = MPI_Finalized\n\ - Indicates whether MPI_Finalize has completed\n\ +@deftypefn {Loadable Function} {[@var{FLAG}, @var{INFO}]} = MPI_Finalized ()\n\ +Indicates whether MPI_Finalize has been executed.\n\ \n\ @example\n\ @group\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Get_processor_name.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Get_processor_name.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Get_processor_name.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -19,8 +19,8 @@ #include <octave/oct.h> DEFUN_DLD(MPI_Get_processor_name, args, nargout,"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} @var{name,resultlen,INFO} = MPI_Get_processor_name()\n\ - Get the name of the processor that is using MPI\n\ +@deftypefn {Loadable Function} {} @var{name,resultlen,INFO} = MPI_Get_processor_name ()\n\ +Get the name of the processor that is using MPI.\n\ \n\ @example\n\ @group\n\ @@ -29,9 +29,9 @@ 16 MPI_ERR_OTHER Attempt was made to call MPI_Init a second time\n\ MPI_Init may only be called once in a program\n\ \n\ -SEE ALSO: MPI_Finalize, MPI_Initialized, MPI_Finalized\n\ @end group\n\ @end example\n\ +@seealso{MPI_Finalize, MPI_Initialized, MPI_Finalized}\n\ @end deftypefn") { int info; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Init.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Init.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Init.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -28,7 +28,7 @@ DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} @var{INFO} = MPI_Init()\n\ - Initialize the MPI execution environment\n\ +Initialize the MPI execution environment.\n\ \n\ @example\n\ @group\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Initialized.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Initialized.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Initialized.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -27,7 +27,7 @@ DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} [@var{FLAG} @var{INFO}] = MPI_Initialized\n\ - Indicates whether MPI_Init has been called\n\ +Indicates whether MPI_Init has been executed.\n\ \n\ @example\n\ @group\n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Iprobe.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Iprobe.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Iprobe.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -44,8 +44,8 @@ } DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} [@var{FLAG} @var{STAT} @var{INFO}] = MPI_Iprobe(@var{SRCRANK}, @var{TAG}, @var{COMM})\n \ - Nonblocking test for a message\n\ +@deftypefn {Loadable Function} {} [@var{FLAG} @var{STAT} @var{INFO}] = MPI_Iprobe(@var{SRCRANK}, @var{TAG}, @var{COMM})\n\ +Nonblocking test for an MPI message.\n\ @example\n\ @group\n\ \n\ @@ -67,7 +67,7 @@ @end group\n\ @end example\n\ \n\ - SEE ALSO: MPI_Probe, MPI_Recv, MPI documentation for examples\n\ +@seealso{MPI_Probe, MPI_Recv, MPI documentation for examples}\n\ @end deftypefn") { octave_value_list results; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -44,7 +44,7 @@ DEFUN_DLD(NAME, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} [@var{STAT} @var{INFO}] = MPI_Probe(@var{SRCRANK}, @var{TAG}, @var{COMM})\n \ - blocking test for a message\n\ +Blocking test for a message.\n\ @example\n\ @group\n\ \n\ @@ -63,7 +63,7 @@ @end group\n\ @end example\n\ \n\ - SEE ALSO: MPI_Iprobe, MPI_Recv, and MPI documentation for C examples\n\ +@seealso{MPI_Iprobe, MPI_Recv, and MPI documentation for C examples}\n\ @end deftypefn") { octave_value_list results; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -687,9 +687,9 @@ DEFUN_DLD(MPI_Recv, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} [@var{VALUE} @var{INFO}]= MPI_Recv(@var{SOURCE},@var{TAG},@var{COMM})\n\ -MPI_Recv receive any Octave datatype into contiguous memory using openmpi library even over an heterogeneous cluster i.e 32 bits CPUs and 64 bits CPU \n \n\ -Returns @var{VALUE} that is an octave variable received\n\ -and an integer @var{INFO} to indicate success or failure \ +Receive an MPI message containing an Octave variable packed into a contiguous memory chunk and extract its value.\n\ +The Octave variable being received is returned as @var{VALUE},\n\ +while @var{INFO} is an integer indicating success or failure.\n\ @example\n\ @group\n\ @var{SOURCE} must be an integer indicating source processes \n\ Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc 2012-08-29 16:28:49 UTC (rev 10927) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc 2012-08-29 16:54:42 UTC (rev 10928) @@ -749,9 +749,8 @@ DEFUN_DLD(MPI_Send, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{INFO} =} MPI_Send(@var{VALUE},@var{RANKS},@var{TAG},@var{COMM})\n\ -MPI_Send sends any octave_value into contiguous memory using openmpi library \n\ -even over an heterogeneous cluster i.e 32 bits CPUs and 64 bits CPU.\n\ -Returns an integer @var{INFO} to indicate success or failure of octave_value expedition.\n\ +Pack an Octave variable into a contiguous memory chunck and transmit it as an MPI message.\n\ +Return an integer @var{INFO} to indicate success or failure.\n\ @example\n\ @group\n\ @var{VALUE} must be an octave variable \n\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-08-29 16:28:57
|
Revision: 10927 http://octave.svn.sourceforge.net/octave/?rev=10927&view=rev Author: cdf Date: 2012-08-29 16:28:49 +0000 (Wed, 29 Aug 2012) Log Message: ----------- more changes for new release Modified Paths: -------------- trunk/octave-forge/main/openmpi_ext/DESCRIPTION trunk/octave-forge/main/openmpi_ext/INDEX trunk/octave-forge/main/openmpi_ext/inst/Pi.m trunk/octave-forge/main/openmpi_ext/inst/hello2dimmat.m trunk/octave-forge/main/openmpi_ext/inst/hellocell.m trunk/octave-forge/main/openmpi_ext/inst/hellosparsemat.m trunk/octave-forge/main/openmpi_ext/inst/hellostruct.m trunk/octave-forge/main/openmpi_ext/inst/helloworld.m trunk/octave-forge/main/openmpi_ext/inst/mc_example.m trunk/octave-forge/main/openmpi_ext/inst/montecarlo.m trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc Added Paths: ----------- trunk/octave-forge/main/openmpi_ext/NEWS trunk/octave-forge/main/openmpi_ext/README Removed Paths: ------------- trunk/octave-forge/main/openmpi_ext/doc/README Modified: trunk/octave-forge/main/openmpi_ext/DESCRIPTION =================================================================== --- trunk/octave-forge/main/openmpi_ext/DESCRIPTION 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/DESCRIPTION 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,8 +1,8 @@ Name: openmpi_ext -Version: 1.0.2 -Date: 2010-6-17 -Author: Riccardo Corradini <ric...@ya...> and the Octave Community -Maintainer: Riccardo Corradini <ric...@ya...> +Version: 1.1.0 +Date: 2012-8-29 +Author: Riccardo Corradini <ric...@ya...>, Jaroslav Hajek, Carlo de Falco +Maintainer: the Octave Community Title: openmpi_ext Description: MPI functions for parallel computing using simple MPI Derived Datatypes. Depends: octave (>= 3.2.4) Modified: trunk/octave-forge/main/openmpi_ext/INDEX =================================================================== --- trunk/octave-forge/main/openmpi_ext/INDEX 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/INDEX 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,9 +1,19 @@ openmpi_ext >> Openmpi_ext -Openmpi_ext - - MPI_Barrier MPI_Comm_Test MPI_Initialized MPI_Probe - MPI_Comm_Load MPI_Finalize MPI_Iprobe MPI_Recv - MPI_Comm_rank MPI_Finalized MPI_Op_Load MPI_Send - MPI_Comm_size MPI_Init MPI_Op_Test - hello2dimmat hellosparsemat helloworld montecarlo - hellocell hellostruct mc_example Pi +Octave Wrappers for MPI functions + MPI_Barrier MPI_Comm_Load + MPI_Comm_Test MPI_Comm_rank + MPI_Comm_size MPI_Finalize + MPI_Finalized + MPI_Get_processor_name + MPI_Init MPI_Initialized + MPI_Iprobe MPI_Probe + MPI_Recv MPI_Send +Examples + Pi + hello2dimmat + hellocell + hellosparsemat + hellostruct + helloworld + mc_example + montecarlo \ No newline at end of file Added: trunk/octave-forge/main/openmpi_ext/NEWS =================================================================== --- trunk/octave-forge/main/openmpi_ext/NEWS (rev 0) +++ trunk/octave-forge/main/openmpi_ext/NEWS 2012-08-29 16:28:49 UTC (rev 10927) @@ -0,0 +1,7 @@ +Summary of changes for openmpi_ext 1.1.0: +------------------------------------------------------------------- + + * Added help text and demos in all example scripts + + * Code clean-up and standardization, and some bug-fixes + Copied: trunk/octave-forge/main/openmpi_ext/README (from rev 10893, trunk/octave-forge/main/openmpi_ext/doc/README) =================================================================== --- trunk/octave-forge/main/openmpi_ext/README (rev 0) +++ trunk/octave-forge/main/openmpi_ext/README 2012-08-29 16:28:49 UTC (rev 10927) @@ -0,0 +1,77 @@ +CONTENTS: + +1) INSTALLATION INSTRUCTIONS + +The makefile included derives all the info it needs for building the code +from running mpicc, so make sure that mpicc is in your path before running Octave +or type + +putenv ("PATH", "/path/to/mpicc:${PATH}") + +from within Octave. +Once this is done you should be able to install openmpi_ext from a locally dowloaded tarball +by doing: + +pkg install openmpi_ext-<version>.tar.gz + +or directly from the ftp server by doing + +pkg install -forge openmpi_ext + + +2) ORIGINAL README + +-------------------- + +1) INSTALLATION INSTRUCTIONS + +2) ORIGINAL README + +Below are the contents of the original README file included with the first release +by R. Corradini, I am not sure all the info there still make sense but they are still +reported here, just in case ... + +The code is general-purpose, but I would like to use it for econometrics. +So the first step will be to install the following tarball from +http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.3.tar.bz2 +possibly in a multi-core computer to run my simple examples +and configure it for instance in the following way (/home/user is your $HOME) +./configure --enable-mpirun-prefix-by-default --enable-heterogeneous --prefix=/home/user/openmpi-1.3.3/ --enable-static + +and modify .bashrc in your home + OMPIBIN=`$ompi_info -path bindir -parsable | cut -d: -f3` + OMPILIB=`$ompi_info -path libdir -parsable | cut -d: -f3` + OMPISCD=`$ompi_info -path sysconfdir -parsable | cut -d: -f3` + + + +export PATH=$OMPIBIN:$PATH + +export LD_LIBRARY_PATH=:$OMPILIB:$LD_LIBRARY_PATH + +unset ompi_info OMPIBIN OMPILIB OMPISCD + +If you want to install it on a simple toy network, just assign a static ip address on every linux computer and set up +an ssh connection with no password (see for instance http://linuxproblem.org/art_9.html ) and then install openmpi and octave always with the same versions and with the same info on .bashrc for the same user. + +After this type in a terminal mpiCC --showme +In my case I will have something like + +g++ -I/home/user/openmpi-1.3.3/include -pthread -L/home/user/openmpi-1.3.3/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl + +This will be useful for mkoctfile +for instance for MPI_Init.cc we shall have +mkoctfile -I/home/user/openmpi-1.3.3/include -lpthread -L/home/user/openmpi-1.3.3/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -lnsl -lutil -lm -ldl MPI_Init.cc + + + +The m files just contain some very simple examples +More complex examples will be provided in the next future. +See also +http://static.msi.umn.edu/tutorial/scicomp/general/MPI/content6.html +to understand the logic of MPI Derived Datatypes and how could they be easily handled by openmpi_ext package. +Bests regards +Riccardo Corradini + + + Deleted: trunk/octave-forge/main/openmpi_ext/doc/README =================================================================== --- trunk/octave-forge/main/openmpi_ext/doc/README 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/doc/README 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,44 +0,0 @@ -The code is general-purpose, but I would like to use it for econometrics. -So the first step will be to install the following tarball from -http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.3.tar.bz2 -possibly in a multi-core computer to run my simple examples -and configure it for instance in the following way (/home/user is your $HOME) -./configure --enable-mpirun-prefix-by-default --enable-heterogeneous --prefix=/home/user/openmpi-1.3.3/ --enable-static - -and modify .bashrc in your home - OMPIBIN=`$ompi_info -path bindir -parsable | cut -d: -f3` - OMPILIB=`$ompi_info -path libdir -parsable | cut -d: -f3` - OMPISCD=`$ompi_info -path sysconfdir -parsable | cut -d: -f3` - - - -export PATH=$OMPIBIN:$PATH - -export LD_LIBRARY_PATH=:$OMPILIB:$LD_LIBRARY_PATH - -unset ompi_info OMPIBIN OMPILIB OMPISCD - -If you want to install it on a simple toy network, just assign a static ip address on every linux computer and set up -an ssh connection with no password (see for instance http://linuxproblem.org/art_9.html ) and then install openmpi and octave always with the same versions and with the same info on .bashrc for the same user. - -After this type in a terminal mpiCC --showme -In my case I will have something like - -g++ -I/home/user/openmpi-1.3.3/include -pthread -L/home/user/openmpi-1.3.3/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl - -This will be useful for mkoctfile -for instance for MPI_Init.cc we shall have -mkoctfile -I/home/user/openmpi-1.3.3/include -lpthread -L/home/user/openmpi-1.3.3/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -lnsl -lutil -lm -ldl MPI_Init.cc - - - -The m files just contain some very simple examples -More complex examples will be provided in the next future. -See also -http://static.msi.umn.edu/tutorial/scicomp/general/MPI/content6.html -to understand the logic of MPI Derived Datatypes and how could they be easily handled by openmpi_ext package. -Bests regards -Riccardo Corradini - - - Modified: trunk/octave-forge/main/openmpi_ext/inst/Pi.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/Pi.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/Pi.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -14,98 +14,113 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance addpath("../src"); -# mpirun -np 5 octave -q --eval "Pi(2E7,'s')" +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{result}]} = Pi () +## Classical MPI example that computes @var{PI} by integrating arctan'(x) in [0,1]. +## @var{N} [1e7] #subdivisions of the [0, 1] interval. +## @var{mod} ['s'] communication modality: (s)end (r)educe. +## @var{results} struct contains +## +## @itemize @minus +## @item @var{pi}: estimated pi value +## @item @var{err}: error +## @item @var{time}: from argument xmit to pi computed +## @end itemize +## +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; Pi ()' +## @end example +## @seealso{hello2dimmat,helloworld,hellocell,hellosparsemat,mc_example,montecarlo,hellostruct} +## @end deftypefn -function results = Pi(N,mod) -addpath("../src"); -# Pi: Classic PI computation by numeric integration of arctan'(x) in [0..1] -# -# Pi [ ( N [ ,mod ] ) ] -# -# N [1E7] #subdivisions of the [0, 1] interval -# mod ['s'] communication modality: (s)end (r)educe -# -# printed results struct contains -# pi estimated pi value -# err error -# time from argument xmit to pi computed -# - +function results = Pi (N, mod) + + ############ + ## ArgChk ## + ############ + if (nargin < 1) + N = 1E7; + end + if (nargin < 2) + mod = 's'; + end + if (nargin > 2) + print_usage (); # let all ranks complain + end + flag = 0; # code much simpler + flag = flag || ~isscalar (N) || ~isnumeric (N); + flag = flag || fix(N) ~= N || N < 1; + mod = lower (mod); mods = 'sr'; + flag = flag || isempty (findstr (mod, mods)); + if (flag) + print_usage (); # let them all error out + end -########## -# ArgChk # -########## -if nargin<1, N=1E7; end -if nargin<2, mod='s'; end -if nargin>2, usage("Pi(N,mod)"); end # let all ranks complain -flag=0; # code much simpler -flag=flag || ~isscalar(N) || ~isnumeric(N); -flag=flag | fix(N)~=N | N<1; - mod=lower(mod); mods='sr'; -flag=flag | isempty(findstr(mod, mods)); # let them all error out -if flag, usage("Pi( <int> N>0, <char> mod=='s|r' )"); end + #################### + ## Results struct ## + #################### + results.pi = 0; + results.err = 0; + results.time = 0; -################## -# Results struct # -################## -results.pi =0; -results.err =0; -results.time =0; + #################################################################### + ## PARALLEL: initialization, include MPI_Init time in measurement ## + #################################################################### - -############ -# PARALLEL # initialization, include MPI_Init time in measurement -############ T=clock; # -############ - MPI_ANY_SOURCE = -1; - MPI_Init(); - MPI_COMM_WORLD = MPI_Comm_Load("NEWORLD"); - rnk = MPI_Comm_rank (MPI_COMM_WORLD); # let it abort if it fails - siz = MPI_Comm_size (MPI_COMM_WORLD); + ############ + MPI_ANY_SOURCE = -1; + MPI_Init (); + MPI_COMM_WORLD = MPI_Comm_Load ("NEWORLD"); + rnk = MPI_Comm_rank (MPI_COMM_WORLD); # let it abort if it fails + siz = MPI_Comm_size (MPI_COMM_WORLD); - SLV = logical(rnk); # handy shortcuts, master is rank 0 - MST = ~ SLV; # slaves are all other + SLV = logical(rnk); # handy shortcuts, master is rank 0 + MST = ~ SLV; # slaves are all other -############ -# PARALLEL # computation (depends on rank/size) -############ # vectorized code, equivalent to - width=1/N; lsum=0; # for i=rnk:siz:N-1 - i=rnk:siz:N-1; # x=(i+0.5)*width; - x=(i+0.5)*width; # lsum=lsum+4/(1+x^2); - lsum=sum(4./(1+x.^2)); # end + ##################################################### + ## PARALLEL: computation (depends on rank/size) ## + ##################################################### -############ -# PARALLEL # reduction and finish -############ -switch mod - case 's', TAG=7; # Any tag would do - if SLV # All slaves send result back - MPI_Send(lsum, 0,TAG,MPI_COMM_WORLD); - else # Here at master - Sum =lsum; # save local result - for slv=1:siz-1 # collect in any order - lsum = MPI_Recv(MPI_ANY_SOURCE,TAG,MPI_COMM_WORLD); - Sum+=lsum; # and accumulate - end # order: slv or MPI_ANY_SOURCE - end - case 'r', - disp("not yet implemented"); -# Sum=0; -# reduction master = rank 0 @ WORLD -# MPI_Reduce(lsum,Sum, MPI_SUM, 0,MPI_COMM_WORLD); -end + width=1/N; lsum=0; # for i=rnk:siz:N-1 + i=rnk:siz:N-1; # x=(i+0.5)*width; + x=(i+0.5)*width; # lsum=lsum+4/(1+x^2); + lsum=sum(4./(1+x.^2)); # end -MPI_Finalize(); + ##################################### + ## PARALLEL: reduction and finish ## + ##################################### -if MST - Sum = Sum/N ; # better at end: don't loose resolution -################################# # stopwatch measurement -results.time = etime(clock,T); # # but only at master after PI computed -################################# # all them started T=clock; -results.err = Sum-pi; -results.pi = Sum # ; + switch mod + case 's', + TAG=7; # Any tag would do + if SLV # All slaves send result back + MPI_Send (lsum, 0, TAG, MPI_COMM_WORLD); + else # Here at master + Sum =lsum; # save local result + for slv=1:siz-1 # collect in any order + lsum = MPI_Recv (MPI_ANY_SOURCE, TAG, MPI_COMM_WORLD); + Sum += lsum; # and accumulate + endfor # order: slv or MPI_ANY_SOURCE + endif + case 'r', + disp ("not yet implemented"); + endswitch -end + MPI_Finalize (); + + if MST + Sum = Sum/N ; # better at end: don't loose resolution + ################################# # stopwatch measurement + results.time = etime(clock,T); # # but only at master after PI computed + ################################# # all them started T=clock; + results.err = Sum - pi; + results.pi = Sum # ; + endif + +endfunction + +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; Pi ()'"); Modified: trunk/octave-forge/main/openmpi_ext/inst/hello2dimmat.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/hello2dimmat.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/hello2dimmat.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,4 +1,5 @@ ## Copyright (C) 2009 Riccardo Corradini <ric...@ya...> +## Copyright (C) 2012 Carlo de Falco ## ## 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 @@ -13,39 +14,53 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance - addpath("../src"); - MPI_SUCCESS =0; - MPI_Init(); +## -*- texinfo -*- +## @deftypefn {Function File} {} = hello2dimmat () +## This function demonstrates sending and receiving of a 2-dimensional matrix over MPI. +## Each process in the pool will create a random 90x90 matrix and send it to process with rank 0. +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; hello2dimmat ()' +## @end example +## @seealso{hellocell,hellosparsemat,hellostruct,helloworld,mc_example,montecarlo,Pi} +## @end deftypefn - # the string NEWORLD is just a label could be whatever you want - CW = MPI_Comm_Load("NEWORLD"); - my_rank = MPI_Comm_rank(CW); - p = MPI_Comm_size(CW); +function hello2dimmat () + + MPI_SUCCESS = 0; + MPI_Init (); + + ## the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load ("NEWORLD"); + my_rank = MPI_Comm_rank (CW); + p = MPI_Comm_size (CW); mytag = 48; - - - + if (my_rank != 0) -# Generate a random matrix - message=rand(90,90); -# load message -# rankvect is the vector containing the list of rank destination process - rankvect = 0; - [info] = MPI_Send(message,rankvect,mytag,CW); + ## Generate a random matrix + message = rand (90, 90); + ## load message + ## rankvect is the vector containing the list of rank destination process + rankvect = 0; + [info] = MPI_Send (message, rankvect, mytag, CW); else - for source = 1:p-1 - disp("We are at rank 0 that is master etc.."); - [messager, info] = MPI_Recv(source,mytag,CW); - -# You could also save each result and make comparisons if you don't trust MPI - disp("Rank 0 is the master receiving ... :"); - if (info == MPI_SUCCESS) - disp('OK!'); - endif - endfor - end + for source = 1:p-1 + disp ("We are at rank 0 that is master etc.."); + [messager, info] = MPI_Recv (source, mytag, CW); + + ## You could also save each result and make comparisons if you don't trust MPI + disp ("Rank 0 is the master receiving ... :"); + if (info == MPI_SUCCESS) + disp ('OK!'); + endif + endfor + endif + MPI_Finalize (); - MPI_Finalize(); +endfunction + +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; hello2dimmat ()'"); + Modified: trunk/octave-forge/main/openmpi_ext/inst/hellocell.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/hellocell.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/hellocell.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,4 +1,5 @@ ## Copyright (C) 2009 Riccardo Corradini <ric...@ya...> +## Copyright (C) 2012 Carlo de Falco ## ## 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 @@ -13,41 +14,49 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance -addpath("../src"); -# if you have 4 cores or a network of 4 computers with a ssh connection with no password and same openmpi 1.3.3 installation -# type at the terminal mpirun -np 4 octave --eval hellocell +## -*- texinfo -*- +## @deftypefn {Function File} {} = hellocell () +## This function demonstrates sending and receiving a string message over MPI. +## Each process will send a message to process with rank 0, which will then display it. +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; hellocell ()' +## @end example +## @seealso{hello2dimmat,helloworld,hellosparsemat,hellostruct,mc_example,montecarlo,Pi} +## @end deftypefn +function hellocell () - MPI_Init(); - # the string NEWORLD is just a label could be whatever you want - CW = MPI_Comm_Load("NEWORLD"); + MPI_Init (); + ## the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load ("NEWORLD"); - + my_rank = MPI_Comm_rank (CW); + p = MPI_Comm_size (CW); - my_rank = MPI_Comm_rank(CW); - p = MPI_Comm_size(CW); - # TAG is very important to identify the message + ## TAG is very important to identify the message TAG = 1; - - message=""; if (my_rank != 0) - message = {magic(3) 17 'fred'; ... - 'AliceBettyCarolDianeEllen' 'yp' 42; ... - {1} 2 3}; - rankvect = 0; - [info] = MPI_Send(message,rankvect,TAG,CW); + message = {magic(3) 17 'fred'; ... + 'AliceBettyCarolDianeEllen' 'yp' 42; ... + {1} 2 3}; + rankvect = 0; + [info] = MPI_Send (message, rankvect, TAG, CW); else - for source = 1:p-1 - disp("We are at rank 0 that is master etc.."); - [messager, info] = MPI_Recv(source,TAG,CW); - info - messager - endfor - end + for source = 1:p-1 + disp ("We are at rank 0 that is master etc.."); + [messagerec, info] = MPI_Recv (source, TAG, CW); + info + messagerec + endfor + endif + MPI_Finalize (); + +endfunction - MPI_Finalize(); +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; hellocell ()'"); Modified: trunk/octave-forge/main/openmpi_ext/inst/hellosparsemat.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/hellosparsemat.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/hellosparsemat.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,4 +1,5 @@ ## Copyright (C) 2009 Riccardo Corradini <ric...@ya...> +## Copyright (C) 2012 Carlo de Falco ## ## 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 @@ -13,53 +14,71 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance - addpath("../src"); +## -*- texinfo -*- +## @deftypefn {Function File} {} = hellosparsemat () +## This function demonstrates sending and receiving a sparse matrix over MPI. +## Each process will send a a sparse matrix to process with rank 0, which will then display it. +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; hellosparsemat ()' +## @end example +## @seealso{hello2dimmat,helloworld,hellocell,hellostruct,mc_example,montecarlo,Pi} +## @end deftypefn + +function hellosparsemat () + MPI_Init(); - # the string NEWORLD is just a label could be whatever you want - CW = MPI_Comm_Load("NEWORLD"); - my_rank = MPI_Comm_rank(CW); - p = MPI_Comm_size(CW); -# tag[0] ----> type of octave_value -# tag[1] ----> array of three elements 1) num of rows 2) number of columns 3) number of non zero elements -# tag[2] ----> vector of rowindex -# tag[3] ----> vector of columnindex -# tag[4] ----> vector of non zero elements -# These tags will be generated after mytag by the MPI_Send and MPI_Recv (see source code) + ## the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load ("NEWORLD"); + my_rank = MPI_Comm_rank (CW); + p = MPI_Comm_size (CW); + ## tag[0] ----> type of octave_value + ## tag[1] ----> array of three elements 1) num of rows 2) number of columns 3) number of non zero elements + ## tag[2] ----> vector of rowindex + ## tag[3] ----> vector of columnindex + ## tag[4] ----> vector of non zero elements + ## These tags will be generated after mytag by the MPI_Send and MPI_Recv (see source code) mytag = 48; + + ## This is just to fill the sparse matrix + M = 5; + N = 5; + D = 0.9; + for one_by_one = p-1:-1:0 ## work one cpu at a time to make the output readable + if (my_rank != 0) + + message = sprand (M, N, D); + dest = 0; + info = MPI_Send (message, dest, mytag, CW); + printf ("on rank %d MPI_Send returned the following error code (0 = Success)\n", my_rank) + info + else -# This is just to fill the sparse matrix - M=5; - N=5; - D=0.9; - message = sprand (M, N, D); -# load message - + for source = 1:p-1 + + [messager, info] = MPI_Recv (source, mytag, CW); + + printf ("MPI_Recv returned the following error code (0 = Success) while receving from rank %d\n", source) + info + + printf ("This is the matrix received from rank %d: \n", source); + full (messager) - - if (my_rank != 0) - dest = 0; -# rankvect is the vector containing the list of rank destination process - rankvect(1,1) = 0; - [info] = MPI_Send(message,rankvect,mytag,CW); - disp("This is flag for sending the message --") - info - else - for source = 1:p-1 - messager=''; - disp("We are at rank 0 that is master etc.."); - [messager, info] = MPI_Recv(source,mytag,CW); - disp("Rank 0 is the master receiving ... :"); - if (messager/message) - disp('OK!'); - endif - messager - endfor - end + endfor + + endif + + MPI_Barrier (CW); + endfor + + MPI_Finalize (); + +endfunction - MPI_Finalize(); +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; hellosparsemat ()'"); Modified: trunk/octave-forge/main/openmpi_ext/inst/hellostruct.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/hellostruct.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/hellostruct.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,4 +1,5 @@ ## Copyright (C) 2009 Riccardo Corradini <ric...@ya...> +## Copyright (C) 2012 Carlo de Falco ## ## 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 @@ -13,37 +14,46 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance -addpath("../src"); -# if you have 4 cores or a network of 4 computers with a ssh connection with no password and same openmpi 1.3.3 installation -# type at the terminal mpirun -np 4 octave --eval hellostruct +## -*- texinfo -*- +## @deftypefn {Function File} {} = hellostruct () +## This function demonstrates sending and receiving a struct over MPI. +## Each process will send a a struct to process with rank 0, which will then display it. +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; hellostruct ()' +## @end example +## @seealso{hello2dimmat,helloworld,hellocell,hellosparsemat,mc_example,montecarlo,Pi} +## @end deftypefn +function hellostruct () - MPI_Init(); - # the string NEWORLD is just a label could be whatever you want - CW = MPI_Comm_Load("NEWORLD"); + MPI_Init (); + ## the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load ("NEWORLD"); - + my_rank = MPI_Comm_rank (CW); + p = MPI_Comm_size (CW); - my_rank = MPI_Comm_rank(CW); - p = MPI_Comm_size(CW); - # TAG is very important to identify the message + ## TAG is very important to identify the message TAG = 1; - - message=""; if (my_rank != 0) - message = struct('f1', {1 3; 2 4}, 'f2', 25); - # Could be a vector containing the list of ranks identifiers; - rankvect = 0; - [info] = MPI_Send(message,rankvect,TAG,CW); + message = struct ("f1", {1 3; 2 4}, "f2", 25); + ## Could be a vector containing the list of ranks identifiers; + rankvect = 0 + info = MPI_Send (message, rankvect, TAG, CW); else - for source = 1:p-1 - disp("We are at rank 0 that is master etc.."); - [message, info] = MPI_Recv(source,TAG,CW); - message - endfor - end - MPI_Finalize(); + for source = 1:p-1 + disp ("We are at rank 0 that is master etc.."); + [messagerec, info] = MPI_Recv (source, TAG, CW); + messagerec + endfor + endif + MPI_Finalize (); + +endfunction + +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; hellostruct ()'"); Modified: trunk/octave-forge/main/openmpi_ext/inst/helloworld.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/helloworld.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/helloworld.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -1,4 +1,5 @@ ## Copyright (C) 2009 Riccardo Corradini <ric...@ya...> +## Copyright (C) 2012 Carlo de Falco ## ## 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 @@ -13,38 +14,48 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# Please add the oct files openmpi_ext folder -# For instance -addpath('../src'); -# if you have 4 cores or a network of 4 computers with a ssh connection with no password and same openmpi 1.3.3 installation -# type at the terminal mpirun -np 4 octave --eval helloworld +## -*- texinfo -*- +## @deftypefn {Function File} {} = helloworld () +## This function demonstrates sending and receiving a string message over MPI. +## Each process will send a message to process with rank 0, which will then display it. +## To run this example, set the variables HOSTFILE and NUMBER_OF_MPI_NODES to appropriate values, +## then type the following command in your shell: +## @example +## mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave --eval 'pkg load openmpi_ext; helloworld ()' +## @end example +## @seealso{hello2dimmat,hellocell,hellosparsemat,hellostruct,mc_example,montecarlo,Pi} +## @end deftypefn +function helloworld () - MPI_Init(); - # the string NEWORLD is just a label could be whatever you want - CW = MPI_Comm_Load("NEWORLD"); + MPI_Init(); + ## the string NEWORLD is just a label could be whatever you want + CW = MPI_Comm_Load("NEWORLD"); + + my_rank = MPI_Comm_rank (CW); + p = MPI_Comm_size (CW); - + ## Could be any number + TAG = 1; - my_rank = MPI_Comm_rank(CW); - p = MPI_Comm_size(CW); - # Could be any number - TAG=1; - - - message=""; + message = ""; if (my_rank != 0) - message = sprintf('Greetings from process: %d!',my_rank); - # rankvect is the vector containing the list of rank destination process - rankvect = 0; - [info] = MPI_Send(message,rankvect,TAG,CW); + message = sprintf ("Greetings from process: %d!", my_rank); + ## rankvect is the vector containing the list of rank of destination process + rankvect = 0; + [info] = MPI_Send (message, rankvect, TAG, CW); else - for source = 1:p-1 - disp("We are at rank 0 that is master etc.."); - [message, info] = MPI_Recv(source,TAG,CW); - printf('%s\n', message); - endfor - end - + for source = 1:p-1 + disp ("We are at rank 0 that is master etc.."); + [message, info] = MPI_Recv (source, TAG, CW); + printf ("%s\n", message); + endfor + endif + MPI_Finalize(); +endfunction + +%!demo +%! system ("mpirun --hostfile $HOSTFILE -np $NUMBER_OF_MPI_NODES octave -q --eval 'pkg load openmpi_ext; helloworld ()'"); + Modified: trunk/octave-forge/main/openmpi_ext/inst/mc_example.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/mc_example.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/mc_example.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -13,35 +13,44 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# mc_example: shows how Monte Carlo can be done using mpi, Does Monte -# Carlo on the OLS estimator. Uses montecarlo.m -# -# USAGE: from the command prompt, not the octave prompt, execute -# orterun -np 3 octave --eval mc_example +## -*- texinfo -*- +## @deftypefn {Function File} {} = mc_example () +## Demonstrates doing Monte Carlo with mpi. +## Does Monte Carlo on the OLS estimator. Uses montecarlo.m +## @seealso{hello2dimmat,helloworld,hellocell,hellosparsemat,Pi,montecarlo,hellostruct} +## @end deftypefn -1; -function betahat = olswrapper(args) - n = args{1}; - theta = args{2}; - x = [ones(n,1) randn(n,1)]; - y = x*theta + randn(n,1); - betahat = ols(y,x); - betahat = betahat'; -endfunction +function mc_example () + n = 30; + theta = [1;1]; -n = 30; -theta = [1;1]; + reps = 1000; + f = "olswrapper"; + args = {n, theta}; + outfile = "mc_output"; + n_pooled = 10; + verbose = true; -reps = 1000; -f = "olswrapper"; -args = {n, theta}; -outfile = "mc_output"; -n_pooled = 10; -verbose = true; + ## montecarlo(f, args, reps, outfile, n_pooled, false, verbose); -# montecarlo(f, args, reps, outfile, n_pooled, false, verbose); + if not (MPI_Initialized ()) + MPI_Init (); + endif + + montecarlo (f, args, reps, outfile, n_pooled, verbose); + if not (MPI_Finalized) + MPI_Finalize; + endif -if not(MPI_Initialized) MPI_Init; endif -montecarlo(f, args, reps, outfile, n_pooled, verbose); -if not(MPI_Finalized) MPI_Finalize; endif +endfunction + +function betahat = olswrapper (args) + n = args{1}; + theta = args{2}; + x = [ones(n,1) randn(n,1)]; + y = x*theta + randn(n,1); + betahat = ols(y,x); + betahat = betahat'; +endfunction + Modified: trunk/octave-forge/main/openmpi_ext/inst/montecarlo.m =================================================================== --- trunk/octave-forge/main/openmpi_ext/inst/montecarlo.m 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/inst/montecarlo.m 2012-08-29 16:28:49 UTC (rev 10927) @@ -13,124 +13,129 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -# montecarlo.m: generates a specified number of replications of a function's -# output and writes them to a user-specified output file. -# -# USAGE: montecarlo(f,f_args,reps,outfile,n_pooled,n_returns,usempi, verbose) -# -# IMPORTANT: f should return a row vector of output from feval(f,f_args) -# -# For normal evaluation on one core, only the first 4 arguments are required. -# * Arg 1: (required) the function that generates a row vector of output -# * Arg 2: (required) the arguments of the function, in a cell -# * Arg 3: (required) the number of replications to generate -# * Arg 4: (required) the output file name -# * Arg 5 (optional) number of replications to be pooled together between writes -# * Arg 6 (optional) verbose: 1 for on, 0 for off -# -# If using MPI, you should run using ranks equal to number of cores plus 1, -# and should make sure that the core running the frontend is also the one that -# has the second rank. That way the core the frontend is on will also do work. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{n_received}]} = @ +## montecarlo (@var{f}, @var{f_args}, @var{reps}, @var{outfile}, @var{n_pooled}, @var{n_returns}, @var{usempi}, @var{verbose}) +## Generate a specified number of replications of a function's +## output and write them to a user-specified output file. +## +## IMPORTANT: @var{f} should return a row vector of output from feval (f, f_args) +## +## For normal evaluation on one core, only the first 4 arguments are required. +## +## @itemize @minus +## @item Arg 1: (required) the function that generates a row vector of output +## @item Arg 2: (required) the arguments of the function, in a cell +## @item Arg 3: (required) the number of replications to generate +## @item Arg 4: (required) the output file name +## @item Arg 5 (optional) number of replications to be pooled together between writes +## @item Arg 6 (optional) verbose: 1 for on, 0 for off +## @end itemize +## +## If using MPI, you should run using ranks equal to number of cores plus 1, +## and should make sure that the core running the frontend is also the one that +## has the second rank. That way the core the frontend is on will also do work. +## @end deftypefn -function n_received = montecarlo(f,f_args,reps,outfile,n_pooled,verbose) +function n_received = montecarlo (f, f_args, reps, outfile, n_pooled, verbose) - t0 = clock(); # initialize timing + t0 = clock(); # initialize timing - # defaults for optional arguments - if (nargin < 6) verbose = false; endif - if (nargin < 5) n_pooled = 1; endif; + ## defaults for optional arguments + if (nargin < 6) verbose = false; endif + if (nargin < 5) n_pooled = 1; endif; - if MPI_Initialized # check if doing this parallel or serial - use_mpi = true; - CW = MPI_Comm_Load("NEWORLD"); - is_node = MPI_Comm_rank(CW); - nodes = MPI_Comm_size(CW); - mytag = 48; - else - use_mpi = false; - is_node = 0; - endif + if MPI_Initialized # check if doing this parallel or serial + use_mpi = true; + CW = MPI_Comm_Load("NEWORLD"); + is_node = MPI_Comm_rank(CW); + nodes = MPI_Comm_size(CW); + mytag = 48; + else + use_mpi = false; + is_node = 0; + endif - if is_node # compute nodes - more_please = 1; - while more_please - for i = 1:n_pooled - contrib = feval(f, f_args); - contribs(i,:) = contrib; - endfor - MPI_Send(contribs, 0, mytag, CW); - pause(0.05); # give time for the fronted to send a stop message, if done - # check if we're done - if (MPI_Iprobe(0, is_node, CW)) # check for ping from rank 0 - junk = MPI_Recv(0, is_node, CW); - break; - endif - endwhile - else # frontend - received = 0; - done = false; - while received < reps - if use_mpi - # retrieve results from compute nodes - for i = 1:nodes-1 - # compute nodes have results yet? - ready = false; - ready = MPI_Iprobe(i, mytag, CW); # check if message pending - if ready - # get it if it's there - contribs = MPI_Recv(i, mytag, CW); - need = reps - received; - received = received + n_pooled; - # truncate? - if n_pooled >= need - contribs = contribs(1:need,:); - done = true; - endif - # write to output file - FN = fopen (outfile, "a"); - if (FN < 0) error ("montecarlo: couldn't open output file %s", outfile); endif - t = etime(clock(), t0); - for j = 1:rows(contribs) - fprintf(FN, "%f ", i, t, contribs(j,:)); - fprintf(FN, "\n"); - endfor - fclose(FN); - if verbose printf("\nContribution received from node%d. Received so far: %d\n", i, received); endif - if done - # tell compute nodes to stop loop - for j = 1:5 - for i = 1:(nodes-1) - if (j==1) MPI_Send(" ",i,i,CW); endif # send out message to stop - ready = MPI_Iprobe(i, mytag, CW); # get last messages - if ready contribs = MPI_Recv(i, mytag, CW); endif - endfor - endfor - break; - endif - endif - endfor - else - for i = 1:n_pooled - contrib = feval(f, f_args); - contribs(i,:) = contrib; - endfor - need = reps - received; - received = received + n_pooled; - # truncate? - if n_pooled >= need - contribs = contribs(1:need,:); - endif - # write to output file - FN = fopen (outfile, "a"); - if (FN < 0) error ("montecarlo: couldn't open output file %s", outfile); endif - t = etime(clock(), t0); - for j = 1:rows(contribs) - fprintf(FN, "%f ", 0, t, contribs(j,:)); - fprintf(FN, "\n"); - endfor - fclose(FN); - if verbose printf("\nContribution received from node 0. Received so far: %d\n", received); endif - endif - endwhile - endif + if is_node # compute nodes + more_please = 1; + while more_please + for i = 1:n_pooled + contrib = feval(f, f_args); + contribs(i,:) = contrib; + endfor + MPI_Send(contribs, 0, mytag, CW); + pause(0.05); # give time for the fronted to send a stop message, if done + # check if we're done + if (MPI_Iprobe(0, is_node, CW)) # check for ping from rank 0 + junk = MPI_Recv(0, is_node, CW); + break; + endif + endwhile + else # frontend + received = 0; + done = false; + while received < reps + if use_mpi + ## retrieve results from compute nodes + for i = 1:nodes-1 + ## compute nodes have results yet? + ready = false; + ready = MPI_Iprobe(i, mytag, CW); # check if message pending + if ready + ## get it if it's there + contribs = MPI_Recv(i, mytag, CW); + need = reps - received; + received = received + n_pooled; + ## truncate? + if n_pooled >= need + contribs = contribs(1:need,:); + done = true; + endif + ## write to output file + FN = fopen (outfile, "a"); + if (FN < 0) error ("montecarlo: couldn't open output file %s", outfile); endif + t = etime(clock(), t0); + for j = 1:rows(contribs) + fprintf(FN, "%f ", i, t, contribs(j,:)); + fprintf(FN, "\n"); + endfor + fclose(FN); + if verbose printf("\nContribution received from node%d. Received so far: %d\n", i, received); endif + if done + ## tell compute nodes to stop loop + for j = 1:5 + for i = 1:(nodes-1) + if (j==1) MPI_Send(" ",i,i,CW); endif # send out message to stop + ready = MPI_Iprobe(i, mytag, CW); # get last messages + if ready contribs = MPI_Recv(i, mytag, CW); endif + endfor + endfor + break; + endif + endif + endfor + else + for i = 1:n_pooled + contrib = feval(f, f_args); + contribs(i,:) = contrib; + endfor + need = reps - received; + received = received + n_pooled; + ## truncate? + if n_pooled >= need + contribs = contribs(1:need,:); + endif + ## write to output file + FN = fopen (outfile, "a"); + if (FN < 0) error ("montecarlo: couldn't open output file %s", outfile); endif + t = etime(clock(), t0); + for j = 1:rows(contribs) + fprintf(FN, "%f ", 0, t, contribs(j,:)); + fprintf(FN, "\n"); + endfor + fclose(FN); + if verbose printf("\nContribution received from node 0. Received so far: %d\n", received); endif + endif + endwhile + endif endfunction Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Barrier.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -27,22 +27,22 @@ DEFUN_DLD (NAME, args, , "-*- texinfo -*-\n\ -@deftypefn {Loadable Function} {} @var{INFO} = MPI_Barrier (@var{COMM})\n \ -Blocks until all processes in the communicator have reached this routine.\n \ -If @var{COMM} octave comunicator object loaded with MPI_Comm_Load is omitted \n \ -returns an error. \n \ - @example\n \ - @group\n \ - @var{INFO} (int) return code\n \ - 0 MPI_SUCCESS No error\n \ - 5 MPI_ERR_COMM Invalid communicator (NULL?)\n \ - 13 MPI_ERR_ARG Invalid argument (typically a NULL pointer?)\n \ -@end group\n \ -@end example\n \ +@deftypefn {Loadable Function} {} @var{INFO} = MPI_Barrier (@var{COMM})\n\ +Blocks until all processes in the communicator have reached this routine.\n\ +If @var{COMM} octave comunicator object loaded with MPI_Comm_Load is omitted \n\ +returns an error. \n\ + @example\n\ + @group\n\ + @var{INFO} (int) return code\n\ + 0 MPI_SUCCESS No error\n\ + 5 MPI_ERR_COMM Invalid communicator (NULL?)\n\ + 13 MPI_ERR_ARG Invalid argument (typically a NULL pointer?)\n\ +@end group\n\ +@end example\n\ @end deftypefn") { - octave_value results; + octave_value_list results; int nargin = args.length (); if (nargin != 1) @@ -53,7 +53,7 @@ || args(0).type_id () != simple::static_type_id ()) { error ("MPI_Barrier: Please enter octave comunicator object"); - results(0) = octave_value(-1); + results(0) = octave_value (-1); } else { @@ -72,14 +72,12 @@ int my_size; int info = MPI_Barrier (comm); - results = info; + results(0) = octave_value (info); } else print_usage (); } } - comm= NULL; - /* [info] = MPI_Barrier (comm) */ return results; } Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_Test.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -33,12 +33,12 @@ @end example\n\ @end deftypefn") { - octave_value retval; + octave_value_list results; if(args.length() != 1 || args(0).type_id () != simple::static_type_id ()) { print_usage (); - results = octave_value (-1); + results(0) = octave_value (-1); } else { @@ -52,7 +52,7 @@ const simple& b = ((const simple &)rep); //octave_stdout << "MPI_Comm_Test has " << b.name_value() << " output arguments.\n"; MPI_Comm res = b.comunicator_value (); - retval = b.name_value (); + results(0) = octave_value (b.name_value ()); } - return retval; + return results; } Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_rank.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -64,6 +64,7 @@ { int my_rank; int info = MPI_Comm_rank (comm, &my_rank); + //std::cout << my_rank << std::endl; if (nargout > 1) results(1) = info; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Comm_size.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -58,8 +58,8 @@ if ((args.length() != 1 ) || args(0).type_id () != simple::static_type_id ()) { - error("MPI_Comm_size: Please enter octave comunicator object"); - results(0) = octave_value(-1); + error ("MPI_Comm_size: Please enter octave comunicator object"); + results(0) = octave_value (-1); } else { @@ -78,7 +78,7 @@ else print_usage (); } - comm = NULL; + // comm = NULL; /* [size info] = MPI_Comm_size (comm) */ } return results; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Probe.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -87,7 +87,7 @@ int src = args(0).int_value (); int tag = args(1).int_value (); - if (! error_status) + if (! error_state) { MPI_Status stat = {0, 0, 0, 0}; int info = MPI_Probe (src, tag, comm, &stat); Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Recv.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -349,7 +349,7 @@ for (octave_idx_type i = 0; i < s[2]; i++) { m.ridx(i) = sridx[i]; - m.data(i) = real(LBNDA1[i])+imag(LBNDA2[i]); + m.data(i) = real (LBNDA1[i]) + imag (LBNDA2[i]); } ov = m; Modified: trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc =================================================================== --- trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc 2012-08-29 02:56:16 UTC (rev 10926) +++ trunk/octave-forge/main/openmpi_ext/src/MPI_Send.cc 2012-08-29 16:28:49 UTC (rev 10927) @@ -24,11 +24,8 @@ /* along the datatype */ int send_class (MPI_Comm comm, octave_value ov, ColumnVector rankrec, int mytag); - int send_string (int t_id, MPI_Comm comm, std::string oi8, ColumnVector rankrec, int mytag); - int send_cell (int t_id, MPI_Comm comm, Cell cell, ColumnVector rankrec, int mytag); - int send_struct (int t_id, MPI_Comm comm, Octave_map map,ColumnVector rankrec, int mytag); template <class Any> @@ -38,9 +35,7 @@ int send_scalar (int t_id, MPI_Datatype TSnd, MPI_Comm comm, Any d, ColumnVector rankrec, int mytag); int send_range (int t_id, MPI_Comm comm, Range range, ColumnVector rankrec, int mytag); - int send_matrix (int t_id, MPI_Datatype TSnd, MPI_Comm comm, octave_value myOv, ColumnVector rankrec, int mytag); - int send_sp_mat (int t_id, MPI_Datatype TSnd, MPI_Comm comm, octave_value MyOv, ColumnVector rankrec, int mytag); // template specialization for complex case @@ -280,6 +275,7 @@ int send_sp_mat (int t_id, MPI_Datatype TSnd, MPI_Comm comm, octave_value MyOv, ColumnVector rankrec, int mytag) { + int info; OCTAVE_LOCAL_BUFFER(int,tanktag,6); tanktag[0] = mytag; @@ -289,7 +285,7 @@ tanktag[4] = mytag+4; tanktag[5] = mytag+5; -#define __MAKE_TYPE_BRANCH__(TMPI,T1,T2,A1) \ +#define __MAKE_TYPE_BRANCH__(TMPI,T0,T1,T2,A1) \ if (TSnd == TMPI and MyOv.T1) \ { \ OCTAVE_LOCAL_BUFFER(int,s,3); \ @@ -316,7 +312,7 @@ for (octave_idx_type ix = 0; ix < m.cols () + 1; ix++) \ scidx[ix]= m.cidx(ix); \ \ - OCTAVE_LOCAL_BUFFER(bool,sdata,m.capacity ()); \ + OCTAVE_LOCAL_BUFFER(T0,sdata,m.capacity ()); \ \ for (octave_idx_type ix = 0; ix < m.capacity (); ix++) \ { \ @@ -353,8 +349,8 @@ } \ } - __MAKE_TYPE_BRANCH__(MPI_INT,is_bool_type(),SparseBoolMatrix,sparse_bool_matrix_value()) - else __MAKE_TYPE_BRANCH__(MPI_DOUBLE,is_real_type(),SparseMatrix,sparse_matrix_value()) + __MAKE_TYPE_BRANCH__(MPI_INT,bool,is_bool_type(),SparseBoolMatrix,sparse_bool_matrix_value()) + else __MAKE_TYPE_BRANCH__(MPI_DOUBLE,double,is_real_type(),SparseMatrix,sparse_matrix_value()) else if (TSnd == MPI_DOUBLE and MyOv.is_complex_type ()) { SparseComplexMatrix m = MyOv.sparse_complex_matrix_value (); @@ -477,7 +473,7 @@ // nd for number of dimensions // dimvec derived datatype // item of cell - int n = cell.capacity(); + int n = cell.capacity (); int info; int tanktag[5]; tanktag[0] = mytag; @@ -502,9 +498,9 @@ // Now start the big loop for (octave_idx_type i = 0; i < rankrec.nelem (); i++) { - info = MPI_Send (&t_id, 1, MPI_INT, rankrec(i), + info = MPI_Send (&t_id, 1, MPI_INT, int (rankrec(i)), tanktag[0], comm); - if (info !=MPI_SUCCESS) + if (info != MPI_SUCCESS) return info; info = MPI_Send (&n, 1, MPI_INT, rankrec(i), tanktag[1], comm); @@ -519,24 +515,23 @@ tanktag[3], comm); if (info != MPI_SUCCESS) return info; + + int cap; + // Now focus on every single octave_value + for (octave_idx_type j = 0; j < n; j++) + { + octave_value ov = cell.data ()[j]; + cap = ov.capacity (); + info = MPI_Send (&cap, 1, MPI_INT, rankrec(i), + newtag, comm); + if (info != MPI_SUCCESS) + return info; + newtag = newtag + ov.capacity (); + info = send_class (comm, ov, rankrec, newtag); + if (info != MPI_SUCCESS) + return info; + } } - - int cap; - // Now focus on every single octave_value - for (octave_idx_type i=0; i<n; i++) - { - octave_value ov = cell.data ()[i]; - cap = ov.capacity (); - info = MPI_Send (&cap, 1, MPI_INT, rankrec(i), - newtag, comm); - if (info != MPI_SUCCESS) - return info; - newtag = newtag + ov.capacity (); - info = send_class (comm, ov, rankrec, newtag); - if (info != MPI_SUCCESS) - return info; - } - return (info); } @@ -574,9 +569,8 @@ int ntagCell = ntagkey + 1; // iterate through keys(fnames) - Octave_map::const_iterator p = map.begin (); int scap; - for (octave_idx_type i=0; p != map.end (); p++, i++) + for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) { // field name std::string key = map.key (p); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-08-29 02:56:25
|
Revision: 10926 http://octave.svn.sourceforge.net/octave/?rev=10926&view=rev Author: carandraug Date: 2012-08-29 02:56:16 +0000 (Wed, 29 Aug 2012) Log Message: ----------- normxcorr2: check input that template is smaller than image Modified Paths: -------------- trunk/octave-forge/main/image/inst/normxcorr2.m Modified: trunk/octave-forge/main/image/inst/normxcorr2.m =================================================================== --- trunk/octave-forge/main/image/inst/normxcorr2.m 2012-08-29 02:45:12 UTC (rev 10925) +++ trunk/octave-forge/main/image/inst/normxcorr2.m 2012-08-29 02:56:16 UTC (rev 10926) @@ -26,6 +26,8 @@ function cc = normxcorr2 (temp, img) if (nargin != 2) print_usage; + elseif (rows (temp) > rows (img) || columns (temp) > columns (img)) + error ("normxcorr2: template must be same size or smaller than image"); endif cc = xcorr2 (img, temp, "coeff"); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-08-29 02:45:19
|
Revision: 10925 http://octave.svn.sourceforge.net/octave/?rev=10925&view=rev Author: carandraug Date: 2012-08-29 02:45:12 +0000 (Wed, 29 Aug 2012) Log Message: ----------- xcorr2: remove old coeff option code, replace by new method Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/xcorr2.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-27 13:28:45 UTC (rev 10924) +++ trunk/octave-forge/main/signal/NEWS 2012-08-29 02:45:12 UTC (rev 10925) @@ -18,8 +18,8 @@ ** Bugfix in `xcorr2' introduced in 1.1.2 that would not accept "none" as scale option. - ** `xcorr2' accepts a new scale option, "norm", to return the normalized - cross correlation. + ** `xcorr2' scaling option "coeff" was changed to return the normalized + cross-correlation. ** The following functions are new: movingrms schtrig clustersegment Modified: trunk/octave-forge/main/signal/inst/xcorr2.m =================================================================== --- trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-27 13:28:45 UTC (rev 10924) +++ trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-29 02:45:12 UTC (rev 10925) @@ -41,10 +41,6 @@ ## element. ## ## @item "coeff" -## Normalizes the sequence dividing by the max of the cross-correlation, so that -## the largest cross-correlation element is 1. -## -## @item "norm" ## Returns the normalized cross-correlation. ## @end table ## @@ -75,7 +71,7 @@ ## bias routines by Dave Cogdell (cog...@as...) ## optimized by Paul Kienzle (pki...@us...) - ## norm routine by Carnë Draug (car...@gm...) + ## coeff routine by Carnë Draug (car...@gm...) switch lower (biasflag) case {"none"} ## do nothing, it's all done @@ -94,15 +90,10 @@ c = c./bias; case {"coeff"} - c = c/max(c(:))'; - - case {"norm"} - ## FIXME maybe these conversions for double can be removed when - ## https://savannah.gnu.org/bugs/?37199 gets fixed? a = double (a); b = double (b); a = conv2 (a.^2, ones (size (b))); - b = dot (b(:), b(:)); + b = sumsq (b(:)); c(:,:) = c(:,:) ./ sqrt (a(:,:) * b); otherwise @@ -110,7 +101,7 @@ endswitch endfunction -%!test +%!test # basic usage %! a = magic (5); %! b = [6 13 22; 10 18 23; 8 15 23]; %! c = [391 807 519 391 473 289 120 @@ -121,3 +112,22 @@ %! 473 1006 1643 1457 946 347 108 %! 242 539 850 477 374 129 54]; %! assert (xcorr2 (a, b), c); + +%!shared a, b, c, row_shift, col_shift +%! row_shift = 18; +%! col_shift = 20; +%! a = randi (255, 30, 30); +%! b = a(row_shift-10:row_shift, col_shift-7:col_shift); +%! c = xcorr2 (a, b, "coeff"); +%!assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # should return exact coordinates +%! m = rand (size (b)) > 0.5; +%! b(m) = b(m) * 0.95; +%! b(!m) = b(!m) * 1.05; +%! c = xcorr2 (a, b, "coeff"); +%!assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # even with some small noise, should return exact coordinates + +%!test # coeff of autocorrelation must be same as negavtive of correlation by additive inverse +%! a = 10 * randn (100, 100); +%! auto = xcorr2 (a, "coeff"); +%! add_in = xcorr2 (a, -a, "coeff"); +%! assert ([min(auto(:)), max(auto(:))], -[max(add_in(:)), min(add_in(:))]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-27 13:28:51
|
Revision: 10924 http://octave.svn.sourceforge.net/octave/?rev=10924&view=rev Author: paramaniac Date: 2012-08-27 13:28:45 +0000 (Mon, 27 Aug 2012) Log Message: ----------- control: fix texinfo bug Modified Paths: -------------- trunk/octave-forge/main/control/inst/WestlandLynx.m Modified: trunk/octave-forge/main/control/inst/WestlandLynx.m =================================================================== --- trunk/octave-forge/main/control/inst/WestlandLynx.m 2012-08-27 13:22:35 UTC (rev 10923) +++ trunk/octave-forge/main/control/inst/WestlandLynx.m 2012-08-27 13:28:45 UTC (rev 10924) @@ -40,8 +40,7 @@ ## @cite{Multivariable Feedback Control: Analysis and Design: ## Second Edition}. Wiley. ## @url{http://www.nt.ntnu.no/users/skoge/book/2nd_edition/matlab_m/matfiles.html} -## @end group -## @end example +## ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |