From: <jpi...@us...> - 2012-04-15 10:51:53
|
Revision: 10224 http://octave.svn.sourceforge.net/octave/?rev=10224&view=rev Author: jpicarbajal Date: 2012-04-15 10:51:47 +0000 (Sun, 15 Apr 2012) Log Message: ----------- miscellaneous: Adding truncate function for evaluation of the community. Added Paths: ----------- trunk/octave-forge/main/miscellaneous/devel/truncate.m Removed Paths: ------------- trunk/octave-forge/main/miscellaneous/inst/truncate.m Copied: trunk/octave-forge/main/miscellaneous/devel/truncate.m (from rev 10223, trunk/octave-forge/main/miscellaneous/inst/truncate.m) =================================================================== --- trunk/octave-forge/main/miscellaneous/devel/truncate.m (rev 0) +++ trunk/octave-forge/main/miscellaneous/devel/truncate.m 2012-04-15 10:51:47 UTC (rev 10224) @@ -0,0 +1,43 @@ +%% Copyright (c) 2012 Juan Pablo Carbajal <car...@if...> +%% +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{y} = } truncate (@var{x}, @var{order}) +%% Truncates @var{X} to @var{order} of magnitude. +%% +%% Example +%% @example +%% format long +%% x = 987654321.123456789; +%% order = [3:-1:0 -(1:3)]'; +%% y = truncate(x,order) +%% y = +%% 987654000.000000 +%% 987654300.000000 +%% 987654320.000000 +%% 987654321.000000 +%% 987654321.100000 +%% 987654321.120000 +%% 987654321.123000 +%% @end example +%% +%% @seealso{round,fix,ceil,floor} +%% @end deftypefn + +function y = truncate (x,order) + ino = 0.1.^order; + o = 10.^order; + y = round (x.*ino).*o; +end Deleted: trunk/octave-forge/main/miscellaneous/inst/truncate.m =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/truncate.m 2012-04-15 10:50:05 UTC (rev 10223) +++ trunk/octave-forge/main/miscellaneous/inst/truncate.m 2012-04-15 10:51:47 UTC (rev 10224) @@ -1,43 +0,0 @@ -%% Copyright (c) 2012 Juan Pablo Carbajal <car...@if...> -%% -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} {@var{y} = } truncate (@var{x}, @var{order}) -%% Truncates @var{X} to @var{order} of magnitude. -%% -%% Example -%% @example -%% format long -%% x = 987654321.123456789; -%% order = [3:-1:0 -(1:3)]'; -%% y = truncate(x,order) -%% y = -%% 987654000.000000 -%% 987654300.000000 -%% 987654320.000000 -%% 987654321.000000 -%% 987654321.100000 -%% 987654321.120000 -%% 987654321.123000 -%% @end example -%% -%% @seealso{round,fix,ceil,floor} -%% @end deftypefn - -function y = truncate (x,order) - ino = 0.1.^order; - o = 10.^order; - y = round (x.*ino).*o; -end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |