changeset 9602:ea1ae710473c octave-forge

miscellaneous: fix indentations, help text, use of print_usage, fix on demos, added simple input check
author carandraug
date Thu, 08 Mar 2012 16:23:48 +0000
parents 3f9bfc8db45d
children 7e209e97b77e
files main/miscellaneous/inst/asci.m main/miscellaneous/inst/chebyshevpoly.m main/miscellaneous/inst/csv2latex.m main/miscellaneous/inst/hermitepoly.m main/miscellaneous/inst/infoskeleton.m main/miscellaneous/inst/laguerrepoly.m main/miscellaneous/inst/legendrepoly.m
diffstat 7 files changed, 128 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/main/miscellaneous/inst/asci.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/asci.m	Thu Mar 08 16:23:48 2012 +0000
@@ -1,5 +1,5 @@
-%# Copyright (C) 2008, Thomas Treichl <thomas.treichl@gmx.net>
-%#
+## Copyright (C) 2008, Thomas Treichl <thomas.treichl@gmx.net>
+##
 ## This program is free software; you can redistribute it and/or modify it under
 ## the terms of the GNU General Public License as published by the Free Software
 ## Foundation; either version 3 of the License, or (at your option) any later
@@ -13,16 +13,25 @@
 ## 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} {[@var{string}] =} asci ([@var{columns}])
-%# If this function is called without any input argument and without any output argument then print a nice ASCI-table (excluding special characters with hexcode 0x00 to 0x20) on screen with four columns per default. If this function is called with one output argument then return an ASCI-table string and don't print anything on screen. Finally, if this function is called with one input argument of type scalar then either print (no output argument) or return (one output argument) an ASCI-table with a number of columns given in @var{columns}.
-%#
-%# For example,
-%# @example
-%# A = asci (3);
-%# disp (A);
-%# @end example
-%# @end deftypefn
+## -*- texinfo -*-
+## @deftypefn {Function} {[@var{string}] =} asci ([@var{columns}])
+## Print ASCI table.
+##
+## If this function is called without any input argument and without any output
+## argument then print a nice ASCI-table (excluding special characters with
+## hexcode 0x00 to 0x20) on screen with four columns per default. If this
+## function is called with one output argument then return an ASCI-table string
+## and don't print anything on screen. Finally, if this function is called with
+## one input argument of type scalar then either print (no output argument) or
+## return (one output argument) an ASCI-table with a number of columns given in
+## @var{columns}.
+##
+## For example,
+## @example
+## A = asci (3);
+## disp (A);
+## @end example
+## @end deftypefn
 
 function [varargout] = asci (varargin)
 
@@ -77,7 +86,3 @@
 %!  A = asci ();
 %!test
 %!  A = asci (2);
-
-%# Local Variables: ***
-%# mode: octave ***
-%# End: ***
--- a/main/miscellaneous/inst/chebyshevpoly.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/chebyshevpoly.m	Thu Mar 08 16:23:48 2012 +0000
@@ -29,39 +29,38 @@
 ## @end deftypefn
 
 function h=chebyshevpoly(kind,order,val)
-	if nargin < 2, error('usage: chebyshevpoly(kind,order,val)'), end
-	
-        h_prev=[0 1];
-	if kind == 1		 
-          h_now=[1 0];
-        elseif (kind == 2)
-          h_now=[2 0];
-        else 
-          error('unknown kind');
-        end
+  if nargin < 2, print_usage, endif
 
-	if order == 0
-	   h=h_prev;
-        else
-           h=h_now;
-        end
+  h_prev=[0 1];
+  if kind == 1
+    h_now=[1 0];
+  elseif (kind == 2)
+    h_now=[2 0];
+  else
+    error('unknown kind');
+  endif
+
+  if order == 0
+    h=h_prev;
+  else
+    h=h_now;
+  endif
 
