changeset 10038:c2a549f1d3f8 octave-forge

miscellaneous: Adding truncate function for evaluation of the community.
author jpicarbajal
date Sun, 15 Apr 2012 10:51:47 +0000
parents 7b32308b8ef5
children f7009e743728
files main/miscellaneous/devel/truncate.m main/miscellaneous/inst/truncate.m
diffstat 2 files changed, 43 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/miscellaneous/devel/truncate.m	Sun Apr 15 10:51:47 2012 +0000
@@ -0,0 +1,43 @@
+%% Copyright (c) 2012 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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
--- a/main/miscellaneous/inst/truncate.m	Sun Apr 15 10:50:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-%% Copyright (c) 2012 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
-%%
-%%    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