-	for ord=2:order
-         x=[];y=[];
-         if (length(h_now) < (1+ord))
-	   x=0;
-         end;
-	 y=zeros(1,(1+ord)-length(h_prev));
-	 p1=[h_now, x];
-         p3=[y, h_prev];
-         h=2*p1  -p3;
-	 h_prev=h_now;
-	 h_now=h;
-	end
+  for ord=2:order
+    x=[];y=[];
+    if (length(h_now) < (1+ord))
+      x=0;
+    endif
+    y=zeros(1,(1+ord)-length(h_prev));
+    p1=[h_now, x];
+    p3=[y, h_prev];
+    h=2*p1  -p3;
+    h_prev=h_now;
+    h_now=h;
+  endfor
 
-        if nargin == 3
-    	 h=polyval(h,val);
-	end
-	
-	return
-end
+  if nargin == 3
+    h=polyval(h,val);
+  endif
+
+endfunction
--- a/main/miscellaneous/inst/csv2latex.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/csv2latex.m	Thu Mar 08 16:23:48 2012 +0000
@@ -13,7 +13,6 @@
 ## You should have received a copy of the GNU General Public License along with
 ## this program; if not, see <http://www.gnu.org/licenses/>.
 
-function csv2latex(csv_file, csv_sep, latex_file, tabular_alignments, has_hline, column_titles, row_titles)
 ## Creates a latex file from a csv file. The generated latex file contains a 
 ## tabular with all values of the csv file. The tabular can be decorated with 
 ## row and column titles. The generated latex file can be inserted in any latex
@@ -48,6 +47,8 @@
 ##  csv2latex('example.csv', '\t', 'example.tex', {'|l|', 'l|'}, true, 
 ##            {'Column 1', 'Column 2', 'Column 3'}, {'Row 1', 'Row 2'});
 
+function csv2latex(csv_file, csv_sep, latex_file, tabular_alignments, has_hline, column_titles, row_titles)
+
   ## set up the default values
   if nargin < 7
    row_titles = {};
--- a/main/miscellaneous/inst/hermitepoly.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/hermitepoly.m	Thu Mar 08 16:23:48 2012 +0000
@@ -25,8 +25,8 @@
 ## 
 ## @end deftypefn
 
-function h=hermitepoly(order,val)
-  if nargin < 1, error('usage: hermitepoly(order.val)'), end
+function h = hermitepoly (order, val)
+  if nargin < 1, print_usage, end
   
   ## contains the first 50 hermite-polynomials
   H = [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 2.00000000e+00 0.00000000e+00
@@ -101,7 +101,7 @@
     for ord=51:order
       x=[];y=[];
       if (length(h_now) < (1+ord))
-    	x=0;
+        x=0;
       end;
       y=zeros(1,(1+ord)-length(h_prev));
       h=[2*h_now, x] -[y, 2*(ord-1)*h_prev];
@@ -113,7 +113,4 @@
   if nargin == 2
     h = polyval(h,val);
   end
-	
-  return
-end
-
+endfunction
--- a/main/miscellaneous/inst/infoskeleton.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/infoskeleton.m	Thu Mar 08 16:23:48 2012 +0000
@@ -93,11 +93,11 @@
   ## generate the code
   fprintf("## -*- texinfo -*-\n")
   if ( length( retval ) > 0 )
-    fprintf("## @deftypefn{Function File} {@var{%s} = } %s (", \
-	    retval,fname );
+    fprintf("## @deftypefn{Function File} {@var{%s} = } %s (", ...
+            retval,fname );
   else
-    fprintf("## @deftypefn{Function File} { } %s (", \
-	    fname );
+    fprintf("## @deftypefn{Function File} { } %s (", ...
+            fname );
   end
 
   pos = 0;
@@ -124,8 +124,7 @@
   fprintf("## @seealso{%s}\n",seealso);
   fprintf("## @end deftypefn\n");
 end
-##   examples: 
-##   infoskeleton( ' [x,y,z]=infoskeleton(func , z , z9 , jj, fjh, x)  ')
-##   infoskeleton('[V,Q] = eig( A )','linear algebra','eigs, chol, qr, det')
-##   infoskeleton( 'function [x,y,z] =  indian_languages ( x)  ')
-##
+
+%!demo infoskeleton( ' [x,y,z]=infoskeleton(func , z , z9 , jj, fjh, x)  ')
+%!demo infoskeleton('[V,Q] = eig( A )','linear algebra','eigs, chol, qr, det')
+%!demo infoskeleton( 'function [x,y,z] =  indian_languages ( x)  ')
--- a/main/miscellaneous/inst/laguerrepoly.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/laguerrepoly.m	Thu Mar 08 16:23:48 2012 +0000
@@ -27,35 +27,37 @@
 ##
 ## @end deftypefn
 
-function h=laguerrepoly(order,val)
-	if nargin < 1, error('usage: hermitepoly(order.val)'), end
-	
-	h_prev=[0 1];
-        h_now=[-1 1];
+function h = laguerrepoly (order, val)
+  if (nargin < 1 || nargin > 2)
+    print_usage
+  endif
 
-	if order == 0
-	   h=h_prev;
-        else
-           h=h_now;
-        end
+  h_prev=[0 1];
+  h_now=[-1 1];
+
+  if order == 0
+    h=h_prev;
+  else
+    h=h_now;
+  endif
 
-	for ord=2:order
-         x=[];y=[];
-         if (length(h_now) < (1+ord))
-	   x=0;
-         end;
-	 y=zeros(1,(1+ord)-length(h_prev));
-	 p1=[h_now, x];
-         p2=[x, h_now];
-         p3=[y, h_prev];
-         h=((2*ord -1).*p2 -p1 -(ord -1).*p3)./(ord);
-	 h_prev=h_now;
-	 h_now=h;
-	end
+  for ord=2:order
+    x=[];
+    y=[];
+    if (length(h_now) < (1+ord))
+      x=0;
+    endif
+    y=zeros(1,(1+ord)-length(h_prev));
+    p1=[h_now, x];
+    p2=[x, h_now];
+    p3=[y, h_prev];
+    h=((2*ord -1).*p2 -p1 -(ord -1).*p3)./(ord);
+    h_prev=h_now;
+    h_now=h;
+  endfor
 
-        if nargin == 2
-    	 h=polyval(h,val);
-	end
-	
-	return
-end
+  if nargin == 2
+    h=polyval(h,val);
+  endif
+
+endfunction
--- a/main/miscellaneous/inst/legendrepoly.m	Thu Mar 08 16:22:56 2012 +0000
+++ b/main/miscellaneous/inst/legendrepoly.m	Thu Mar 08 16:23:48 2012 +0000
@@ -27,34 +27,36 @@
 ##
 ## @end deftypefn
 
-function h=legendrepoly(order,val)
-	if nargin < 1, error('usage: legendrepoly(order,val)'), end
-	
-	h_prev=[0 1];
-        h_now=[1 0];
+function h = legendrepoly (order, val)
+  if (nargin < 1 || nargin > 2)
+    print_usage
+  endif
 
-	if order == 0
-	   h=h_prev;
-        else
-           h=h_now;
-        end
+  h_prev = [0 1];
+  h_now  = [1 0];
+
+  if order == 0
+    h=h_prev;
+  else
+    h=h_now;
+  endif
 
-	for ord=2:order
-         x=[];y=[];
-         if (length(h_now) < (1+ord))
-	   x=0;
-         end;
-	 y=zeros(1,(1+ord)-length(h_prev));
-	 p1=[h_now, x];
-         p3=[y, h_prev];
-         h=((2*ord -1).*p1  -(ord -1).*p3)./(ord);
-	 h_prev=h_now;
-	 h_now=h;
-	end
+  for ord=2:order
+    x=[];
+    y=[];
+    if (length(h_now) < (1+ord))
+      x=0;
+    endif
+    y=zeros(1,(1+ord)-length(h_prev));
+    p1=[h_now, x];
+    p3=[y, h_prev];
+    h=((2*ord -1).*p1  -(ord -1).*p3)./(ord);
+    h_prev=h_now;
+    h_now=h;
+  endfor
 
-        if nargin == 2
-    	 h=polyval(h,val);
-	end
-	
-	return
-end
+  if nargin == 2
+    h=polyval(h,val);
+  endif
+
+endfunction